:root {
  color-scheme: light;
  --ink: #1d1a18;
  --ink-soft: #5e5752;
  --muted: #6f6863;
  --line: #e8e2dc;
  --paper: #f7f4ef;
  --surface: #ffffff;
  --red: #d81022;
  --red-dark: #a90c18;
  --red-wash: #fff0f1;
  --gold: #dda62b;
  --gold-wash: #fff8e7;
  --green: #2e7254;
  --green-wash: #edf8f2;
  --shadow: 0 18px 55px rgba(44, 35, 28, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.auth-screen {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(360px, .95fr) minmax(420px, 1.05fr);
  background: var(--paper);
}
.auth-brand-panel {
  min-height: 100svh;
  padding: clamp(34px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  color: #fff;
  background:
    radial-gradient(circle at 18% 15%, rgba(216,16,34,.28), transparent 27%),
    linear-gradient(145deg, #211b18, #171412 72%);
}
.auth-brand-lockup { display: flex; align-items: center; gap: 14px; }
.auth-brand-lockup > span:last-child { display: grid; gap: 4px; }
.auth-brand-lockup strong { font-family: "Songti SC", STSong, serif; font-size: 20px; letter-spacing: .12em; }
.auth-brand-lockup small { color: #8e8580; font-size: 9px; letter-spacing: .18em; }
.auth-stamp {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 10px 10px 10px 2px;
  color: #fff;
  background: var(--red);
  box-shadow: 0 10px 28px rgba(216,16,34,.3);
  font-family: "Songti SC", STSong, serif;
  font-size: 28px;
  font-weight: 700;
}
.auth-statement { margin: auto 0; }
.auth-statement p { margin: 0 0 16px; color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: .17em; }
.auth-statement h1 { margin: 0; font-family: "Songti SC", STSong, serif; font-size: clamp(36px, 4.6vw, 66px); font-weight: 580; line-height: 1.2; letter-spacing: -.035em; }
.auth-statement span { display: block; max-width: 480px; margin-top: 24px; color: #9d938d; font-size: 13px; line-height: 1.8; }
.auth-footnote { color: #655d58; font-size: 10px; letter-spacing: .08em; }
.auth-form-panel { min-height: 100svh; display: grid; place-items: center; padding: 34px; }
.auth-loading { color: var(--muted); font-size: 13px; }
.auth-form { width: min(390px, 100%); animation: auth-in .28s ease-out; }
.auth-form h2 { margin: 7px 0 10px; font-family: "Songti SC", STSong, serif; font-size: 35px; font-weight: 650; }
.auth-description { margin: 0 0 30px; color: var(--muted); font-size: 13px; }
.auth-form label { display: grid; gap: 8px; margin-bottom: 16px; }
.auth-form label > span { color: var(--ink-soft); font-size: 12px; }
.auth-form input { height: 48px; border-radius: 10px; background: #fff; }
.auth-submit { width: 100%; min-height: 48px; margin-top: 2px; }
.auth-error { margin: 0 0 8px; }
.auth-security-note { display: block; margin-top: 16px; color: var(--muted); font-size: 10px; line-height: 1.6; text-align: center; }
@keyframes auth-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 230px;
  display: flex;
  flex-direction: column;
  color: #fff;
  background:
    radial-gradient(circle at 18% 8%, rgba(216, 16, 34, 0.22), transparent 25%),
    #1d1a18;
  padding: 28px 20px 24px;
}

.brand-lockup { display: flex; align-items: center; gap: 12px; padding: 0 8px 34px; }
.brand-lockup > span:last-child { display: grid; gap: 2px; }
.brand-lockup strong { font-size: 17px; letter-spacing: 0.12em; }
.brand-lockup small { color: #aaa19b; font-size: 11px; letter-spacing: 0.18em; }
.brand-stamp {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--red);
  border-radius: 9px 9px 9px 2px;
  font-family: "Songti SC", STSong, serif;
  font-size: 24px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(216, 16, 34, 0.32);
}

.side-nav { display: grid; gap: 7px; }
.nav-item {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #a9a19c;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  transition: color .18s ease, background .18s ease;
}
.nav-item span { color: #6e6762; font-size: 10px; letter-spacing: .12em; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.09); }
.nav-item.active span { color: var(--gold); }
.mobile-logout { display: none; }

.sidebar-note { margin-top: auto; display: flex; align-items: flex-start; gap: 12px; padding: 20px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-note p { margin: 0; color: #ddd6d1; font-family: "Songti SC", STSong, serif; line-height: 1.5; }
.sidebar-note small { color: #77706b; font-family: inherit; font-size: 11px; }
.gold-mark { width: 4px; height: 34px; margin-top: 3px; background: var(--gold); border-radius: 99px; }

.workspace { grid-column: 2; min-width: 0; padding: 36px 42px 64px; }
.topbar { min-height: 92px; display: flex; justify-content: space-between; align-items: flex-start; gap: 30px; margin-bottom: 24px; }
.topbar h1 { margin: 5px 0 7px; font-family: "Songti SC", STSong, serif; font-size: clamp(28px, 3vw, 40px); font-weight: 650; letter-spacing: -.02em; }
.topbar p { margin: 0; }
.page-subtitle, #pageSubtitle { color: var(--muted); font-size: 14px; }
.eyebrow { color: var(--red); font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: 15px; }
.top-actions time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.user-session { min-height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 5px 0 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.user-session span { max-width: 110px; overflow: hidden; color: var(--ink-soft); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.user-session button { min-height: 26px; border: 0; border-left: 1px solid var(--line); padding: 0 7px 0 10px; color: var(--red-dark); background: transparent; cursor: pointer; font-size: 10px; }

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 650;
  font-size: 13px;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.button-primary { color: #fff; background: var(--red); box-shadow: 0 8px 20px rgba(216,16,34,.18); }
.button-primary:hover { background: var(--red-dark); }
.button-secondary { border-color: var(--line); background: #fff; }

.page { display: none; }
.page.active { display: block; animation: page-in .2s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.scope-banner {
  margin-bottom: 18px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: #635c57;
  background: #eee9e3;
  border: 1px solid #e2dcd5;
  border-radius: 11px;
  font-size: 12px;
}
.scope-banner strong { color: var(--ink); margin-right: 8px; }
.scope-banner button { border: 0; padding: 0; color: var(--red-dark); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; white-space: nowrap; }
.text-button { border: 0; padding: 0; color: var(--red); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; white-space: nowrap; }

.metric-grid { display: grid; grid-template-columns: 1.05fr 1fr 1fr 1fr; gap: 13px; margin-bottom: 13px; }
.metric-card { min-height: 142px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 26px rgba(44,35,28,.035); }
.metric-card span { color: var(--ink-soft); font-size: 12px; }
.metric-card strong { display: block; margin: 16px 0 6px; font-family: "Songti SC", STSong, serif; font-size: 29px; line-height: 1; }
.metric-card small { color: var(--muted); font-size: 11px; }
.metric-lead { color: #fff; background: var(--ink); border-color: var(--ink); }
.metric-lead span, .metric-lead small { color: #aaa29d; }
.warning-card { border-color: #ead7aa; background: var(--gold-wash); }
.warning-card strong { color: #99620a; }

.surface { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 26px rgba(44,35,28,.035); }
.dashboard-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 13px; margin-bottom: 13px; }
.quality-panel, .focus-panel, .recent-panel { padding: 22px; }
.section-heading { min-height: 42px; margin-bottom: 17px; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.section-heading p { margin: 0 0 5px; }
.section-heading h2 { margin: 0; font-family: "Songti SC", STSong, serif; font-size: 20px; font-weight: 650; }
.quiet-badge, .table-summary { color: var(--muted); font-size: 11px; }

.quality-list { display: grid; gap: 2px; }
.quality-list button { border: 0; border-radius: 8px; background: transparent; padding: 11px 9px; display: flex; justify-content: space-between; cursor: pointer; }
.quality-list button:hover { background: var(--paper); }
.quality-list span { display: flex; align-items: center; gap: 9px; color: var(--ink-soft); font-size: 13px; }
.quality-list strong { font-size: 14px; }
.dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; }
.dot.red { background: var(--red); }
.dot.amber { background: var(--gold); }
.dot.ink { background: var(--ink); }
.dot.muted { background: #b8b0aa; }

.focus-list { display: grid; gap: 8px; }
.focus-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 11px; background: #fff; cursor: pointer; text-align: left; }
.focus-item:hover { border-color: #cfc6be; }
.focus-thumb { width: 38px; height: 38px; display: grid; place-items: center; overflow: hidden; border-radius: 8px; color: #a59b94; background: var(--paper); font-family: "Songti SC", STSong, serif; }
.focus-thumb img { width: 100%; height: 100%; object-fit: cover; }
.focus-item strong { display: block; font-size: 13px; }
.focus-item small { color: var(--muted); font-size: 10px; }
.focus-item > span:last-child { color: var(--red); font-size: 11px; }

.empty-inline { min-height: 82px; display: grid; place-items: center; color: var(--muted); font-size: 12px; border: 1px dashed var(--line); border-radius: 10px; }

.toolbar { margin-bottom: 13px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.search-field { flex: 1 1 330px; max-width: 460px; }
.search-field input { width: 100%; height: 43px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 0 15px; outline: none; }
.search-field input:focus { border-color: #a99e95; box-shadow: 0 0 0 3px rgba(29,26,24,.05); }
.filter-group { display: flex; flex-wrap: wrap; gap: 5px; }
.filter { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); cursor: pointer; font-size: 11px; }
.filter.active { color: #fff; border-color: var(--ink); background: var(--ink); }

.inventory-surface, .page[data-page="movements"] .surface { padding: 22px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 11px 12px; color: var(--muted); background: #faf8f5; border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; font-weight: 650; letter-spacing: .04em; }
td { padding: 13px 12px; border-bottom: 1px solid #f0ebe6; color: var(--ink-soft); font-size: 12px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.inventory-table tbody tr { cursor: pointer; }
.inventory-table tbody tr:hover td { background: #fdfbf8; }
.tea-cell strong { display: block; color: var(--ink); font-size: 13px; }
.tea-cell small, .muted-line { color: var(--muted); font-size: 10px; }
.table-thumb { width: 45px; height: 45px; border-radius: 8px; display: grid; place-items: center; overflow: hidden; color: #a69d96; background: var(--paper); font-family: "Songti SC", STSong, serif; }
.table-thumb img { width: 100%; height: 100%; object-fit: cover; }
.weight-main { color: var(--ink); font-weight: 700; }
.weight-main small { font-weight: 400; color: var(--muted); }
.status-pill { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 99px; font-size: 10px; }
.status-pill.net, .movement-pill.purchase { color: var(--green); background: var(--green-wash); }
.status-pill.gross, .movement-pill.adjustment { color: #93600c; background: var(--gold-wash); }
.status-pill.missing, .movement-pill.sale { color: var(--red); background: var(--red-wash); }
.completion-bar { width: 68px; height: 4px; overflow: hidden; border-radius: 99px; background: #eee9e4; }
.completion-bar i { height: 100%; display: block; background: var(--red); border-radius: inherit; }
.completion-bar .score-0 { width: 0; }
.completion-bar .score-25 { width: 25%; }
.completion-bar .score-50 { width: 50%; }
.completion-bar .score-75 { width: 75%; }
.completion-bar .score-100 { width: 100%; }
.completion small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }
.movement-pill { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border-radius: 99px; font-size: 10px; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--ink); }

.backup-layout { min-height: 520px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; padding: clamp(30px, 6vw, 76px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.backup-copy h2 { max-width: 600px; margin: 7px 0 16px; font-family: "Songti SC", STSong, serif; font-size: clamp(30px, 4vw, 48px); line-height: 1.2; }
.backup-copy > p:not(.eyebrow) { max-width: 600px; color: var(--muted); line-height: 1.8; }
.backup-copy dl { margin-top: 34px; display: grid; gap: 13px; }
.backup-copy dl div { display: grid; grid-template-columns: 75px 1fr; gap: 10px; font-size: 12px; }
.backup-copy dt { color: var(--muted); }
.backup-copy dd { margin: 0; word-break: break-all; }
.backup-card { padding: 32px; background: var(--ink); color: #fff; border-radius: 16px; box-shadow: 0 25px 60px rgba(29,26,24,.2); }
.backup-mark { width: 56px; height: 56px; display: grid; place-items: center; color: var(--gold); border: 1px solid #514943; border-radius: 12px; font-weight: 800; font-size: 12px; }
.backup-card h3 { margin: 24px 0 10px; font-family: "Songti SC", STSong, serif; font-size: 24px; }
.backup-card p { color: #aaa29c; font-size: 13px; line-height: 1.7; }
.backup-card .download-button { width: 100%; margin: 16px 0 12px; }
.backup-card small { color: #776f69; font-size: 10px; }

dialog { border: 0; padding: 0; background: transparent; color: var(--ink); }
dialog::backdrop { background: rgba(20,17,15,.56); backdrop-filter: blur(3px); }
.item-dialog { width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 30px); }
.dialog-shell, .form-dialog form { overflow: hidden; background: var(--surface); border-radius: 18px; box-shadow: 0 30px 100px rgba(0,0,0,.28); }
.dialog-head { padding: 19px 22px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--line); }
.dialog-head p { margin: 0 0 4px; }
.dialog-head h2 { margin: 0; font-family: "Songti SC", STSong, serif; font-size: 23px; }
.dialog-close { width: 36px; height: 36px; border: 0; border-radius: 8px; color: var(--muted); background: var(--paper); cursor: pointer; font-size: 22px; line-height: 1; }
.dialog-close:hover { color: var(--ink); }
.dialog-content { max-height: calc(100vh - 130px); overflow-y: auto; padding: 22px; }

.photo-section { display: grid; grid-template-columns: minmax(0,1fr) 210px; gap: 13px; align-items: stretch; }
.photo-gallery { min-height: 170px; display: flex; gap: 10px; overflow-x: auto; padding-bottom: 3px; }
.photo-card { position: relative; flex: 0 0 190px; height: 170px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.photo-open { width: 100%; height: 100%; border: 0; padding: 0; background: transparent; cursor: zoom-in; }
.photo-open img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .18s ease; }
.photo-open:hover img { transform: scale(1.025); }
.photo-open:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
.photo-card .photo-delete { position: absolute; top: 7px; right: 7px; width: 27px; height: 27px; border: 0; border-radius: 7px; color: #fff; background: rgba(0,0,0,.62); cursor: pointer; }
.photo-viewer { width: min(1180px, calc(100vw - 24px)); max-height: calc(100svh - 24px); }
.photo-viewer::backdrop { background: rgba(10,9,8,.86); backdrop-filter: blur(6px); }
.photo-viewer-shell { overflow: hidden; border-radius: 16px; background: #171412; box-shadow: 0 30px 100px rgba(0,0,0,.5); }
.photo-viewer-head { min-height: 62px; padding: 12px 14px 12px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.1); }
.photo-viewer-head div { min-width: 0; display: grid; gap: 3px; }
.photo-viewer-head strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.photo-viewer-head small { color: #aaa19b; font-size: 10px; }
.photo-viewer-head button { width: 38px; height: 38px; flex: 0 0 auto; border: 0; border-radius: 8px; color: #fff; background: rgba(255,255,255,.1); cursor: pointer; font-size: 24px; }
.photo-viewer-stage { height: calc(100svh - 110px); display: grid; place-items: center; padding: 12px; }
.photo-viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.photo-empty { width: 100%; min-height: 170px; display: grid; place-items: center; border: 1px dashed #d6cec7; border-radius: 12px; color: var(--muted); background: #fcfaf7; text-align: center; font-size: 12px; }
.upload-button { min-height: 170px; display: grid; place-content: center; gap: 7px; padding: 18px; text-align: center; color: var(--red); background: var(--red-wash); border: 1px dashed #e8afb5; border-radius: 12px; cursor: pointer; }
.upload-button:hover { background: #ffe9eb; }
.upload-button input { position: absolute; opacity: 0; pointer-events: none; }
.upload-button span { font-weight: 700; font-size: 13px; }
.upload-button small { color: #a66b71; font-size: 9px; line-height: 1.5; }
.upload-status { min-height: 16px; grid-column: 1 / -1; margin: -4px 0 0; color: var(--muted); font-size: 10px; }

.detail-tabs { margin: 18px 0; display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.detail-tabs button { min-height: 39px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.detail-tabs button.active { color: var(--ink); border-bottom-color: var(--red); font-weight: 700; }
.detail-pane { display: none; }
.detail-pane.active { display: block; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-grid label { display: grid; gap: 6px; }
.form-grid label > span { color: var(--ink-soft); font-size: 11px; }
.form-grid label.wide { grid-column: 1 / -1; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); outline: none; }
input, select { height: 40px; padding: 0 11px; }
textarea { padding: 10px 11px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: #aaa098; box-shadow: 0 0 0 3px rgba(29,26,24,.045); }
input:disabled { color: #aaa; background: #f2efeb; }
.weight-callout { margin-top: 16px; padding: 12px 14px; color: var(--ink-soft); background: var(--paper); border-left: 3px solid var(--gold); border-radius: 7px; font-size: 11px; line-height: 1.6; }
.weight-callout strong { color: var(--ink); }
.form-error { min-height: 18px; margin: 10px 0 0; color: var(--red); font-size: 11px; }
.form-actions { margin-top: 4px; display: flex; justify-content: flex-end; gap: 9px; }

.movement-type { margin-bottom: 15px; display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.movement-type label input { position: absolute; opacity: 0; }
.movement-type label span { min-height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 11px; }
.movement-type label input:checked + span { color: #fff; border-color: var(--ink); background: var(--ink); }
.item-history { display: grid; gap: 9px; }
.history-row { display: grid; grid-template-columns: 90px 70px 1fr auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 11px; }
.history-row time, .history-row small { color: var(--muted); }
.history-row strong { font-size: 12px; }

.form-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 30px); }
.form-dialog form { max-height: calc(100vh - 30px); overflow-y: auto; padding-bottom: 22px; }
.form-dialog .form-grid, .form-dialog .form-error, .form-dialog .form-actions { margin-left: 22px; margin-right: 22px; }
.form-dialog .form-grid { padding-top: 20px; }
.form-dialog .form-actions { margin-top: 0; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; max-width: min(430px, calc(100vw - 32px)); transform: translate(-50%, 20px); padding: 11px 16px; color: #fff; background: var(--ink); border-radius: 9px; box-shadow: 0 12px 35px rgba(0,0,0,.25); font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red-dark); }
.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 (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-brand-panel { min-height: 260px; padding: 28px 24px; }
  .auth-statement { margin: auto 0 0; }
  .auth-statement h1 { font-size: 34px; }
  .auth-statement span, .auth-footnote { display: none; }
  .auth-form-panel { min-height: calc(100svh - 260px); padding: 34px 24px 48px; align-items: start; }
  .auth-form h2 { font-size: 30px; }
  .app-shell { display: block; }
  .sidebar { position: sticky; top: 0; width: 100%; height: auto; padding: 11px 14px; flex-direction: row; align-items: center; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
  .brand-lockup { padding: 0; margin-right: auto; }
  .brand-stamp { width: 34px; height: 34px; font-size: 19px; }
  .brand-lockup strong { font-size: 13px; }
  .brand-lockup small, .sidebar-note { display: none; }
  .side-nav { display: flex; gap: 2px; }
  .nav-item { width: 42px; height: 38px; justify-content: center; padding: 0; font-size: 0; }
  .nav-item span { font-size: 9px; }
  .mobile-logout { display: flex; }
  .workspace { padding: 22px 14px 48px; }
  .topbar { min-height: 0; margin-bottom: 20px; align-items: center; }
  .topbar h1 { font-size: 27px; }
  .top-actions time { display: none; }
  .user-session { display: none; }
  .top-actions .button { padding: 0 12px; }
  .scope-banner { align-items: flex-start; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 126px; padding: 18px; }
  .metric-card strong { font-size: 23px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-field { flex-basis: auto; max-width: none; }
  .filter-group { overflow-x: auto; flex-wrap: nowrap; }
  .filter { flex: 0 0 auto; }
  .backup-layout { grid-template-columns: 1fr; padding: 27px 20px; }
  .backup-copy h2 { font-size: 32px; }
  .photo-section { grid-template-columns: 1fr; }
  .upload-button { min-height: 90px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.wide { grid-column: auto; }
  .movement-type { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .brand-lockup > span:last-child { display: none; }
  .scope-banner { display: block; line-height: 1.6; }
  .scope-banner button { margin-top: 7px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 112px; }
  .dashboard-grid { display: block; }
  .quality-panel { margin-bottom: 13px; }
  .item-dialog, .form-dialog { width: 100vw; max-height: 100vh; }
  .dialog-shell, .form-dialog form { min-height: 100vh; border-radius: 0; }
  .dialog-content, .form-dialog .form-grid { max-height: none; }
}

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