:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #d8dee6;
  --border-strong: #c2cad4;
  --text: #172033;
  --muted: #647084;
  --muted-2: #8b95a5;
  --primary: #2457b0;
  --primary-soft: #eaf1ff;
  --green: #1c7c55;
  --green-soft: #e7f6ee;
  --amber: #a86b00;
  --amber-soft: #fff4d6;
  --red: #b33a3a;
  --red-soft: #fdeaea;
  --blue-soft: #eaf3fb;
  --shadow: 0 10px 30px rgba(28, 39, 56, 0.12);
  --radius: 8px;
  --sidebar-w: 236px;
  --topbar-h: 64px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Segoe UI",
    "Microsoft YaHei",
    "PingFang SC",
    Arial,
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: #1f2937;
  color: #f8fafc;
  z-index: 20;
}

.sidebar-backdrop {
  display: none;
}

.brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
  font-weight: 800;
  font-size: 17px;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-sub {
  margin-top: 2px;
  color: #aab3c1;
  font-size: 11px;
}

.nav-list {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
}

.nav-item {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-radius: 7px;
  color: #ccd3dd;
  background: transparent;
  text-align: left;
  margin-bottom: 4px;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.nav-item.is-active {
  background: #ffffff;
  color: #172033;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.nav-icon svg,
.icon-button svg,
.connection-pill svg,
.empty-icon svg,
.inline-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-badge {
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e5f6ec;
  color: #1c7c55;
  font-size: 11px;
  font-weight: 700;
}

.nav-item.is-active .nav-badge {
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.offline-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #aab3c1;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #43b581;
  box-shadow: 0 0 0 4px rgba(67, 181, 129, 0.15);
}

.main-shell {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  font-size: 16px;
  font-weight: 700;
}

.connection-pill {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 12px;
}

.connection-pill svg {
  width: 15px;
  height: 15px;
}

.role-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-label {
  color: var(--muted);
  font-size: 12px;
}

.role-switch select {
  height: 34px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.role-switch select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 87, 176, 0.12);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
}

#currentUserRole {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(31, 41, 55, 0.96), rgba(36, 87, 176, 0.9)),
    #1f2937;
}

.auth-screen[hidden] {
  display: none !important;
}

.auth-card {
  width: min(430px, 100%);
  padding: 28px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.auth-title {
  font-size: 20px;
  font-weight: 750;
}

.auth-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.auth-form {
  display: grid;
  gap: 13px;
}

.auth-form .field {
  gap: 6px;
}

.auth-error {
  padding: 9px 11px;
  border-radius: 6px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12px;
}

.auth-footnote {
  margin-top: 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.content {
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

.mobile-only {
  display: none;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface);
}

.icon-button:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-soft);
}

.view {
  animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.page-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border-radius: 7px;
  font-weight: 600;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: #1d4b96;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-green {
  background: var(--green-soft);
  color: var(--green);
}

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  min-height: 108px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.stat-value {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 750;
  line-height: 1;
}

.stat-meta {
  margin-top: 10px;
  color: var(--muted-2);
  font-size: 12px;
}

.stat-card.accent-blue {
  border-top: 3px solid var(--primary);
}

.stat-card.accent-green {
  border-top: 3px solid var(--green);
}

.stat-card.accent-amber {
  border-top: 3px solid #d79922;
}

.stat-card.accent-red {
  border-top: 3px solid var(--red);
}

.section-band {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
}

.section-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 15px;
  font-weight: 700;
}

.section-desc {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.section-body {
  padding: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field label {
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 87, 176, 0.12);
}

.field.span-2 {
  grid-column: span 2;
}

.field.span-4 {
  grid-column: 1 / -1;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  padding: 11px 12px;
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fbfcfe;
}

.table-input {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  outline: none;
}

.table-input:hover {
  border-color: var(--border);
  background: #fff;
}

.table-input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(36, 87, 176, 0.1);
}

td.num,
th.num {
  text-align: right;
}

.text-right {
  text-align: right;
}

.money {
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-draft {
  background: #edf0f4;
  color: #566175;
}

.status-pending_dept {
  background: var(--blue-soft);
  color: var(--primary);
}

.status-pending_finance {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-approved {
  background: var(--green-soft);
  color: var(--green);
}

.status-rejected {
  background: var(--red-soft);
  color: var(--red);
}

.status-archived {
  background: #eee8fb;
  color: #6543a5;
}

.empty-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  padding: 32px;
  text-align: center;
}

.empty-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
}

.empty-icon svg {
  width: 24px;
  height: 24px;
}

.empty-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.empty-text {
  color: var(--muted);
  margin-bottom: 14px;
}

.dropzone {
  min-height: 124px;
  display: grid;
  place-items: center;
  padding: 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background 0.18s ease;
}

.dropzone.is-dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone-icon {
  width: 38px;
  height: 38px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow);
}

.dropzone-icon svg {
  width: 20px;
  height: 20px;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.attachment-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.attachment-preview {
  height: 144px;
  display: grid;
  place-items: center;
  background: #eef1f5;
  color: var(--muted);
  overflow: hidden;
  cursor: zoom-in;
}

.attachment-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attachment-info {
  padding: 10px;
}

.attachment-name {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  word-break: break-all;
}

.attachment-name svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.attachment-meta {
  margin-top: 5px;
  color: var(--muted-2);
  font-size: 11px;
}

.recognition-warning {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-top: 7px;
  padding: 6px 8px;
  border: 1px solid #eed8a8;
  border-radius: 6px;
  background: var(--amber-soft);
  color: #745000;
  font-size: 11px;
  line-height: 1.4;
}

.recognition-warning svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  margin-top: 1px;
  stroke: currentColor;
  fill: none;
}

.rules-summary {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.rules-details {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.rules-details summary {
  padding: 10px 12px;
  cursor: pointer;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.rules-details pre {
  max-height: 420px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.attachment-actions {
  display: flex;
  gap: 6px;
  margin-top: 9px;
  flex-wrap: wrap;
}

.ocr-progress {
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: #e9edf2;
  overflow: hidden;
}

.ocr-progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.15s ease;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
}

.search-box {
  position: relative;
  flex: 1 1 260px;
  max-width: 420px;
}

.search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--muted-2);
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-box input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  outline: none;
}

.search-box input:focus {
  border-color: var(--primary);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  gap: 2px;
}

.segment {
  height: 30px;
  padding: 0 10px;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.segment.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(28, 39, 56, 0.12);
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  position: relative;
  padding: 0 0 16px 28px;
  border-left: 2px solid var(--border);
  margin-left: 8px;
}

.timeline li:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
}

.timeline li.completed::before {
  background: var(--primary);
}

.timeline li.rejected::before {
  border-color: var(--red);
  background: var(--red);
}

.timeline-title {
  font-weight: 700;
}

.timeline-meta {
  color: var(--muted);
  font-size: 12px;
}

.timeline-note {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.46);
  overflow-y: auto;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(980px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 18px;
}

.modal-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  min-width: 260px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast.error {
  background: var(--red);
}

.toast.success {
  background: var(--green);
}

.review-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  margin-bottom: 12px;
}

.review-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.review-item-body {
  padding: 0 16px 14px;
  border-top: 1px solid var(--border);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.detail-item {
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 13px;
}

.approval-box {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.approval-cell {
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.approval-cell-label {
  color: var(--muted);
  font-size: 12px;
}

.approval-cell-value {
  margin-top: 14px;
  font-weight: 700;
}

.approval-cell-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.attachment-print-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.preview-zoom-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.preview-zoom-wrap {
  break-inside: avoid;
  page-break-inside: avoid;
}

.print-attachment {
  border: 1px solid #d0d5dc;
  break-inside: avoid;
  page-break-inside: avoid;
}

.print-attachment img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  display: block;
  background: #f5f6f8;
}

.print-attachment-name {
  padding: 6px 8px;
  font-size: 11px;
  border-top: 1px solid #d0d5dc;
  background: #fafbfc;
}

.sync-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.sync-panel {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.sync-panel h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.sync-panel p {
  color: var(--muted);
}

.file-drop-panel {
  min-height: 140px;
  display: grid;
  place-items: center;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin: 0 -24px -24px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.total-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
}

.total-line strong {
  color: var(--text);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

#printRoot {
  display: none;
}

@media (max-width: 1180px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .field.span-2 {
    grid-column: span 2;
  }

  .field.span-4 {
    grid-column: 1 / -1;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }

  .app-shell.sidebar-open .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 19;
    display: block;
    padding: 0;
    background: rgba(15, 23, 42, 0.38);
  }

  .main-shell {
    margin-left: 0;
  }

  .mobile-only {
    display: inline-grid;
  }

  .topbar {
    padding: 0 14px;
  }

  .content {
    padding: 16px;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .approval-box {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sync-card {
    grid-template-columns: 1fr;
  }

  .sticky-actions {
    margin: 0 -16px -16px;
  }
}

@media (max-width: 620px) {
  body {
    -webkit-text-size-adjust: 100%;
  }

  .topbar {
    min-height: 58px;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .topbar-left,
  .topbar-right {
    gap: 6px;
  }

  .topbar-left {
    flex: 1;
    min-width: 0;
  }

  .topbar-right {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .page-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .connection-pill {
    display: none;
  }

  .user-chip {
    gap: 4px;
    max-width: 100%;
  }

  #currentUserName {
    max-width: 76px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #currentUserRole {
    display: none;
  }

  .user-chip .btn {
    min-height: 30px;
    padding: 0 7px;
    font-size: 11px;
  }

  .content {
    padding: 12px;
  }

  .auth-screen {
    align-items: center;
    padding: 12px;
  }

  .auth-card {
    width: min(430px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px);
    padding: 20px;
    border-radius: 8px;
    overflow: hidden;
  }

  .auth-brand {
    margin-bottom: 18px;
  }

  .auth-title {
    font-size: 18px;
  }

  .auth-form .btn {
    min-height: 44px;
  }

  .page-head h1 {
    font-size: 22px;
  }

  .page-head {
    gap: 12px;
    margin-bottom: 14px;
  }

  .section-head {
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 12px;
  }

  .section-head .page-actions {
    width: 100%;
  }

  .section-head .page-actions:not(.compact-actions) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-head .page-actions .btn {
    width: 100%;
    min-width: 0;
    padding: 0 8px;
  }

  .section-body {
    padding: 12px;
  }

  .btn {
    min-height: 42px;
  }

  .btn-sm {
    min-height: 36px;
  }

  .field input,
  .field select,
  .field textarea,
  .table-input,
  .auth-form input {
    font-size: 16px;
  }

  .dropzone {
    min-height: 150px;
    padding: 16px;
    touch-action: manipulation;
  }

  .attachment-grid {
    grid-template-columns: 1fr;
  }

  .attachment-preview {
    height: 180px;
  }

  .attachment-actions .btn {
    flex: 1;
    min-width: 90px;
  }

  .responsive-table .table-wrap,
  .responsive-table {
    overflow: visible;
  }

  .responsive-table table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody {
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  .responsive-table tr {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
  }

  .responsive-table td,
  .responsive-table td.num,
  .responsive-table td.num.money {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
  }

  .responsive-table td:last-child {
    border-bottom: 0;
  }

  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
  }

  .responsive-table td[data-label="操作"] {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .responsive-table td[data-label="操作"] .text-right {
    justify-content: flex-start;
  }

  .responsive-table td[data-label="操作"] .btn {
    min-width: 0;
    flex: 0 1 auto;
  }

  .responsive-table .table-input {
    min-height: 40px;
    padding: 7px 8px;
    border-color: var(--border);
    background: #fff;
  }

  .responsive-table td[data-label="操作"] > .icon-button {
    margin-left: 0;
  }

  .sticky-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    margin: 0 -12px -12px;
  }

  .sticky-actions > div:last-child {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .sticky-actions .btn {
    width: 100%;
  }

  .total-line {
    justify-content: space-between;
  }

  .total-line strong {
    font-size: 18px;
  }

  .modal-backdrop {
    align-items: stretch;
    padding: 0;
  }

  .modal-panel {
    width: 100% !important;
    max-height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
  }

  .modal-body {
    padding: 12px;
  }

  .modal-head,
  .modal-foot {
    padding: 10px 12px;
  }

  .attachment-print-grid {
    grid-template-columns: 1fr;
  }

  .role-label {
    display: none;
  }

  .connection-pill span:last-child {
    display: none;
  }

  .connection-pill {
    padding: 0 10px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field.span-2,
  .field.span-4 {
    grid-column: span 1;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
  }

  .approval-box {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .attachment-print-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
    font-size: 11pt;
    color: #000;
  }

  .app-shell,
  .modal-backdrop,
  .toast-region {
    display: none !important;
  }

  #printRoot {
    display: block !important;
    padding: 8mm;
  }

  #printRoot * {
    box-sizing: border-box;
  }
}
