:root {
  color-scheme: light;
  --ink: #202b2a;
  --muted: #737f7c;
  --soft-muted: #99a39f;
  --line: #e5ebe8;
  --line-strong: #d7e0dc;
  --canvas: #f5f7f6;
  --surface: #ffffff;
  --green: #167e68;
  --green-dark: #116a59;
  --green-pale: #e8f4ef;
  --blue-pale: #edf5fb;
  --blue: #557b9a;
  --red-pale: #fbefed;
  --red: #b45b50;
  --shadow: 0 18px 55px rgba(29, 53, 46, .16);
  font-family: Inter, "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
}

button, input, select { font: inherit; }
button { color: inherit; }
button:disabled { cursor: wait; opacity: .55; }
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(22, 126, 104, .25); outline-offset: 2px; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(390px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.login-description { margin: 12px 0 23px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.login-card .form-field { margin-top: 15px; }
.login-card > .button { width: 100%; margin-top: 22px; }
.login-help { margin: 15px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.account-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 5px 16px; margin-bottom: 18px; color: var(--muted); font-size: 12px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 16px; }
.users-dialog { width: min(630px, calc(100vw - 28px)); }
.users-content { padding: 25px 27px 22px; }
.users-description { color: var(--muted); font-size: 12px; line-height: 1.7; }
.users-list { display: flex; flex-direction: column; gap: 0; margin: 17px 0; border-top: 1px solid var(--line); }
.user-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.user-item > div { min-width: 0; }
.user-item strong { display: block; overflow-wrap: anywhere; font-size: 13px; font-weight: 600; }
.user-item span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.user-item .text-button { flex: 0 0 auto; }
.users-list-empty { padding: 16px 0; color: var(--muted); font-size: 12px; }
.users-content #user-form { padding: 0; }
.user-form-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 15px; }
.user-form-heading h3 { margin: 0; font-size: 14px; font-weight: 600; }
.checkbox-field { display: flex; align-items: center; gap: 7px; color: #596662; font-size: 12px; }
.checkbox-field input { accent-color: var(--green); }

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

.topbar {
  height: 68px;
  padding: 0 max(28px, calc((100vw - 1380px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: var(--green-pale); color: var(--green); }
.brand-mark svg { width: 21px; height: 21px; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-size: 15px; font-weight: 650; }
.topbar-meta, .storage-indicator { display: flex; align-items: center; }
.topbar-meta { gap: 22px; }
.storage-indicator { gap: 7px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #48a184; }
.storage-indicator.is-unavailable .status-dot { background: #bd7653; }
.storage-indicator.is-unavailable { color: #976447; }

.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border: 1px solid transparent; border-radius: 5px; cursor: pointer; font-size: 13px; font-weight: 600; transition: background-color .16s ease, border-color .16s ease, color .16s ease; }
.button svg, .icon-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button-primary { color: white; background: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: #45524f; background: white; border-color: var(--line-strong); }
.button-secondary:hover { background: #f8faf9; border-color: #bfcfc8; }

.main-content { width: min(1380px, 100%); margin: 0 auto; padding: 35px 28px 50px; }
.page-heading { min-height: 62px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 600; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 23px; line-height: 1.3; font-weight: 650; }
.heading-actions { display: flex; gap: 9px; }
.top-add { display: none; }

.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 27px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.42); }
.summary-item { position: relative; min-height: 94px; padding: 19px 22px; display: flex; align-items: baseline; gap: 7px; border-right: 1px solid var(--line); }
.summary-item:first-child { padding-left: 0; }
.summary-item:last-child { border-right: 0; }
.summary-label { margin-right: auto; align-self: flex-start; color: var(--muted); font-size: 12px; }
.summary-item strong { align-self: flex-start; color: var(--ink); font-size: 22px; font-weight: 620; line-height: 1.1; font-variant-numeric: tabular-nums; }
.summary-unit { align-self: flex-start; padding-top: 7px; color: var(--soft-muted); font-size: 11px; }

.records-section { margin-top: 30px; }
.section-topline { min-height: 38px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.section-title-wrap { display: flex; align-items: baseline; gap: 10px; }
.section-title-wrap h2 { margin: 0; font-size: 16px; font-weight: 650; }
.result-count { color: var(--soft-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.text-button { padding: 5px 0; border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.text-button:hover { color: var(--green); }

.filters { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-bottom: 0; background: var(--surface); }
.search-field { height: 36px; min-width: 210px; max-width: 330px; flex: 1 1 300px; position: relative; display: flex; align-items: center; }
.search-field svg { position: absolute; left: 11px; width: 16px; height: 16px; fill: none; stroke: #8c9894; stroke-width: 1.7; stroke-linecap: round; }
.search-field input { width: 100%; height: 100%; padding: 0 12px 0 36px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: white; font-size: 12px; }
.search-field input::placeholder { color: #a0aaa7; }
.date-range { display: flex; align-items: center; gap: 7px; }
.date-field { display: flex; align-items: center; gap: 7px; color: #7d8885; font-size: 11px; white-space: nowrap; }
.date-field input { width: 133px; height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 4px; color: #44514e; background: white; font-size: 11px; }
.date-separator { color: #9da7a4; font-size: 11px; }
.type-filter { margin-left: auto; display: inline-flex; align-items: center; padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: #f7f9f8; }
.filter-option { height: 28px; min-width: 48px; padding: 0 10px; border: 0; border-radius: 3px; color: #73807c; background: transparent; cursor: pointer; font-size: 12px; }
.filter-option.is-active { color: #246f5f; background: white; box-shadow: 0 1px 3px rgba(23, 47, 39, .11); font-weight: 600; }

.table-wrap { position: relative; min-height: 220px; border: 1px solid var(--line); background: var(--surface); overflow-x: auto; }
table { width: 100%; min-width: 920px; border-collapse: collapse; text-align: left; }
thead { background: #f7f9f8; }
th { height: 41px; padding: 0 14px; border-bottom: 1px solid var(--line); color: #74807c; font-size: 11px; font-weight: 600; white-space: nowrap; }
td { height: 54px; padding: 0 14px; border-bottom: 1px solid #edf1ef; color: #43504c; font-size: 12px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfb; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
td.numeric { color: #303d39; }
.record-name { color: var(--ink); font-weight: 600; }
.type-label { display: inline-flex; min-width: 40px; height: 22px; align-items: center; justify-content: center; padding: 0 7px; border-radius: 3px; font-size: 11px; }
.type-label.inbound { color: #327760; background: var(--green-pale); }
.type-label.outbound { color: #557b9a; background: var(--blue-pale); }
.actions-cell { text-align: right; }
.row-actions { display: inline-flex; justify-content: flex-end; gap: 12px; }
.row-action { padding: 4px 0; border: 0; color: #78847f; background: transparent; cursor: pointer; font-size: 11px; }
.row-action:hover { color: var(--green); }
.row-action.delete:hover { color: var(--red); }
.empty-state { min-height: 219px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; color: var(--muted); }
.empty-state[hidden] { display: none; }
.empty-mark { width: 38px; height: 38px; margin-bottom: 3px; display: grid; place-items: center; border-radius: 50%; color: #7c9a8e; background: #f0f5f2; }
.empty-mark svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.empty-state strong { color: #54615d; font-size: 13px; font-weight: 600; }
.empty-state span:last-child { font-size: 11px; }
.mobile-records { display: none; }
.data-note { margin: 12px 1px 0; color: #9aa5a1; font-size: 11px; }
.data-footer { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 5px 16px; }
.data-actions { display: flex; flex-wrap: wrap; gap: 15px; }
.data-note.is-error { color: #976447; }

.record-dialog { width: min(560px, calc(100vw - 28px)); max-width: none; max-height: min(92vh, 780px); padding: 0; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; box-shadow: var(--shadow); overflow: auto; }
.record-dialog::backdrop { background: rgba(20, 34, 30, .36); backdrop-filter: blur(2px); }
.record-dialog form { padding: 25px 27px 22px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.dialog-header .eyebrow { margin-bottom: 5px; }
.dialog-header h2 { margin: 0; font-size: 19px; font-weight: 650; }
.icon-button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 4px; color: #7d8985; background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--ink); background: #f1f5f3; }
.form-type { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 20px; padding: 4px; border: 1px solid var(--line); border-radius: 5px; background: #f6f8f7; }
.form-type-option { height: 34px; border: 0; border-radius: 3px; color: #7b8783; background: transparent; cursor: pointer; font-size: 13px; }
.form-type-option.is-selected { color: var(--green-dark); background: white; box-shadow: 0 1px 3px rgba(23, 47, 39, .1); font-weight: 650; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 14px; }
.form-field { min-width: 0; display: flex; flex-direction: column; gap: 7px; color: #596662; font-size: 12px; }
.form-field > span { font-weight: 600; }
.form-field i { color: #bf6659; font-size: 11px; font-style: normal; }
.form-field input, .form-field select { width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--ink); background: white; font-size: 13px; }
.form-field input::placeholder { color: #a7b0ad; }
.form-field-wide { grid-column: 1 / -1; }
.form-error { margin: 14px 0 0; color: #aa493e; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.toast { position: fixed; z-index: 5; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); padding: 10px 15px; transform: translate(-50%, 14px); border: 1px solid #dbe5df; border-radius: 5px; color: #38574c; background: white; box-shadow: 0 5px 20px rgba(30, 55, 47, .12); font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 1500px) {
  .topbar { padding-right: calc((100vw - 1380px) / 2); padding-left: calc((100vw - 1380px) / 2); }
}

@media (max-width: 980px) {
  .main-content { padding-right: 22px; padding-left: 22px; }
  .filters { flex-wrap: wrap; }
  .search-field { flex-basis: 100%; max-width: none; }
  .type-filter { margin-left: auto; }
}

@media (max-width: 680px) {
  body { background: #f6f8f7; font-size: 13px; }
  .topbar { height: 56px; padding: 0 16px; }
  .brand { gap: 9px; }
  .brand-mark { width: 30px; height: 30px; border-radius: 7px; }
  .brand-mark svg { width: 19px; height: 19px; }
  .brand-name { font-size: 14px; }
  .topbar-meta { gap: 12px; }
  .storage-indicator { font-size: 10px; }
  .status-dot { width: 6px; height: 6px; }
  .top-add { display: inline-flex; min-height: 34px; padding: 0 10px; font-size: 12px; }
  .top-add svg { width: 14px; height: 14px; }
  .main-content { padding: 23px 15px calc(32px + env(safe-area-inset-bottom)); }
  .page-heading { min-height: 44px; align-items: flex-end; }
  .page-heading .eyebrow { margin-bottom: 4px; font-size: 10px; }
  h1 { font-size: 20px; }
  .heading-actions { gap: 7px; }
  .heading-actions .button { display: none; }
  .heading-actions #export-records { display: inline-flex; min-height: 32px; padding: 0 9px; font-size: 12px; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 20px; background: white; }
  .summary-item { min-width: 0; min-height: 68px; display: grid; grid-template-columns: minmax(0, auto) auto auto; justify-content: space-between; align-items: center; gap: 5px; padding: 11px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .summary-item:first-child { padding-left: 12px; }
  .summary-item:nth-child(2) { border-right: 0; }
  .summary-item:nth-child(n+3) { border-bottom: 0; }
  .summary-label { min-width: 0; align-self: center; margin: 0; font-size: 11px; }
  .summary-unit { grid-column: 3; }
  .summary-item strong { align-self: center; font-size: 19px; }
  .summary-unit { align-self: center; padding-top: 3px; font-size: 10px; }
  .records-section { margin-top: 23px; }
  .section-topline { margin-bottom: 11px; }
  .section-title-wrap h2 { font-size: 15px; }
  .filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; padding: 11px; border-bottom: 1px solid var(--line); }
  .filters > * { min-width: 0; }
  .search-field { min-width: 0; height: 38px; }
  .date-range { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; }
  .date-field { width: 100%; min-width: 0; display: flex; align-items: flex-start; flex-direction: column; gap: 5px; font-size: 10px; }
  .date-field input { width: 100%; min-width: 0; height: 36px; padding: 0 7px; font-size: 11px; }
  .date-separator { align-self: end; padding-bottom: 10px; }
  .type-filter { width: 100%; margin: 0; }
  .filter-option { flex: 1; }
  .table-wrap { display: none; }
  .mobile-records { display: flex; flex-direction: column; gap: 9px; }
  .mobile-record { min-width: 0; padding: 13px 13px 12px; border: 1px solid var(--line); border-radius: 5px; background: white; }
  .mobile-record-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .mobile-record-title { min-width: 0; display: flex; align-items: center; gap: 8px; }
  .mobile-record-title strong { min-width: 0; overflow: hidden; color: var(--ink); font-size: 14px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-record-date { flex: 0 0 auto; color: #89948f; font-size: 10px; font-variant-numeric: tabular-nums; }
  .mobile-record-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; padding: 9px 0; border-top: 1px solid #edf1ef; border-bottom: 1px solid #edf1ef; }
  .mobile-metric { display: flex; justify-content: space-between; gap: 8px; color: #7b8782; font-size: 11px; }
  .mobile-metric strong { color: #3d4945; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .mobile-record-details { display: grid; gap: 7px; margin-top: 10px; }
  .mobile-detail { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 8px; color: #8a9591; font-size: 11px; }
  .mobile-detail strong { min-width: 0; overflow-wrap: anywhere; color: #505d58; font-size: 11px; font-weight: 500; }
  .mobile-record-footer { display: flex; justify-content: flex-end; gap: 16px; margin-top: 10px; padding-top: 7px; border-top: 1px solid #edf1ef; }
  .mobile-empty { min-height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); color: #84908b; background: white; }
  .mobile-empty[hidden] { display: none; }
  .mobile-empty strong { color: #54615d; font-size: 13px; }
  .mobile-empty span { font-size: 11px; }
  .data-note { margin-top: 10px; font-size: 10px; }
  .record-dialog { width: 100%; max-width: none; max-height: 94vh; margin: auto 0 0; border-right: 0; border-bottom: 0; border-left: 0; border-radius: 10px 10px 0 0; }
  .record-dialog::backdrop { background: rgba(20, 34, 30, .4); }
  .record-dialog form { padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); }
  .users-content { padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); }
  .users-content #user-form { padding: 0; }
  .users-dialog { width: 100%; }
  .account-toolbar { margin-bottom: 15px; font-size: 11px; }
  .account-actions { gap: 13px; }
  .login-card { padding: 25px 21px; }
  .dialog-header { margin-bottom: 17px; }
  .dialog-header h2 { font-size: 18px; }
  .form-type { margin-bottom: 17px; }
  .form-grid { gap: 13px 10px; }
  .form-field { gap: 6px; font-size: 11px; }
  .form-field input { height: 42px; font-size: 13px; }
  .dialog-actions { margin-top: 19px; }
  .dialog-actions .button { flex: 1; }
}

@media (max-width: 365px) {
  .topbar { padding: 0 11px; }
  .topbar-meta { gap: 8px; }
  .storage-indicator { gap: 5px; font-size: 9px; }
  .top-add { padding: 0 8px; }
  .main-content { padding-right: 11px; padding-left: 11px; }
  .summary-item { padding-right: 9px; padding-left: 9px; }
  .summary-item:first-child { padding-left: 9px; }
  .summary-label { font-size: 10px; }
  .summary-item strong { font-size: 18px; }
  .mobile-record { padding-right: 10px; padding-left: 10px; }
  .mobile-record-title { gap: 5px; }
  .mobile-record-title strong { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
