:root {
  --ink: #19222c;
  --muted: #66717d;
  --line: #dfe5e8;
  --soft: #f4f6f5;
  --surface: #ffffff;
  --accent: #ffd84d;
  --accent-strong: #f4b400;
  --accent-dark: #795800;
  --warning: #f2c567;
  --danger: #e67878;
  --info: #7eb7d9;
  --success: #52b788;
  --shadow: 0 18px 50px rgba(25, 34, 44, 0.10);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--soft); }
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; background: linear-gradient(to right, var(--ink) 260px, transparent 260px); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 20px 20px;
  background: var(--ink);
  color: #fff;
  z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 20px; letter-spacing: -0.5px; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px;
  background: var(--accent); color: var(--ink); font-weight: 900;
  transform: rotate(-5deg);
}
.brand-mark span { transform: rotate(5deg); }
.nav { display: grid; gap: 7px; margin-top: 42px; }
.nav-item {
  width: 100%; border: 0; border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 12px;
  background: transparent; color: #bfc8cf; cursor: pointer; text-align: left; font-weight: 650;
}
.nav-item span { width: 20px; text-align: center; font-size: 18px; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.09); color: #fff; }
.sidebar-card { margin-top: auto; padding: 17px; border: 1px solid rgba(255,255,255,.10); border-radius: 15px; background: rgba(255,255,255,.055); }
.sidebar-card-icon { margin-bottom: 8px; color: var(--accent); }
.sidebar-card p { margin: 6px 0 0; color: #bfc8cf; font-size: 12px; line-height: 1.55; }
.sidebar-footer {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 11px;
  width: 100%;
}
.sidebar-footer .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--ink);
  font-weight: 800;
  font-size: 12px;
}
.sidebar-user {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sidebar-user strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.25;
}
.sidebar-user span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #aeb9c1;
  font-size: 11px;
  line-height: 1.25;
}

.main { min-width: 0; }
.topbar {
  min-height: 98px; padding: 24px 38px; display: flex; align-items: center; gap: 18px; justify-content: space-between;
  background: rgba(244,246,245,.92); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; border-bottom: 1px solid rgba(223,229,232,.75);
}
.topbar h1 { margin: 2px 0 0; font-size: 25px; letter-spacing: -.7px; }
.eyebrow { margin: 0; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: 1.8px; }
.topbar-actions { display: flex; gap: 10px; }
.mobile-menu { display: none !important; }
.content { padding: 30px 38px 50px; max-width: 1380px; margin: 0 auto; }

.button {
  border: 0; border-radius: 11px; min-height: 42px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; font-weight: 750; transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--ink); color: #fff; box-shadow: 0 8px 22px rgba(25,34,44,.16); }
.button-primary:hover { background: #273541; }
.button-ghost { background: #fff; border: 1px solid var(--line); }
.button-light { background: #fff; color: var(--ink); }
.button-small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.text-button { border: 0; background: transparent; color: var(--accent-dark); cursor: pointer; font-weight: 750; }
.icon-button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; display: grid; place-items: center; font-size: 20px; }

.hero-card {
  min-height: 245px; border-radius: 24px; padding: 34px 38px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  background: radial-gradient(circle at 86% 24%, rgba(255,216,77,.42), transparent 25%), linear-gradient(130deg, #1b2631, #243842);
  color: #fff; box-shadow: var(--shadow); overflow: hidden; position: relative;
}
.hero-card::after { content: "✓"; position: absolute; right: 70px; top: -58px; font-size: 250px; font-weight: 900; color: rgba(255,216,77,.08); transform: rotate(-8deg); }
.hero-card > * { position: relative; z-index: 1; }
.hero-card h2 { max-width: 680px; margin: 15px 0 8px; font-size: clamp(32px, 4.4vw, 60px); line-height: .98; letter-spacing: -2.4px; }
.hero-card p:not(.eyebrow) { max-width: 620px; margin: 0; color: #cbd4da; font-size: 16px; line-height: 1.55; }
.pill { display: inline-flex; border-radius: 100px; padding: 7px 10px; font-size: 9px; font-weight: 900; letter-spacing: 1.2px; }
.pill-light { background: var(--accent); color: var(--ink); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.stat-card { padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-dot { width: 9px; height: 9px; border-radius: 50%; }
.stat-value { margin: 15px 0 2px; font-size: 34px; font-weight: 850; letter-spacing: -1.4px; }
.stat-card small { color: var(--muted); }
.dot-awaiting { background: var(--info); }
.dot-changes { background: var(--warning); }
.dot-approved { background: var(--success); }
.dot-overdue { background: var(--danger); }

.section-heading { margin: 34px 2px 15px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-heading h2, .panel-heading h2 { margin: 4px 0 0; font-size: 23px; letter-spacing: -.6px; }
.request-list { display: grid; gap: 10px; }
.request-card {
  display: grid; grid-template-columns: minmax(240px, 1.4fr) minmax(150px, .7fr) minmax(140px, .65fr) minmax(125px, .55fr) 36px;
  gap: 18px; align-items: center; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: 15px; cursor: pointer;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.request-card:hover { border-color: #b9c7cc; transform: translateY(-1px); box-shadow: 0 8px 25px rgba(25,34,44,.06); }
.request-main { display: flex; align-items: center; gap: 13px; min-width: 0; }
.file-icon { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; background: var(--soft); font-weight: 850; font-size: 11px; }
.request-main div:last-child { min-width: 0; }
.request-main strong, .request-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.request-main span, .request-meta span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { width: max-content; display: inline-flex; align-items: center; gap: 7px; border-radius: 100px; padding: 7px 10px; font-size: 11px; font-weight: 850; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-awaiting { background: #eaf4fa; color: #326d90; }
.status-changes { background: #fff4d9; color: #9a6814; }
.status-approved { background: #e2f8ee; color: #24724f; }
.status-rejected { background: #fdeaea; color: #a94646; }
.status-overdue { background: #fdeaea; color: #a94646; }
.card-arrow { color: #8d989f; font-size: 22px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 18px; }
.search-field { flex: 1; max-width: 520px; min-height: 45px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--line); background: #fff; border-radius: 12px; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; }
.select-field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.select-field select { min-height: 45px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 0 34px 0 12px; color: var(--ink); }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.panel-heading { padding: 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.panel-heading.compact { padding: 16px 18px; }
.panel-heading.compact h2 { font-size: 17px; }
.timeline { padding: 6px 22px 24px; }
.timeline-item { position: relative; display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.timeline-item:last-child { border-bottom: 0; }
.timeline-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; background: var(--soft); font-size: 12px; z-index: 1; }
.timeline-item p { margin: 0; line-height: 1.45; font-size: 14px; }
.timeline-item small { color: var(--muted); white-space: nowrap; }
.empty-state { padding: 58px 24px; text-align: center; background: #fff; border: 1px dashed #bec8cd; border-radius: var(--radius); }
.empty-state .empty-icon { width: 50px; height: 50px; margin: 0 auto 15px; display: grid; place-items: center; border-radius: 50%; background: var(--soft); font-size: 22px; }
.empty-state h1, .empty-state h3 { margin: 0 0 8px; }
.empty-state p { max-width: 480px; margin: 0 auto 22px; color: var(--muted); line-height: 1.5; }

.modal { border: 0; padding: 0; background: transparent; width: min(760px, calc(100% - 28px)); max-height: calc(100vh - 32px); }
.modal::backdrop { background: rgba(18,25,32,.64); backdrop-filter: blur(4px); }
.modal-card { max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: 22px; padding: 24px; box-shadow: 0 25px 80px rgba(0,0,0,.24); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.modal-header h2 { margin: 4px 0 0; font-size: 26px; letter-spacing: -.8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 8px; }
.field > span:first-child { font-size: 12px; font-weight: 800; }
.field em { color: #bb4949; font-style: normal; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 11px; padding: 12px 13px; outline: 0; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: #b88600; box-shadow: 0 0 0 3px rgba(244,180,0,.18); }
.field-span-2 { grid-column: span 2; }
.dropzone { position: relative; min-height: 145px; border: 1.5px dashed #b6c1c6; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; cursor: pointer; background: var(--soft); text-align: center; }
.dropzone:hover, .dropzone.dragging { border-color: var(--accent-dark); background: #fff9df; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-icon { font-size: 27px; color: var(--accent-dark); }
.dropzone small { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.modal-actions.centered { justify-content: center; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 12px 16px; border-radius: 11px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; box-shadow: var(--shadow); transition: .22s ease; z-index: 80; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.detail-card { width: min(100%, 760px); }
.detail-overview { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; }
.detail-preview { min-height: 330px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: grid; place-items: center; background: #eef1f1; }
.detail-preview img, .detail-preview iframe { width: 100%; height: 100%; max-height: 480px; object-fit: contain; border: 0; }
.detail-info { display: grid; align-content: start; gap: 14px; }
.detail-info-block { padding: 14px; border-radius: 12px; background: var(--soft); }
.detail-info-block span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.detail-info-block strong { font-size: 14px; overflow-wrap: anywhere; }
.share-box { margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.share-box label { display: block; font-size: 11px; font-weight: 800; margin-bottom: 8px; }
.copy-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.copy-row input { min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 10px; color: var(--muted); background: var(--soft); }
.history { margin-top: 20px; }
.history h3 { font-size: 15px; margin: 0 0 10px; }
.history-item { padding: 11px 0; display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.history-item::before { content: ""; width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--accent-strong); }
.history-item small { color: var(--muted); }

.review-body { min-height: 100vh; background: #eef1f0; }
.review-header { min-height: 76px; padding: 18px clamp(18px, 4vw, 56px); display: flex; justify-content: space-between; align-items: center; background: var(--ink); color: #fff; }
.secure-label { color: #b8c3c9; font-size: 12px; }
.secure-label::first-letter { color: var(--accent-strong); }
.review-main { padding: clamp(20px, 4vw, 52px); }
.review-layout { max-width: 1340px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(330px, .75fr); gap: 20px; align-items: start; }
.review-preview { overflow: hidden; }
.file-preview { height: min(72vh, 780px); min-height: 480px; display: grid; place-items: center; background: #dde2e1; }
.file-preview img, .file-preview iframe { width: 100%; height: 100%; object-fit: contain; border: 0; }
.file-placeholder { color: var(--muted); text-align: center; }
.review-sidebar { padding: 24px; position: sticky; top: 20px; }
.review-sidebar h1 { margin: 14px 0 3px; font-size: 29px; line-height: 1.08; letter-spacing: -1px; }
.muted { color: var(--muted); }
.requester-note { margin: 20px 0; padding: 15px; border-left: 3px solid var(--accent-strong); background: var(--soft); border-radius: 0 11px 11px 0; color: #3d4851; line-height: 1.55; font-size: 14px; }
.meta-list { margin: 0 0 22px; }
.meta-list div { display: grid; grid-template-columns: 95px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.meta-list dt { color: var(--muted); font-size: 12px; }
.meta-list dd { margin: 0; font-size: 13px; font-weight: 750; overflow-wrap: anywhere; }
.decision-form { display: grid; gap: 14px; }
.decision-grid { display: grid; gap: 9px; }
.decision-button { min-height: 47px; border-radius: 11px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 800; display: flex; justify-content: center; align-items: center; gap: 9px; }
.decision-button.approve { background: var(--ink); color: #fff; border-color: var(--ink); }
.decision-button.changes:hover { background: #fff8e8; border-color: #dfbd70; }
.decision-button.reject:hover { background: #fff0f0; border-color: #df9191; }
.decision-complete { margin: 16px 0; padding: 15px; border-radius: 13px; background: #e9f8f1; color: #235f46; }
.decision-complete strong { display: block; margin-bottom: 4px; }
.confirmation-card { text-align: center; padding: 36px; }
.confirmation-icon { width: 58px; height: 58px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); font-size: 26px; font-weight: 900; }
.confirmation-card h2 { margin: 0 0 8px; }
.confirmation-card p { margin: 0; color: var(--muted); line-height: 1.5; }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .request-card { grid-template-columns: minmax(220px, 1fr) minmax(130px,.6fr) minmax(120px,.55fr) 34px; }
  .request-card .request-meta:nth-of-type(3) { display: none; }
  .review-layout { grid-template-columns: 1fr; }
  .review-sidebar { position: static; }
}

@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: min(300px, 84vw); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: grid !important; }
  .topbar { padding: 18px; min-height: 82px; }
  .topbar h1 { font-size: 20px; }
  .topbar-actions .button-ghost { display: none; }
  .topbar-actions .button-primary { padding: 0 12px; }
  .content { padding: 20px 16px 40px; }
  .hero-card { min-height: 330px; padding: 26px; align-items: flex-start; flex-direction: column; justify-content: flex-end; }
  .hero-card h2 { font-size: 42px; letter-spacing: -1.8px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .request-card { grid-template-columns: 1fr auto; gap: 10px; }
  .request-card .request-meta { display: none !important; }
  .status-badge { grid-column: 1; }
  .card-arrow { grid-column: 2; grid-row: 1 / span 2; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-field { max-width: none; }
  .select-field { justify-content: space-between; }
  .select-field select { flex: 1; }
  .form-grid, .detail-overview { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .modal-card { padding: 20px; }
  .file-preview { min-height: 380px; height: 60vh; }
  .review-main { padding: 14px; }
  .review-header { padding: 15px 18px; }
  .secure-label { display: none; }
}

@media (max-width: 430px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-actions .button-primary span { display: none; }
  .hero-card h2 { font-size: 36px; }
}

/* Online beta: authentication and setup */
.auth-body { min-height: 100vh; background: #eef1f0; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, .9fr) minmax(420px, 1.1fr); }
.auth-brand-panel { padding: clamp(28px, 5vw, 70px); background: radial-gradient(circle at 80% 20%, rgba(255,216,77,.24), transparent 28%), var(--ink); color: #fff; display: flex; flex-direction: column; justify-content: space-between; gap: 80px; }
.auth-brand-panel h1 { max-width: 620px; margin: 18px 0 12px; font-size: clamp(46px, 6vw, 82px); line-height: .95; letter-spacing: -3px; }
.auth-brand-panel p:not(.pill) { max-width: 580px; color: #c5cfd5; line-height: 1.65; font-size: 16px; }
.auth-card { width: min(560px, calc(100% - 38px)); margin: auto; padding: clamp(26px, 4vw, 46px); background: #fff; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.auth-card h2 { margin: 5px 0 8px; font-size: 34px; letter-spacing: -1.2px; }
.auth-form { display: grid; gap: 16px; margin-top: 28px; }
.auth-form .button { min-height: 50px; }
.auth-switch { margin-top: 18px; padding: 0; }
.text-link { display: block; margin-top: 15px; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.form-message { min-height: 20px; margin: 14px 0 0; font-size: 13px; line-height: 1.45; }
.form-message.error { color: #a94646; }
.form-message.success { color: #24724f; }
.notice { padding: 13px 14px; border-radius: 11px; font-size: 12px; line-height: 1.5; }
.notice-warning { background: #fff4d9; color: #755217; }
.sidebar-signout { width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.16); border-radius: 9px; background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center; }
.share-note { display: block; margin-top: 10px; color: var(--muted); line-height: 1.45; }
button:disabled { opacity: .62; cursor: wait; transform: none !important; }
@media (max-width: 800px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand-panel { min-height: 330px; gap: 55px; }
  .auth-brand-panel h1 { font-size: 50px; letter-spacing: -2px; }
  .auth-card { margin: 22px auto; }
}

/* v7: recoverable Trash system */
.nav-item { position: relative; }
.nav-count {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  display: inline-grid; place-items: center; background: rgba(245,200,66,.18); color: var(--accent);
  font-size: 11px; font-weight: 850;
}
.nav-item.active .nav-count { background: var(--accent); color: var(--ink); }
.status-trash { background: #eceff0; color: #59656c; }
.trash-heading {
  margin-bottom: 18px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 16px;
  background: linear-gradient(135deg, #fff 0%, #faf8ee 100%);
}
.trash-heading h2 { margin: 4px 0 7px; font-size: 27px; letter-spacing: -.7px; }
.trash-heading p:not(.eyebrow) { margin: 0; color: var(--muted); line-height: 1.55; max-width: 720px; }
.trash-request-card { opacity: .88; }
.trash-request-card:hover { opacity: 1; }
.trash-action-box {
  margin-top: 18px; padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
  border: 1px solid #e2d7ae; border-radius: 13px; background: #fffaf0;
}
.trash-action-box strong { display: block; margin-bottom: 4px; }
.trash-action-box p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.button-danger { background: #a94141; color: #fff; }
.button-danger:hover { background: #8e3434; }
@media (max-width: 700px) {
  .trash-action-box { align-items: stretch; flex-direction: column; }
  .trash-action-box .modal-actions { justify-content: stretch; }
  .trash-action-box .button { flex: 1; }
}
#forgotLink { margin-right: 18px; }

/* ---------- v2: plans, profile, record ---------- */
.sidebar { overflow-y: auto; }
.sidebar-footer { grid-template-columns: minmax(0, 1fr) 34px; }
.sidebar-profile { min-width: 0; display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: center; gap: 11px; padding: 4px; margin: -4px; border: 0; border-radius: 12px; background: transparent; color: #fff; text-align: left; cursor: pointer; }
.sidebar-profile:hover, .sidebar-profile:focus-visible { background: rgba(255,255,255,.08); }
.plan-badge { display: inline-flex; align-items: center; width: max-content; padding: 5px 10px; border-radius: 100px; background: var(--soft); border: 1px solid var(--line); color: var(--ink); font-size: 11px; font-weight: 850; letter-spacing: .2px; vertical-align: middle; }
.plan-badge-pro { background: var(--accent); border-color: var(--accent-strong); }
.pro-tag { display: inline-block; margin-left: 6px; padding: 2px 6px; border-radius: 6px; background: var(--accent); color: var(--ink); font-size: 9px; font-weight: 900; letter-spacing: .8px; vertical-align: middle; }
.plan-strip { margin: 0 0 18px; padding: 12px 14px 12px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: 14px; font-size: 14px; }
.plan-strip > span:nth-child(2) { flex: 1 1 200px; }
.plan-strip-full { border-color: var(--accent-strong); background: #fffbea; }
.plan-meter { flex: 0 1 140px; height: 8px; min-width: 80px; border-radius: 100px; background: var(--soft); border: 1px solid var(--line); overflow: hidden; }
.plan-meter i { display: block; height: 100%; background: var(--accent-strong); border-radius: inherit; }
.plan-meter-large { width: 100%; height: 10px; margin: 8px 0; }
.history-note { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; background: #fff4d9; color: #755217; font-size: 13px; line-height: 1.5; }
.plan-current { padding: 22px; }
.plan-current-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.plan-current h2 { margin: 6px 0; font-size: 28px; letter-spacing: -.8px; display: flex; align-items: center; gap: 10px; }
.plan-current p { margin: 0; }
.plan-usage { min-width: 220px; display: grid; gap: 2px; }
.plan-usage small { color: var(--muted); }
.billing-toggle { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 750; font-size: 13px; }
.billing-toggle.yearly { background: var(--ink); color: #fff; border-color: var(--ink); }
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.plan-card { display: flex; flex-direction: column; gap: 10px; padding: 24px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.plan-card-pro { border: 2px solid var(--accent-strong); box-shadow: var(--shadow); }
.plan-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.plan-card h3 { margin: 0; font-size: 22px; }
.plan-card p { margin: 0; }
.plan-price strong { font-size: 36px; letter-spacing: -1.2px; }
.plan-price span { margin-left: 6px; color: var(--muted); }
.plan-features { margin: 6px 0 8px; padding: 0; list-style: none; display: grid; gap: 9px; font-size: 14px; line-height: 1.4; }
.plan-features li { position: relative; padding-left: 24px; }
.plan-features li::before { content: '✓'; position: absolute; left: 0; top: 0; color: #24724f; font-weight: 900; }
.plan-cta { margin-top: auto; width: 100%; }
.plan-small { margin: 14px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.profile-card { overflow: hidden; }
.profile-body { padding: 22px; display: grid; gap: 14px; }
.profile-body p { margin: 0; line-height: 1.5; }
.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.field-hint { color: var(--muted); font-size: 12px; line-height: 1.45; }
.field-hint a { text-decoration: underline; }
.field input[readonly] { background: var(--soft); color: var(--muted); }
.field input:disabled { background: var(--soft); cursor: not-allowed; }
.danger-card { border-color: #ecc5c5; }
.danger-card .panel-heading { background: #fff6f6; }
.button-danger:disabled { cursor: not-allowed; }
.modal-narrow { width: min(460px, calc(100% - 28px)); }
.limit-pro { margin-top: 10px !important; color: var(--ink) !important; font-weight: 650; }
.auto-reminder-note { color: #755217; }
@media (max-width: 900px) {
  .plan-grid { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .plan-strip { font-size: 13px; }
  .plan-strip .button { width: 100%; }
  .plan-meter { flex-basis: 100%; }
  .profile-actions .button { flex: 1 1 auto; }
  .plan-current h2 { font-size: 24px; }
  .section-heading { flex-wrap: wrap; }
}

/* Printable record (record.html) */
.record-body { background: var(--soft); }
.record-page { width: min(900px, calc(100% - 28px)); margin: 24px auto 60px; display: grid; gap: 16px; }
.record-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.record-sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(20px, 4vw, 40px); }
.record-sheet h1 { margin: 6px 0 4px; font-size: 30px; letter-spacing: -1px; }
.record-sheet h2 { margin: 26px 0 10px; font-size: 16px; }
.record-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; margin-top: 18px; }
.record-meta div span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; }
.record-meta div strong { display: block; margin-top: 3px; font-size: 14px; word-break: break-word; }
.record-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.record-table th, .record-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.record-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.record-foot { margin-top: 28px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.record-message { padding: 28px; text-align: center; }
@media (max-width: 600px) {
  .record-meta { grid-template-columns: 1fr; }
  .record-table { font-size: 12px; }
}
@media print {
  @page { margin: 16mm; }
  .record-body { background: #fff; }
  .record-toolbar, .no-print { display: none !important; }
  .record-page { width: 100%; margin: 0; }
  .record-sheet { border: 0; padding: 0; }
  .record-table tr { break-inside: avoid; }
}

/* Review page brand line (Pro) */
.meta-list dd.review-brand-line { grid-column: 2; margin-top: -8px; color: var(--muted); font-size: 12px; font-weight: 650; }

@media (max-width: 780px) { .app-shell { background: none; } }

/* ---------- Profile layout (v18): one aligned column, max 960px ---------- */
.profile-layout { max-width: 960px; display: grid; gap: 16px; }
.profile-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.profile-card { display: flex; flex-direction: column; min-width: 0; }
.profile-card > .profile-body { flex: 1 1 auto; align-content: start; }
.profile-card > form.profile-body { grid-template-rows: auto; }
/* Buttons sit on the same baseline in side-by-side cards */
.profile-pair form.profile-body { display: flex; flex-direction: column; gap: 14px; }
.profile-pair form.profile-body > .profile-actions { margin-top: auto; padding-top: 4px; }
.profile-actions { align-items: center; }
.profile-actions .form-message { margin: 0; min-height: 0; flex: 1 1 180px; }
.profile-actions .form-message:empty { display: none; }
.profile-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.profile-row-text { display: grid; gap: 8px; min-width: 0; flex: 1 1 auto; max-width: 520px; }
.profile-row-text h2 { margin: 4px 0 0; font-size: 23px; letter-spacing: -.6px; }
.profile-row > .profile-actions { flex: 0 0 auto; justify-content: flex-end; }
.danger-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 14px; align-items: end; }
.danger-fields .profile-actions .button { min-height: 46px; }
#deleteForm .form-message { margin: 0; }
#deleteForm .form-message:empty { display: none; }
@media (max-width: 1100px) {
  .danger-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .danger-fields .profile-actions { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .profile-pair { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .profile-row { flex-direction: column; align-items: stretch; gap: 14px; }
  .profile-row > .profile-actions { justify-content: stretch; }
  .profile-row > .profile-actions .button { flex: 1 1 0; }
  .danger-fields { grid-template-columns: 1fr; }
  .danger-fields .profile-actions .button { width: 100%; }
}

/* ---------- v18 alignment fixes for other views ---------- */
.plan-strip { margin-top: 22px; }
.hero-card > .button { flex: 0 0 auto; white-space: nowrap; }
.plan-cta-current { cursor: default; color: var(--muted); background: var(--soft); border-color: var(--line); }
.plan-cta-current:hover { transform: none; }
.plan-cta-note { min-height: 42px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 13px; }
.plan-current .profile-actions { margin-top: 14px; }
@media (max-width: 780px) {
  .hero-card > .button { white-space: normal; }
  .topbar-actions .button { white-space: nowrap; padding: 0 14px; }
}

/* =====================================================================
   v19: pinned sidebar bottom + fluid, responsive pages
   ===================================================================== */
:root {
  --sidebar-w: 260px;
  --gutter: clamp(14px, 3.2vw, 38px);
  --app-vh: 100vh;
}
@supports (height: 100dvh) { :root { --app-vh: 100dvh; } }

/* ---- Sidebar: nav on top, flexible spacer, card + login block pinned to the bottom ---- */
.app-shell { min-height: var(--app-vh); grid-template-columns: var(--sidebar-w) minmax(0, 1fr); background: linear-gradient(to right, var(--ink) var(--sidebar-w), transparent var(--sidebar-w)); }
.sidebar {
  height: var(--app-vh); max-height: var(--app-vh); min-height: 0;
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  padding: clamp(16px, 3.5vh, 28px) 20px 0;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sidebar > .brand { flex: 0 0 auto; }
.sidebar .nav { flex: 0 0 auto; margin-top: clamp(18px, 5vh, 42px); }
.sidebar-scrim { display: none; }
.sidebar-spacer { flex: 1 1 auto; min-height: 16px; }
.sidebar-bottom {
  flex: 0 0 auto; display: grid; gap: 16px;
  position: sticky; bottom: 0; z-index: 2;
  margin: 0 -20px; padding: 14px 20px max(18px, env(safe-area-inset-bottom));
  background: var(--ink);
}
.sidebar-bottom .sidebar-card { margin-top: 0; }
.sidebar-bottom .sidebar-footer { margin-top: 0; padding-top: 16px; }
details.sidebar-card { padding: 0; }
details.sidebar-card > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; min-height: 44px; border-radius: 15px;
}
details.sidebar-card > summary::-webkit-details-marker { display: none; }
details.sidebar-card > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
details.sidebar-card > summary .sidebar-card-icon { margin: 0; font-size: 10px; }
details.sidebar-card > summary strong { flex: 1 1 auto; font-size: 14px; }
.sidebar-card-chevron { width: 8px; height: 8px; border-right: 2px solid #8e9aa3; border-bottom: 2px solid #8e9aa3; transform: rotate(-135deg); transition: transform .15s ease; margin-top: 4px; }
details.sidebar-card:not([open]) .sidebar-card-chevron { transform: rotate(45deg); margin-top: -4px; }
details.sidebar-card > p { margin: -4px 0 0; padding: 0 16px 15px; }
.sidebar-footer .avatar { flex: 0 0 auto; }
.sidebar-signout { width: 40px; height: 40px; }
.sidebar-footer { grid-template-columns: minmax(0, 1fr) 40px; }

/* Short screens: tighter nav so the bottom block stays on screen */
@media (max-height: 699px) {
  .sidebar .nav { gap: 3px; }
  .nav-item { padding-top: 9px; padding-bottom: 9px; }
  .sidebar-bottom { gap: 10px; padding-top: 10px; }
  .sidebar-bottom .sidebar-footer { padding-top: 12px; }
}
@media (max-height: 520px) {
  .nav-item { padding-top: 7px; padding-bottom: 7px; min-height: 38px; }
  .sidebar .nav { margin-top: 14px; }
}

/* ---- Main column fills the viewport; no hanging gaps ---- */
.main { display: flex; flex-direction: column; min-height: var(--app-vh); min-width: 0; }
.main > .content { flex: 1 0 auto; width: 100%; }
.content { padding: clamp(18px, 3vw, 30px) var(--gutter) clamp(28px, 4vw, 50px); max-width: 1480px; }
.topbar { padding: clamp(14px, 2.2vw, 24px) var(--gutter); min-height: clamp(70px, 9vw, 98px); }
.topbar > div:nth-child(2) { min-width: 0; flex: 1 1 auto; }
.topbar h1 { font-size: clamp(19px, 1.2vw + 14px, 25px); overflow-wrap: anywhere; }

/* ---- Fluid grids ---- */
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 132px), 1fr)); }
.plan-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.hero-card { min-height: clamp(210px, 26vw, 260px); padding: clamp(22px, 3.4vw, 38px); flex-wrap: wrap; }
.hero-card > div { flex: 1 1 320px; min-width: 0; }
.hero-card h2 { font-size: clamp(30px, 3.6vw + 10px, 60px); letter-spacing: clamp(-2.4px, -.15vw, -1px); }
.hero-card::after { font-size: clamp(150px, 18vw, 250px); }
.request-card { grid-template-columns: minmax(0, 1.4fr) minmax(0, .7fr) minmax(0, .65fr) minmax(max-content, .55fr) 28px; }
.trash-heading h2 { font-size: clamp(22px, 1.4vw + 16px, 27px); }
.plan-price strong { font-size: clamp(30px, 2vw + 20px, 36px); }
.modal-header h2 { font-size: clamp(21px, 1.4vw + 15px, 26px); }
.auth-brand-panel h1 { font-size: clamp(36px, 5.4vw + 8px, 82px); letter-spacing: clamp(-3px, -.2vw, -1.2px); overflow-wrap: anywhere; }
.auth-card h2 { font-size: clamp(26px, 2vw + 18px, 34px); }

/* ---- Consistent loading + empty states ---- */
.loading-state, .empty-state { border-radius: var(--radius); }
.loading-state { padding: clamp(32px, 6vw, 58px) 24px; display: grid; justify-items: center; gap: 12px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed #bec8cd; }
.loading-state p { margin: 0; font-size: 14px; }
.timeline .loading-state, .timeline > .empty-state { margin: 16px 0 0; }
.record-message .loading-state { border: 0; }
.loading-spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent-strong); animation: ca-spin .8s linear infinite; }
@keyframes ca-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading-spinner { animation-duration: 2.4s; } }
.empty-state { padding: clamp(32px, 6vw, 58px) clamp(16px, 4vw, 24px); }

/* ---- Large screens ---- */
@media (min-width: 1700px) {
  :root { --sidebar-w: 280px; }
  .content { max-width: 1560px; }
}

/* ---- Tablet / small laptop ---- */
@media (max-width: 1280px) {
  .request-card { grid-template-columns: minmax(0, 1.3fr) minmax(0, .7fr) minmax(max-content, .55fr) 28px; }
  .request-card .request-meta:nth-of-type(3) { display: none; }
}
@media (max-width: 1050px) {
  .request-card { grid-template-columns: minmax(0, 1fr) minmax(max-content, auto) 24px; }
  .request-card .request-meta { display: none; }
}

/* ---- Phones and the slide-in drawer ---- */
@media (max-width: 780px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); height: var(--app-vh); padding-left: 18px; padding-right: 18px; z-index: 40; visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
  .sidebar.open { visibility: visible; transition: transform .2s ease, visibility 0s; }
  .sidebar-bottom { margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
  /* drawer backdrop (hidden on desktop by the base rule) */
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(18,25,32,.5); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  .sidebar.open ~ .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .topbar { gap: 10px; }
  .hero-card { min-height: 0; flex-direction: column; align-items: stretch; }
  .hero-card > div { flex: 0 0 auto; }
  .hero-card > .button { align-self: flex-start; }
  .request-card { grid-template-columns: minmax(0, 1fr) 24px; }
  .request-card .status-badge { grid-column: 1; }
  .modal { width: calc(100% - 20px); max-height: calc(var(--app-vh) - 20px); }
  .modal-card { max-height: calc(var(--app-vh) - 20px); }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .button { flex: 1 1 140px; }
  .timeline { padding: 4px 16px 18px; }
  .timeline-item { grid-template-columns: 31px minmax(0, 1fr); }
  .timeline-item > small, .timeline-item > :last-child:not(:nth-child(2)) { grid-column: 2; white-space: normal; }
  .detail-preview { min-height: 220px; }
  .copy-row { grid-template-columns: minmax(0, 1fr); }
  .trash-action-box .modal-actions { flex-wrap: wrap; }
  .file-preview { height: min(60vh, 520px); min-height: 280px; }
  .review-sidebar h1 { font-size: clamp(23px, 6vw, 29px); }
  .meta-list div { grid-template-columns: minmax(80px, 30%) minmax(0, 1fr); }
  .auth-brand-panel { min-height: 0; gap: 28px; padding: 28px 22px; }
  .auth-card { width: calc(100% - 28px); margin: 18px auto 28px; }
}

/* Touch-friendly targets */
@media (max-width: 780px), (pointer: coarse) {
  .button, .decision-button, .select-field select, .search-field { min-height: 44px; }
  .button-small { min-height: 40px; }
  .icon-button { width: 44px; height: 44px; }
  .nav-item { min-height: 44px; }
  .text-button { min-height: 40px; padding: 8px 4px; }
  .billing-toggle { min-height: 40px; }
  .field input, .field textarea, .field select { font-size: 16px; } /* no iOS zoom on focus */
}

@media (max-width: 430px) {
  .topbar-actions .button-primary { padding: 0 12px; }
  .hero-card > .button { align-self: stretch; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 28px; }
  .stat-top { font-size: 11px; }
  .panel-heading { padding: 16px; }
  .profile-body { padding: 16px; }
  .plan-card { padding: 18px; }
  .plan-current { padding: 16px; }
  .plan-usage { min-width: 0; width: 100%; }
}
@media (max-width: 359px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar .eyebrow { display: none; }
  .topbar-actions .button-primary { font-size: 13px; padding: 0 10px; }
  .brand { font-size: 18px; }
}

/* ---- Record page: tables stack into cards on small screens ---- */
.record-page { width: min(960px, calc(100% - 2 * clamp(12px, 3vw, 28px))); min-height: calc(var(--app-vh) - 84px); align-content: start; }
.record-sheet { overflow-wrap: anywhere; }
.record-sheet h1 { font-size: clamp(23px, 2vw + 16px, 30px); }
@media (max-width: 560px) {
  .record-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .record-table, .record-table tbody, .record-table tr, .record-table td { display: block; width: 100%; }
  .record-table tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .record-table td { position: relative; padding: 4px 0 4px 102px; border: 0; overflow-wrap: anywhere; min-height: 24px; }
  .record-table td::before { position: absolute; left: 0; top: 6px; width: 92px; content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; }
  .record-toolbar .profile-actions { width: 100%; }
  .record-toolbar .profile-actions .button { flex: 1 1 0; }
}
@media print {
  .record-page { min-height: 0; }
  .record-table thead { position: static; width: auto; height: auto; clip: auto; }
}

/* ---- Review page ---- */
.review-body { display: flex; flex-direction: column; min-height: var(--app-vh); }
.review-main { flex: 1 0 auto; padding: clamp(12px, 3.6vw, 52px); }
@media (min-width: 1051px) { .review-layout { grid-template-columns: minmax(0, 1.55fr) minmax(330px, .75fr); } }
@media (max-width: 1050px) { .review-layout { grid-template-columns: minmax(0, 1fr); } }
.review-header { min-height: clamp(60px, 7vw, 76px); gap: 12px; }
@media (min-width: 1700px) { .review-layout { max-width: 1560px; } }
@media (max-height: 640px) and (min-width: 1051px) { .file-preview { min-height: 340px; height: 70vh; } }

/* ---- Sign-in ---- */
.auth-shell { min-height: var(--app-vh); grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
@media (max-width: 800px) { .auth-shell { grid-template-columns: minmax(0, 1fr); align-content: start; } }
@media (max-height: 640px) and (min-width: 801px) { .auth-brand-panel { gap: 32px; } .auth-card { margin: 24px auto; } }
@media (max-width: 780px) {
  .request-card > div:nth-last-child(2) { grid-column: 1; grid-row: 2; }
  .request-card > .card-arrow { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
}
