:root {
  --bg: #faf6f1;
  --card: #ffffff;
  --ink: #0b0d12;
  --ink-soft: #1f2937;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --border: #ece6dc;
  --border-soft: #f1ece3;
  --accent: #059669;
  --accent-2: #10b981;
  --accent-grad: linear-gradient(135deg, #34d399 0%, #059669 60%, #047857 100%);
  --success: #10b981;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #f59e0b;
  --warn-soft: #fffbeb;
  --shadow-xs: 0 1px 2px rgba(11,13,18,.04);
  --shadow-sm: 0 1px 3px rgba(11,13,18,.06), 0 1px 2px rgba(11,13,18,.04);
  --shadow-md: 0 4px 12px rgba(11,13,18,.06);
  --shadow-lg: 0 24px 50px rgba(11,13,18,.12), 0 10px 18px rgba(11,13,18,.06);
  --r: 14px;
  --r-lg: 20px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.view { display: none; }
.view.active { display: block; }

/* ---------- LOGIN ---------- */
#loginView {
  min-height: 100vh; min-height: 100dvh;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(800px 400px at 80% -10%, rgba(56,189,248,.18), transparent 60%),
    radial-gradient(700px 500px at -10% 100%, rgba(14,165,233,.14), transparent 60%),
    var(--bg);
}
#loginView.active { display: flex; }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--card);
  padding: 36px 30px 30px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.login-card .logo {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--accent-grad);
  color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 8px 20px rgba(5,150,105,.35);
}
.login-card .logo svg { width: 24px; height: 24px; }
.login-card h1 {
  margin: 0; font-size: 26px; text-align: center;
  letter-spacing: -.02em; font-weight: 800;
}
.login-card .sub { margin: 6px 0 24px; color: var(--muted); font-size: 14px; text-align: center; }
.login-card label {
  display: block; font-size: 12px; color: var(--muted);
  margin-top: 14px; font-weight: 600;
}
.login-card input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 12px;
  margin-top: 6px; font-size: 15px; background: #fff;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(11,13,18,.08);
}
.login-card button {
  width: 100%; margin-top: 22px; padding: 13px;
  background: var(--ink); color: #fff; border: none; border-radius: 12px;
  font-weight: 700; cursor: pointer; font-size: 15px;
  transition: transform .1s, background .15s;
  font-family: inherit;
}
.login-card button:hover { background: #000; }
.login-card button:active { transform: scale(.98); }
.login-card .hint { font-size: 12px; color: var(--muted); margin-top: 16px; text-align: center; }
.login-card .hint code {
  background: #f3efe7; padding: 2px 6px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.login-card .err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 0; text-align: center; }

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 5;
}
.brand {
  display: flex; align-items: center; gap: 10px;
}
.logo-box {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(5,150,105,.3);
}
.brand-name {
  font-size: 18px; font-weight: 800; letter-spacing: -.01em;
  color: var(--ink);
}

.navtabs { display: flex; gap: 4px; }
.navtab {
  background: transparent; border: none; cursor: pointer;
  padding: 8px 14px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 14px;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.navtab:hover { background: #f3efe7; color: var(--ink); }
.navtab.active { background: var(--ink); color: #fff; }

.who { margin-left: auto; }
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-xs);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-grad);
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  text-transform: uppercase;
}
.user-meta { line-height: 1.15; }
.user-name { font-size: 13px; font-weight: 700; color: var(--ink); }
.user-role { font-size: 11px; color: var(--muted); text-transform: capitalize; }
button.ghost {
  background: transparent; border: none; cursor: pointer;
  width: 28px; height: 28px; border-radius: 8px;
  color: var(--muted); font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
button.ghost:hover { background: #f3efe7; color: var(--ink); }

.pane { display: none; }
.pane.active { display: block; }

/* ---------- CONTAINER + HERO ---------- */
.container {
  max-width: 1100px; margin: 0 auto;
  padding: 28px 28px 100px;
}
.hero { margin-bottom: 28px; }
.eyebrow {
  font-size: 12px; font-weight: 700; color: var(--muted);
  letter-spacing: .12em;
}
.hero-title {
  margin: 6px 0 8px;
  font-size: clamp(38px, 6vw, 56px);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.05;
  color: var(--ink);
}
.dot-accent { color: var(--accent); }
.hero-sub {
  margin: 0; color: var(--muted); font-size: 15px;
  max-width: 600px;
}

/* ---------- STAT CARDS ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, transform .15s;
}
.stat-card .label {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em;
  display: flex; align-items: center; gap: 8px;
}
.stat-card .label .ic { font-size: 14px; }
.stat-card .num {
  font-size: 30px; font-weight: 800; margin-top: 8px;
  letter-spacing: -.02em; color: var(--ink);
}
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-card.accent-green .ic { color: var(--success); }
.stat-card.accent-blue .ic { color: var(--accent); }
.stat-card.accent-amber .ic { color: var(--warn); }
.stat-card.accent-red .ic { color: var(--danger); }

/* ---------- FORM ---------- */
.form-grid { display: grid; gap: 16px; }
.fs {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 22px 22px;
  box-shadow: var(--shadow-xs);
}
.fs legend {
  /* Float removes the legend from its native "on the border" position
     and makes it flow as a card header inside the box. */
  float: left;
  width: 100%;
  margin: 0 0 14px 0;
  padding: 0 0 12px 0;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  letter-spacing: -.005em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.fs legend + * { clear: both; }
.fs legend .legend-sub {
  font-weight: 500; color: var(--muted); font-size: 13px;
}
.fs legend button.add {
  margin-left: auto;
  padding: 5px 12px; font-size: 12px;
  background: var(--ink); color: #fff; border: none; border-radius: 999px;
  cursor: pointer; font-weight: 600; font-family: inherit;
}
.fs legend button.add:hover { background: #000; }
.row {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 6px;
}
.row label { font-size: 12px; color: var(--muted); display: block; font-weight: 600; }
.row label.full { grid-column: 1 / -1; }
.row input, .row textarea, .row select {
  width: 100%; padding: 12px 14px;
  font-size: 15px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 12px;
  margin-top: 6px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.row input:focus, .row textarea:focus, .row select:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(11,13,18,.06);
}
.row input[disabled] {
  background: #faf6f1; color: var(--ink); font-weight: 700;
  border-color: var(--border); cursor: not-allowed;
}

/* ---------- DUAL PHOTO PICKER ---------- */
.photo-picker {
  margin-top: 6px;
  display: block;
}
.photo-picker .pp-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.photo-picker .pp-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  min-height: 48px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, border-color .15s;
}
.photo-picker .pp-btn:hover { background: #faf6f1; border-color: var(--ink); }
.photo-picker .pp-btn:active { transform: scale(.98); }
.photo-picker .pp-cam {
  background: #eef9ff; border-color: #bae6fd; color: #0369a1;
}
.photo-picker .pp-cam:hover { background: #dbf2ff; }
.photo-picker .pp-lib {
  background: #fff;
}
.photo-picker .pp-single {
  background: #eef9ff; border-color: #bae6fd; color: #0369a1;
  grid-column: 1 / -1;
}
.photo-picker .pp-single:hover { background: #dbf2ff; }
.photo-picker .pp-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.photo-picker .pp-thumbs:empty { display: none; }
.pp-thumb {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
}
.pp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pp-rm {
  position: absolute; top: 2px; right: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(11,13,18,.75);
  color: #fff;
  border: none; cursor: pointer;
  font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.pp-rm:hover { background: var(--danger); }

/* AI verification banner */
.verify-result {
  margin-top: 10px; padding: 10px 12px;
  border-radius: 10px; font-size: 13px; font-weight: 600;
  line-height: 1.4; display: none;
}
.verify-result:not(:empty) { display: block; }
.verify-result small {
  display: block; font-weight: 400; opacity: .85; margin-top: 3px;
}
.verify-result.loading {
  background: #eef9ff; color: #0369a1; border: 1px solid #bae6fd;
  display: flex; align-items: center; gap: 8px;
}
.vr-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #0ea5e9;
  animation: vrpulse 1s ease-in-out infinite;
}
@keyframes vrpulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }
.verify-result.ok {
  background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0;
}
.verify-result.bad {
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
}
.verify-result.warn {
  background: #fffbeb; color: #92400e; border: 1px solid #fde68a;
}
.vr-use {
  margin-left: 8px; padding: 4px 10px;
  background: var(--ink); color: #fff; border: none; border-radius: 999px;
  font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.vr-use:hover { background: #000; }

@media (max-width: 720px) {
  .photo-picker .pp-btn { font-size: 15px; min-height: 52px; padding: 14px 8px; }
}

/* file inputs */
.filelbl .filebox { display: block; position: relative; margin-top: 6px; }
.filelbl input[type="file"] {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer;
}
.filelbl .fileui {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #faf6f1;
  color: var(--muted); font-weight: 600; font-size: 14px;
  min-height: 46px;
  transition: border-color .15s, background .15s, color .15s;
}
.filelbl .fileui:hover { border-color: var(--ink); color: var(--ink); }
.filelbl .fileui.has-file {
  background: var(--success-soft); border-color: #a7f3d0;
  border-style: solid; color: var(--success);
}

/* dynamic items */
.dynlist { display: grid; gap: 10px; margin-top: 10px; }
.dynitem {
  display: grid; gap: 12px;
  grid-template-columns: 1.6fr 1.4fr 1.4fr auto;
  align-items: end;
  padding: 14px;
  background: #faf6f1;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.dynitem > label {
  display: block;
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.dynitem > label > input[type="text"],
.dynitem > label > input[type="number"] {
  width: 100%;
  display: block;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  border: 1px solid var(--border); border-radius: 12px;
  margin-top: 6px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.dynitem > label > input:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(11,13,18,.06);
}
.dynitem .filebox { position: relative; display: block; margin-top: 6px; }
.dynitem input[type="file"] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }
.dynitem .fileui {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px; border: 1px dashed var(--border);
  border-radius: 10px; background: #fff;
  color: var(--muted); font-weight: 600; font-size: 13px; min-height: 44px;
}
.dynitem .fileui.has-file { background: var(--success-soft); border-color: #a7f3d0; border-style: solid; color: var(--success); }
.dynitem button.rm {
  height: 44px; padding: 0 16px;
  background: #fff; color: var(--danger);
  border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer;
  font-weight: 600; font-family: inherit; font-size: 13px;
}
.dynitem button.rm:hover { background: var(--danger-soft); border-color: #fecaca; }

.emptyhint {
  color: var(--muted); font-size: 13px; margin: 12px 2px 0;
  text-align: center; padding: 16px;
  border: 1px dashed var(--border); border-radius: 12px;
  background: #faf6f1;
}
.emptyhint.hidden { display: none; }

.actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 12px;
  position: sticky; bottom: 14px;
  background: rgba(250,246,241,.85);
  backdrop-filter: blur(10px);
  padding: 12px; border-radius: 16px;
  border: 1px solid var(--border);
}
button.primary {
  background: var(--ink); color: #fff; border: none;
  padding: 12px 22px; border-radius: 12px;
  font-weight: 700; cursor: pointer; font-size: 15px;
  font-family: inherit;
  transition: transform .1s, background .15s;
}
button.primary:hover { background: #000; }
button.primary:active { transform: scale(.98); }
button.ghost-dark {
  background: #fff; color: var(--ink);
  border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 12px;
  font-weight: 600; cursor: pointer; font-size: 15px;
  font-family: inherit;
}
button.ghost-dark:hover { background: #faf6f1; }

/* ---------- MODALS ---------- */
.modal-bg {
  display: none; position: fixed; inset: 0;
  background: rgba(11,13,18,.5);
  align-items: center; justify-content: center; z-index: 999;
  padding: 18px;
  backdrop-filter: blur(6px);
}
.modal-bg.show { display: flex; }
.modal {
  background: #fff; padding: 26px;
  border-radius: 18px; width: 100%; max-width: 440px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.modal.wide { max-width: 480px; text-align: center; }
.modal h3 { margin-top: 0; font-size: 18px; letter-spacing: -.01em; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin-top: 12px; font-weight: 600; }
.modal input, .modal select {
  width: 100%; padding: 12px 14px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 12px; margin-top: 6px;
  background: #fff;
}
.modal input:focus, .modal select:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(11,13,18,.06);
}
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px;
  flex-wrap: wrap;
}
.modal-actions.center { justify-content: center; }
.checkmark {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--success); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 800;
  margin: 4px auto 12px;
  box-shadow: 0 12px 28px rgba(16,185,129,.35);
}
.ty { color: var(--ink); font-size: 26px; margin: 4px 0 6px; letter-spacing: -.01em; }

/* ---------- SECTION HEAD ---------- */
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.section-title {
  margin: 0; font-size: 22px; font-weight: 800;
  letter-spacing: -.02em; color: var(--ink);
}
.section-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.back-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: 14px;
  font-family: inherit; padding: 6px 0;
}
.back-btn:hover { color: var(--ink); }

/* ---------- STORE CARDS ---------- */
.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.loading-msg {
  grid-column: 1 / -1;
  text-align: center; padding: 36px; color: var(--muted);
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.store-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color .15s, transform .12s, box-shadow .15s;
  box-shadow: var(--shadow-xs);
  position: relative;
}
.store-card:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.store-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.store-name {
  font-size: 18px; font-weight: 700; letter-spacing: -.01em;
  color: var(--ink);
}
.store-chev { color: var(--muted-2); font-size: 18px; }
.store-meta {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-top: 12px;
}
.store-meta .cell {
  background: #faf6f1; border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 8px 12px;
}
.store-meta .cell .k {
  font-size: 10px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
}
.store-meta .cell .v {
  font-size: 16px; font-weight: 700; margin-top: 2px;
  letter-spacing: -.01em;
}
.store-last {
  font-size: 12px; color: var(--muted);
  margin-top: 12px;
  display: flex; align-items: center; gap: 6px;
}
.store-card .badge { margin-left: 8px; }

@media (max-width: 720px) {
  .store-grid { grid-template-columns: 1fr; }
}

/* ---------- REPORTS LIST ---------- */
.reports-toolbar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
  align-items: center;
}
.reports-toolbar input,
.reports-toolbar select {
  padding: 11px 14px; border: 1px solid var(--border);
  border-radius: 12px; font-size: 14px; background: #fff;
  font-family: inherit; color: var(--ink);
}
.reports-toolbar input { flex: 1; min-width: 220px; }
.reports-toolbar input:focus, .reports-toolbar select:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(11,13,18,.06);
}

.reports-table-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.reports-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.reports-table th, .reports-table td {
  text-align: left; padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.reports-table th {
  background: #faf6f1;
  font-weight: 700; color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
}
.reports-table tbody tr {
  cursor: pointer; transition: background .12s;
}
.reports-table tbody tr:hover { background: #faf6f1; }
.reports-table tbody tr:last-child td { border-bottom: none; }
.reports-table .empty { text-align: center; padding: 36px; color: var(--muted); }
.muted-ts { color: var(--muted); font-size: 13px; }
.muted-note { color: var(--muted); font-size: 13px; font-weight: 600; align-self: center; }

.badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: capitalize;
  border: 1px solid transparent;
}
.badge.pending { background: var(--warn-soft); color: #92400e; border-color: #fde68a; }
.badge.finalized { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }
.badge.short { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.badge.excess { background: var(--warn-soft); color: #854d0e; border-color: #fde68a; }

/* ---------- DETAIL SHEET ---------- */
.modal.sheet {
  max-width: 760px; width: 100%;
  max-height: 90vh; max-height: 90dvh;
  display: flex; flex-direction: column; padding: 0;
  border-radius: 22px;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-soft);
  background: #fff;
  border-radius: 22px 22px 0 0;
}
.sheet-head h3 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.sheet-body { padding: 22px 24px 26px; overflow-y: auto; }

.rd-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 14px;
}
.rd-cell {
  background: #faf6f1;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
}
.rd-cell .k {
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .08em; font-weight: 700;
}
.rd-cell .v { font-size: 16px; font-weight: 700; margin-top: 4px; letter-spacing: -.005em; }
.rd-section { margin-top: 18px; }
.rd-section h4 {
  margin: 0 0 10px; font-size: 13px;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700;
}
.rd-list { display: grid; gap: 8px; }
.rd-item {
  display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 12px;
  align-items: center; background: #faf6f1;
  border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 12px;
}
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs img {
  width: 46px; height: 46px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); cursor: zoom-in;
}
.edit-banner {
  background: #fffbeb; border: 1px solid #fde68a;
  color: #92400e; padding: 12px 16px; border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 0 0 16px; flex-wrap: wrap;
}
.rd-item img {
  width: 50px; height: 50px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--border); cursor: zoom-in;
}
.rd-photo-large {
  width: 100px; height: 100px; object-fit: cover; border-radius: 12px;
  border: 1px solid var(--border); cursor: zoom-in;
}
.rd-photos { display: flex; gap: 12px; flex-wrap: wrap; }
.rd-photo-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted); font-weight: 600;
}
.rd-sheet-mount {
  background: #f3efe7;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  overflow-x: auto;
  display: flex;
  justify-content: center;
}
.rd-sheet-mount > #reportSheet {
  position: static; left: auto; top: auto;
  box-shadow: 0 6px 16px rgba(11,13,18,.1);
}
@media (max-width: 720px) {
  .rd-sheet-mount > #reportSheet {
    transform-origin: top left;
    transform: scale(.45);
    width: 780px;
    margin-bottom: -380px;
  }
}

/* Cashpoint sync status */
.cp-status {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 600; flex-wrap: wrap;
}
.cp-status.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.cp-status.bad { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.cp-status.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* Edit history list */
.edits-list { display: grid; gap: 10px; }
.edit-entry {
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 12px; padding: 12px 14px;
}
.edit-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--ink);
}
.edit-head .badge.admin { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.edit-head .badge.staff { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.edit-head .badge.employee { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.edit-ts { color: var(--muted); font-size: 12px; margin-left: auto; }
.edit-reason {
  margin: 6px 0 8px; font-style: italic; color: #92400e;
  font-size: 14px;
}
.edit-changes { display: grid; gap: 4px; }
.diff-row {
  display: grid; grid-template-columns: 1fr 1fr auto 1fr;
  gap: 8px; font-size: 12px; padding: 4px 8px;
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
}
.diff-k { font-weight: 700; color: var(--ink); }
.diff-from { color: #b91c1c; text-decoration: line-through; }
.diff-arrow { color: var(--muted); }
.diff-to { color: #065f46; font-weight: 600; }

.rd-finalize {
  margin-top: 20px; padding: 16px;
  background: #faf6f1;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.rd-finalize textarea {
  width: 100%; padding: 11px; border: 1px solid var(--border);
  border-radius: 10px; font-family: inherit; font-size: 14px;
  margin-top: 6px; background: #fff;
}
.rd-finalize .actions-row {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px;
  flex-wrap: wrap;
}
.rd-finalized-banner {
  margin-top: 20px; padding: 14px 16px;
  background: var(--success-soft);
  border: 1px solid #a7f3d0;
  border-radius: 14px; color: #065f46;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}

/* ---------- THANK-YOU PREVIEW MODAL ---------- */
.preview-modal { max-width: 880px; }
.ty-head { display: flex; align-items: center; gap: 14px; }
.modal-lead { margin: 4px 0 14px; color: var(--muted); font-size: 14px; }

/* Edit reason modal — polished look */
.edit-reason-modal { text-align: center; padding: 28px 26px; }
.edit-reason-modal h3 {
  margin: 6px 0 4px; font-size: 19px;
  letter-spacing: -.01em;
}
.edit-reason-modal .modal-lead {
  text-align: center; margin: 0 0 18px;
}
.edit-reason-modal .er-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  font-size: 22px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 8px;
  box-shadow: 0 6px 14px rgba(245, 158, 11, .25);
}
.edit-reason-modal textarea {
  width: 100%; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 12px;
  font-family: inherit; font-size: 15px; line-height: 1.45;
  background: #faf6f1;
  resize: vertical; min-height: 92px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.edit-reason-modal textarea:focus {
  outline: none; border-color: var(--ink); background: #fff;
  box-shadow: 0 0 0 3px rgba(11,13,18,.06);
}
.edit-reason-modal .er-counter {
  text-align: right; font-size: 11px; color: var(--muted);
  margin-top: 4px; font-weight: 600; letter-spacing: .02em;
}
.edit-reason-modal .modal-actions { justify-content: center; margin-top: 18px; }
.edit-reason-modal .modal-actions button { min-width: 130px; }
.choice-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin: 10px 0 14px;
}
.choice-card {
  background: #fff; border: 1.5px solid var(--border);
  border-radius: 14px; padding: 16px 12px;
  cursor: pointer; text-align: center;
  font-family: inherit; transition: border-color .15s, background .15s, transform .1s;
}
.choice-card:hover { border-color: var(--ink); background: #faf6f1; }
.choice-card.active {
  border-color: var(--ink); background: var(--ink); color: #fff;
}
.choice-card.active .cc-sub { color: rgba(255,255,255,.7); }
.cc-emoji { font-size: 24px; }
.cc-title { font-size: 14px; font-weight: 700; margin-top: 6px; letter-spacing: -.005em; }
.cc-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
button.primary:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 480px) {
  .choice-grid { grid-template-columns: 1fr; }
}

.checkmark-sm {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--success); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(16,185,129,.35);
}
.ty-sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.preview-body { background: #f3efe7; padding: 20px; }
#reportPreviewBox {
  display: flex; justify-content: center;
}
#reportPreviewBox > #reportSheet {
  position: static; left: auto; top: auto;
  box-shadow: 0 8px 20px rgba(11,13,18,.12);
  border-radius: 4px;
}
.sheet-foot {
  padding: 14px 24px;
  border-top: 1px solid var(--border-soft);
  display: flex; justify-content: flex-end;
  background: #fff; border-radius: 0 0 22px 22px;
}

@media (max-width: 720px) {
  .preview-body { padding: 12px; overflow-x: auto; }
  #reportPreviewBox > #reportSheet {
    transform-origin: top left;
    transform: scale(.5);
    width: 780px; /* keep intrinsic size for transform */
    margin-bottom: -340px; /* compensate scaled height */
  }
  .ty-head h3 { font-size: 16px; }
  .ty-sub { display: none; }
}

/* ---------- REPORT SHEET (hidden by default, shown when moved into preview) ---------- */
#reportSheetWrap { position: absolute; left: -10000px; top: 0; }
#reportSheet {
  width: 780px; padding: 18px; background: #fff; color: #000;
  font-family: Arial, sans-serif; font-size: 11px;
}
.rs-top { display: grid; grid-template-columns: 1fr 1fr 1fr; border: 1px solid #000; }
.rs-top > div { padding: 6px 8px; border-right: 1px solid #000; }
.rs-top > div:last-child { border-right: none; }
.rs-row { display: flex; gap: 6px; padding: 2px 0; }
.rs-row .lbl { font-weight: 600; min-width: 90px; }
.rs-row .val { flex: 1; border-bottom: 1px dotted #555; min-height: 14px; }
.rs-grid3 { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr; margin-top: 8px; }
.rs-grid3 > .rs-tbl { border-right: none; }
.rs-grid3 > .rs-tbl:last-child { border-right: 1px solid #000; }
.rs-tbl { width: 100%; border-collapse: collapse; border: 1px solid #000; }
.rs-tbl th, .rs-tbl td {
  border: 1px solid #000; padding: 4px 6px; text-align: left;
  vertical-align: top; height: 18px;
}
.rs-tbl th { background: #f0f0f0; text-align: center; font-weight: 700; }
.rs-tbl .sub-h { text-align: center; font-weight: 700; background: #f7f7f7; }
.rs-mainsplit { display: grid; grid-template-columns: 1fr 1.25fr; margin-top: 8px; }
.rs-mainsplit > .rs-tbl:first-child { border-right: none; }
.rs-summary td { font-weight: 500; }
.rs-summary td:last-child { text-align: right; min-width: 110px; padding-right: 8px; }
.rs-expenses { margin-top: 8px; }
.rs-expenses td:first-child { width: 36px; text-align: center; }
.rs-expenses td:last-child { width: 110px; text-align: right; }
.rs-expenses-full { width: 100%; }
.remarks { min-height: 30px; }

/* ---------- MOBILE ---------- */
@media (max-width: 720px) {
  .topbar {
    padding: 12px 16px; gap: 10px;
    flex-wrap: wrap;
  }
  .navtabs { order: 3; width: 100%; }
  .navtab { flex: 1; padding: 10px; font-size: 13px; }
  .user-pill { padding: 3px 8px 3px 3px; }
  .user-meta { display: none; }
  .avatar { width: 30px; height: 30px; font-size: 13px; }

  .container { padding: 20px 16px 110px; }
  .hero-title { font-size: 36px; }
  .hero-sub { font-size: 14px; }

  .fs { padding: 16px; border-radius: 16px; }
  .fs legend { font-size: 13px; }
  .row { grid-template-columns: 1fr; gap: 10px; }
  .dynitem { grid-template-columns: 1fr; gap: 14px; padding: 16px; }
  .dynitem > label { font-size: 13px; }
  .dynitem > label > input[type="text"],
  .dynitem > label > input[type="number"] {
    font-size: 16px; padding: 14px 14px; min-height: 50px;
  }
  .dynitem .fileui { padding: 14px; min-height: 52px; font-size: 14px; }
  .dynitem button.rm { width: 100%; height: 50px; font-size: 15px; }
  .row input, .row textarea, .row select { font-size: 16px; }
  .modal { padding: 22px; }
  .actions { gap: 8px; padding: 10px; bottom: 10px; }
  button.primary, button.ghost-dark { flex: 1; }

  .reports-table { font-size: 13px; }
  .reports-table th, .reports-table td { padding: 11px 12px; }
  .rd-item { grid-template-columns: 1fr; }
  .rd-photo-large { width: 100%; max-width: 220px; height: auto; }
}

@media (max-width: 380px) {
  .container { padding: 16px 12px 110px; }
}
