:root {
  color-scheme: light;
  --ink: #17242b;
  --muted: #6c7a7c;
  --line: #dce6e3;
  --surface: #ffffff;
  --background: #f3f6f5;
  --brand: #0b6f67;
  --brand-soft: #e7f4f0;
  --danger: #b4483e;
  --danger-soft: #fff0ee;
  --shadow: 0 8px 24px rgba(24, 47, 48, 0.07);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--background); color: var(--ink); font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.invoice-shell { width: min(720px, 100%); min-height: 100vh; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom)); }
.page-header { min-height: 52px; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; }
.page-header p { margin: 0 0 1px; color: #79908c; font-size: 10px; font-weight: 760; letter-spacing: .08em; }
.page-header h1 { margin: 0; color: #17342f; font-size: 21px; line-height: 1.2; }
.back-button, .new-button { min-height: 38px; border-radius: 10px; font-weight: 760; }
.back-button { width: 38px; padding: 0; border: 1px solid var(--line); background: var(--surface); color: #24433e; font-size: 31px; line-height: .8; }
.new-button { border: 0; padding: 0 14px; background: var(--brand); color: #fff; font-size: 14px; box-shadow: 0 5px 12px rgba(11,111,103,.18); }

.notice { position: sticky; top: 8px; z-index: 5; margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: #e9f5f1; color: #17675f; font-size: 13px; font-weight: 650; box-shadow: var(--shadow); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.access-panel { margin-top: 28px; padding: 22px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.access-panel strong { display: block; font-size: 16px; }
.access-panel a { display: inline-block; margin-top: 12px; color: var(--brand); font-size: 14px; text-decoration: none; }

.summary-strip { display: grid; grid-template-columns: 1fr 1.35fr; margin-top: 12px; overflow: hidden; border: 1px solid #d9e9e4; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.summary-strip > div { min-height: 70px; display: grid; align-content: center; gap: 3px; padding: 11px 13px; }
.summary-strip > div + div { border-left: 1px solid #e4eeeb; }
.summary-strip span { color: var(--muted); font-size: 12px; }
.summary-strip strong { color: #0a6058; font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: 0; }

.invoice-form { display: grid; gap: 12px; margin-top: 12px; padding: 14px; border: 1px solid #cfe5de; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.form-head { display: flex; align-items: center; justify-content: space-between; }
.form-head h2 { margin: 0; font-size: 17px; }
.form-head button { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: #f1f6f4; color: #547069; font-size: 23px; line-height: 1; }
.invoice-form label { display: grid; gap: 6px; color: #47615c; font-size: 13px; font-weight: 700; }
.invoice-form input, .invoice-form textarea, .search-field input { width: 100%; border: 1px solid var(--line); border-radius: 9px; outline: none; background: #fff; color: var(--ink); }
.invoice-form input { height: 42px; padding: 0 11px; }
.invoice-form textarea { padding: 10px 11px; resize: vertical; }
.invoice-form input:focus, .invoice-form textarea:focus, .search-field input:focus { border-color: #3e998c; box-shadow: 0 0 0 3px rgba(29, 132, 118, .1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.save-button { min-height: 44px; border: 0; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 760; }

.list-tools { margin-top: 15px; }
.search-field { height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.search-field > span { color: #5a7871; font-size: 20px; transform: translateY(-1px); }
.search-field input { height: 100%; padding: 0; border: 0; font-size: 14px; box-shadow: none !important; }
.status-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 10px; }
.status-tabs button { min-height: 35px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: #526863; font-size: 13px; font-weight: 720; }
.status-tabs button.is-active { border-color: #afd7ce; background: var(--brand-soft); color: #07635b; }

.invoice-list-panel { margin-top: 14px; border: 1px solid #e0e8e5; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.list-title { min-height: 45px; display: flex; align-items: center; justify-content: space-between; padding: 0 13px; border-bottom: 1px solid #edf1ef; }
.list-title h2 { margin: 0; font-size: 16px; }
.list-title span { color: var(--muted); font-size: 12px; }
.invoice-list { display: grid; }
.invoice-row { min-height: 76px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px 13px; border-bottom: 1px solid #edf1ef; }
.invoice-row:last-child { border-bottom: 0; }
.invoice-main { min-width: 0; }
.invoice-main strong { display: block; overflow: hidden; color: #1d2c30; font-size: 15px; font-weight: 780; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.invoice-main p { margin: 4px 0 0; color: #6f7f7c; font-size: 12px; line-height: 1.35; }
.invoice-main .invoice-note { overflow: hidden; max-width: 100%; text-overflow: ellipsis; white-space: nowrap; }
.invoice-side { display: grid; justify-items: end; gap: 6px; }
.status { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 760; white-space: nowrap; }
.status.pending { background: var(--danger-soft); color: var(--danger); }
.status.received { background: #e7f4ed; color: #197149; }
.row-action { min-height: 27px; padding: 0 7px; border: 0; border-radius: 6px; background: transparent; font-size: 12px; font-weight: 720; white-space: nowrap; }
.row-action.receive { color: #087267; }
.row-action.reopen { color: #846433; }
.empty-state { padding: 34px 12px; color: var(--muted); font-size: 14px; text-align: center; }

@media (max-width: 360px) {
  .invoice-shell { padding-left: 10px; padding-right: 10px; }
  .page-header h1 { font-size: 20px; }
  .new-button { padding: 0 11px; }
  .invoice-row { padding-left: 11px; padding-right: 11px; }
}
