/* =========================================================
   PATRA — paper purchase ledger
   Theme: warm paper + forest botanical
   ========================================================= */

:root {
  /* core palette */
  --paper: #f5efe0;
  --paper-warm: #ebe3d0;
  --paper-deep: #ddd1b5;
  --ink: #2a2418;
  --ink-soft: #5a513f;
  --ink-muted: #8a7f68;

  --moss: #2d4a2b;
  --moss-light: #4a6b48;
  --leaf: #5a7a4a;
  --sage: #a8b598;
  --olive: #7a8f5e;

  --accent: #c97b3d;     /* terracotta */
  --accent-soft: #e8a875;
  --gold: #b8923a;

  --line: #d4c8a8;
  --line-soft: #e3d9bf;

  --danger: #a8412e;

  --shadow-sm: 0 1px 2px rgba(45, 36, 24, 0.06);
  --shadow-md: 0 4px 14px rgba(45, 36, 24, 0.08), 0 1px 3px rgba(45, 36, 24, 0.06);
  --shadow-lg: 0 12px 32px rgba(45, 36, 24, 0.12), 0 2px 6px rgba(45, 36, 24, 0.08);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(ellipse at top right, rgba(122,143,94,0.10) 0%, transparent 50%),
    radial-gradient(ellipse at bottom left, rgba(201,123,61,0.06) 0%, transparent 55%),
    linear-gradient(180deg, #f7f1e3 0%, #efe7d1 100%);
  background-attachment: fixed;
}

/* ---------- DECORATIVE BG ---------- */
.bg-leaves {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: 0.6;
}
.bg-leaves svg { width: 100%; height: 100%; }

/* ---------- APP SHELL ---------- */
.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 14px) 18px calc(var(--safe-bottom) + 100px);
  min-height: 100vh;
}

/* ---------- HEADER ---------- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.leaf-icon {
  width: 42px; height: 42px;
  background: var(--moss);
  color: var(--paper);
  border-radius: 50%;
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(45, 74, 43, 0.25), inset 0 -2px 4px rgba(0,0,0,0.1);
  position: relative;
}
.leaf-icon::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 1px dashed var(--moss);
  border-radius: 50%;
  opacity: 0.3;
}
.leaf-icon svg { width: 24px; height: 24px; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  margin: 0;
  line-height: 1;
  color: var(--moss);
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144;
}
.brand-tag {
  margin: 4px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}
.install-btn {
  background: var(--moss);
  color: var(--paper);
  border: none;
  padding: 9px 16px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.install-help {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  color: var(--moss);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, background 0.2s;
}
.install-help:active { transform: scale(0.92); }

/* ---------- INSTALL MODAL ---------- */
.install-card {
  text-align: left;
}
.install-illo {
  display: grid;
  place-items: center;
  margin: -4px 0 12px;
  width: 80px;
  height: 80px;
  background: var(--paper-warm);
  border-radius: 50%;
  margin-left: auto;
  margin-right: auto;
  border: 1px dashed var(--line);
}
.install-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--moss);
  margin: 0 0 6px;
  text-align: center;
  letter-spacing: -0.01em;
}
.install-sub {
  font-size: 13px;
  color: var(--ink-muted);
  text-align: center;
  margin: 0 0 22px;
  line-height: 1.4;
}
.install-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--paper-warm);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--leaf);
}
.step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--moss);
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
}
.install-step strong {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  display: block;
  margin-bottom: 2px;
}
.install-step p {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin: 0;
  line-height: 1.4;
}
.install-direct {
  margin-top: 4px;
}
.install-note {
  font-size: 11.5px;
  color: var(--ink-muted);
  text-align: center;
  margin-top: 14px;
  font-style: italic;
  line-height: 1.4;
}

/* ---------- TABS ---------- */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: var(--paper-warm);
  border-radius: 14px;
  padding: 5px;
  margin-bottom: 22px;
  box-shadow: inset 0 1px 2px rgba(45,36,24,0.06);
  border: 1px solid var(--line-soft);
}
.tab {
  background: transparent;
  border: none;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--ink-soft);
  border-radius: 10px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.02em;
}
.tab.active {
  background: var(--moss);
  color: var(--paper);
  box-shadow: 0 2px 8px rgba(45,74,43,0.25);
}
.tab svg { stroke: currentColor; }

/* ---------- VIEWS ---------- */
.view { display: none; animation: fadeUp 0.4s ease both; }
.view.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- SUMMARY CARD ---------- */
.summary-card {
  position: relative;
  background: linear-gradient(135deg, var(--moss) 0%, #243d22 100%);
  color: var(--paper);
  border-radius: var(--radius-lg);
  padding: 22px 20px 18px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.summary-card::before {
  content: "";
  position: absolute;
  top: -40px; right: -40px;
  width: 160px; height: 160px;
  border: 1px solid rgba(245, 239, 224, 0.08);
  border-radius: 50%;
}
.summary-card::after {
  content: "";
  position: absolute;
  top: -20px; right: -20px;
  width: 120px; height: 120px;
  border: 1px solid rgba(245, 239, 224, 0.06);
  border-radius: 50%;
}
.summary-watermark {
  position: absolute;
  bottom: -20px; right: -20px;
  width: 180px; height: 180px;
  color: rgba(245, 239, 224, 0.07);
  pointer-events: none;
}
.summary-watermark svg { width: 100%; height: 100%; }

.summary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  position: relative;
  z-index: 1;
}
.summary-row.second {
  grid-template-columns: 1fr 1fr 1fr;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(245,239,224,0.15);
}
.summary-cell { display: flex; flex-direction: column; gap: 4px; }
.cell-label {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
  font-weight: 500;
}
.cell-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144;
}
.cell-value .unit { font-size: 14px; opacity: 0.7; font-weight: 500; }
.cell-value-sm {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  font-variation-settings: "opsz" 144;
}

/* ---------- SECTION HEAD ---------- */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.section-head h2::before {
  content: "❦";
  color: var(--moss-light);
  margin-right: 8px;
  font-size: 14px;
}
#searchBox {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 13px;
  width: 150px;
  color: var(--ink);
  outline: none;
  transition: all 0.2s;
}
#searchBox:focus {
  border-color: var(--moss-light);
  background: var(--paper);
  width: 170px;
}

/* ---------- ENTRY CARDS ---------- */
.entry-list { display: flex; flex-direction: column; gap: 12px; }

.entry-card {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.entry-card:active {
  transform: scale(0.985);
  box-shadow: var(--shadow-md);
}
.entry-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--leaf), var(--moss));
}

.entry-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 10px;
}
.entry-mill {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--moss);
  letter-spacing: -0.01em;
  line-height: 1.2;
  font-variation-settings: "opsz" 144;
}
.entry-date {
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  white-space: nowrap;
}

.entry-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}
.meta-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

.entry-photo-chip {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--moss);
}
.entry-photo-chip svg { width: 14px; height: 14px; }

/* ---------- EMPTY STATE ---------- */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
}
.empty-state.show { display: flex; }
.empty-illo {
  width: 120px;
  height: 120px;
  margin-bottom: 8px;
  opacity: 0.85;
}
.empty-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin: 4px 0 6px;
  color: var(--ink);
}
.empty-sub {
  font-size: 13px;
  margin: 0;
  color: var(--ink-muted);
}

/* ---------- FORM ---------- */
.form-header {
  margin-bottom: 20px;
}
.form-header h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--moss);
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144;
}
.form-header h2::after {
  content: "";
  display: block;
  width: 32px;
  height: 2px;
  background: var(--accent);
  margin-top: 8px;
  border-radius: 2px;
}
.form-header p {
  margin: 8px 0 0;
  color: var(--ink-muted);
  font-size: 13px;
}

.form { display: flex; flex-direction: column; gap: 16px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="date"] {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus {
  border-color: var(--moss-light);
  box-shadow: 0 0 0 3px rgba(74, 107, 72, 0.15);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.hint {
  font-size: 11.5px;
  color: var(--ink-muted);
  font-style: italic;
  margin-top: 2px;
}
.hint.warn { color: var(--accent); font-style: normal; font-weight: 500; }

/* ---------- REELS ---------- */
.reels-section {
  background: var(--paper-warm);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
}
.reels-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.add-reel-btn {
  background: var(--moss);
  color: var(--paper);
  border: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-body);
}
.reels-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.reel-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  background: var(--paper);
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
}
.reel-row .field-label {
  font-size: 9.5px;
  margin-bottom: 4px;
  display: block;
}
.reel-row input {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 13px;
  width: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  outline: none;
}
.reel-row input:focus { border-color: var(--moss-light); }
.del-reel {
  width: 32px; height: 36px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--danger);
  border-radius: 6px;
  font-size: 18px;
  font-weight: 600;
}
.reels-summary {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  color: var(--ink-soft);
}
.reels-summary strong {
  font-family: var(--font-mono);
  color: var(--moss);
}

/* ---------- PHOTO ---------- */
.photo-drop {
  background: var(--paper-warm);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 24px 16px;
  display: grid;
  place-items: center;
  min-height: 140px;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  position: relative;
}
.photo-drop:hover { border-color: var(--moss-light); }
.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--ink-muted);
  text-align: center;
}
.photo-placeholder span { font-size: 13px; }
#photoPreview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  display: block;
}
.clear-photo {
  margin-top: 8px;
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: underline;
  align-self: flex-start;
  padding: 4px 0;
}

/* ---------- HISAB TOGGLE (form) ---------- */
.hisab-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--paper-warm);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.hisab-toggle:has(input:checked) {
  background: linear-gradient(135deg, rgba(90, 122, 74, 0.12), rgba(45, 74, 43, 0.08));
  border-color: var(--leaf);
  box-shadow: 0 0 0 3px rgba(90, 122, 74, 0.1);
}
.hisab-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.hisab-check {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  display: grid;
  place-items: center;
  color: transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.hisab-check svg { width: 18px; height: 18px; transform: scale(0); transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }
.hisab-toggle:has(input:checked) .hisab-check {
  background: var(--moss);
  border-color: var(--moss);
  color: var(--paper);
  box-shadow: 0 3px 8px rgba(45, 74, 43, 0.25);
}
.hisab-toggle:has(input:checked) .hisab-check svg { transform: scale(1); }
.hisab-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.hisab-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.hisab-sub {
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.3;
}

/* ---------- FILTER CHIPS ---------- */
.filter-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 7px 14px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}
.chip.active {
  background: var(--moss);
  color: var(--paper);
  border-color: var(--moss);
}
.chip svg { stroke: currentColor; }

/* ---------- LEDGER CARD HISAB TICK ---------- */
.entry-card .hisab-tick {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  display: grid;
  place-items: center;
  color: transparent;
  z-index: 2;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.entry-card .hisab-tick svg { width: 16px; height: 16px; transform: scale(0); transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }
.entry-card .hisab-tick.done {
  background: var(--moss);
  border-color: var(--moss);
  color: var(--paper);
}
.entry-card .hisab-tick.done svg { transform: scale(1); }
.entry-card .hisab-tick:active { transform: scale(0.9); }

.entry-card.done {
  background: linear-gradient(180deg, rgba(90, 122, 74, 0.05), var(--paper));
  border-color: rgba(90, 122, 74, 0.35);
}
.entry-card.done::before {
  background: linear-gradient(180deg, var(--accent), var(--gold));
}
.entry-card.done .entry-mill::after {
  content: " · settled";
  font-family: var(--font-body);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--leaf);
  font-weight: 600;
  vertical-align: middle;
  margin-left: 4px;
}

/* shift photo chip to make room for hisab tick */
.entry-card .entry-photo-chip {
  right: 50px;
}

/* shift entry-top right padding when tick is shown */
.entry-card .entry-top { padding-right: 36px; }

/* ---------- DETAIL HISAB BADGE ---------- */
.detail-hisab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  cursor: pointer;
}
.detail-hisab .tick-box {
  width: 22px; height: 22px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  display: grid; place-items: center;
  color: transparent;
  flex-shrink: 0;
}
.detail-hisab .tick-box svg { width: 14px; height: 14px; }
.detail-hisab.done {
  background: linear-gradient(135deg, rgba(90, 122, 74, 0.18), rgba(45, 74, 43, 0.1));
  border-color: var(--leaf);
  color: var(--moss);
}
.detail-hisab.done .tick-box {
  background: var(--moss);
  border-color: var(--moss);
  color: var(--paper);
}

/* ---------- BUTTONS ---------- */
.form-actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  margin-top: 8px;
}
.btn-primary, .btn-secondary, .btn-ghost {
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 14.5px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s, box-shadow 0.2s;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--moss);
  color: var(--paper);
  box-shadow: 0 4px 12px rgba(45, 74, 43, 0.25);
}
.btn-primary:active { transform: scale(0.97); }
.btn-secondary {
  background: var(--paper-warm);
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.btn-ghost {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid rgba(168, 65, 46, 0.3);
}
.full { width: 100%; }

/* ---------- CHARTS ---------- */
.chart-card {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}
.chart-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.chart-unit {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}
.chart-wrap {
  position: relative;
  height: 200px;
}
.export-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

/* ---------- MODAL ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(42, 36, 24, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease;
}
.modal-card {
  position: relative;
  background: var(--paper);
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 22px 20px calc(24px + var(--safe-bottom));
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
}
.modal-card::before {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: -10px auto 14px;
}
.modal-close {
  position: absolute;
  top: 14px; right: 16px;
  background: var(--paper-warm);
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 20px;
  color: var(--ink-soft);
  line-height: 1;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

.detail-mill {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--moss);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.detail-date {
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.detail-cell {
  background: var(--paper-warm);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
}
.detail-cell .meta-label { font-size: 9.5px; }
.detail-cell .meta-value { font-size: 15px; }
.detail-photo {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border: 1px solid var(--line);
}
.detail-reels-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin: 8px 0;
}
.detail-reel {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--paper-warm);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13px;
  border-left: 3px solid var(--leaf);
}
.detail-reel-size { font-family: var(--font-mono); color: var(--ink); }
.detail-reel-weight { font-family: var(--font-mono); color: var(--moss); font-weight: 600; }

.detail-delete {
  width: 100%;
  background: transparent;
  border: 1.5px solid rgba(168, 65, 46, 0.3);
  color: var(--danger);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-family: var(--font-body);
  margin-top: 12px;
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  bottom: calc(110px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: toastIn 0.3s ease;
  max-width: 90vw;
  text-align: center;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- RESPONSIVE TWEAKS ---------- */
@media (max-width: 360px) {
  .summary-row.second { gap: 10px; }
  .cell-value { font-size: 22px; }
  .entry-meta { grid-template-columns: 1fr 1fr; }
  .entry-meta .meta-item:nth-child(3) { display: none; }
}
