:root {
  --bg: #FAF7F1;
  --paper: #FFFFFF;
  --ink: #221812;
  --ink-2: #4A3A2C;
  --muted: #8C7D6B;
  --tan: #B08D57;
  --tan-2: #96744A;
  --tan-soft: #F3EBDF;
  --line: #EAE3D7;
  --red: #A6483B;
  --green: #4E7A55;
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .serif { font-family: 'Playfair Display', Georgia, 'Times New Roman', serif; font-weight: 500; letter-spacing: .01em; }
a { color: var(--tan-2); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  width: 100%;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--tan); box-shadow: 0 0 0 3px rgba(176,141,87,.14); }
label { display: block; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 16px 0 6px; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 20px;
  background: var(--bg); }
.auth-card { background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: 52px 46px 46px; width: 100%; max-width: 420px; }
.auth-card p.muted { text-align: center; color: var(--muted); margin: 14px 0 6px; font-size: 14px; }
.brand-mark { text-align: center; margin-bottom: 10px; }
.brand-mark .word { font-family: 'Inter', sans-serif; font-weight: 300; font-size: 44px; letter-spacing: .06em; color: var(--tan); line-height: 1; }
.brand-mark .word2 { font-family: 'Playfair Display', serif; font-size: 15px; font-weight: 500; letter-spacing: .52em; text-indent: .52em; color: var(--ink); margin-top: 8px; }
.brand-mark .sub { font-size: 10px; letter-spacing: .3em; text-transform: uppercase; color: var(--muted); margin-top: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--ink); color: #FBF8F2; border: 1px solid var(--ink); border-radius: 99px;
  padding: 10px 22px; font-weight: 500; font-size: 13.5px; letter-spacing: .04em;
  transition: all .15s;
}
.btn:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.gold { background: var(--tan); border-color: var(--tan); color: #fff; }
.btn.gold:hover { background: var(--tan-2); border-color: var(--tan-2); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--tan); color: var(--tan-2); }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.block { width: 100%; margin-top: 22px; padding: 12px 22px; }
.btn.sm { padding: 6px 14px; font-size: 12.5px; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--paper); color: var(--ink);
  border-right: 1px solid var(--line);
  padding: 34px 22px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.sidebar .word { font-family: 'Inter', sans-serif; font-weight: 300; font-size: 26px; letter-spacing: .08em; color: var(--tan); }
.sidebar .sub { font-size: 9.5px; letter-spacing: .3em; text-transform: uppercase; color: var(--muted); margin: 4px 0 34px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px;
  color: var(--ink-2); font-size: 14px; font-weight: 400; background: none; border: none; width: 100%; text-align: left;
  transition: all .15s;
}
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: var(--tan-soft); color: var(--tan-2); font-weight: 500; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; stroke-width: 1.7; }
.sidebar .spacer { flex: 1; }
.main { flex: 1; padding: 44px 48px 100px; max-width: 1160px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 30px; flex-wrap: wrap; }
.page-head h1 { font-size: 32px; font-weight: 500; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards & tables ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 22px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.stat .n { font-family: 'Playfair Display', serif; font-size: 30px; font-weight: 500; line-height: 1.15; }
.stat .l { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-top: 4px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid #F2EDE4; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }
.pill { display: inline-block; padding: 3px 12px; border-radius: 99px; font-size: 11.5px; font-weight: 500; letter-spacing: .02em; }
.pill.pending { background: #F6EBD4; color: #8A6A1F; }
.pill.confirmed { background: #E2EDE2; color: var(--green); }
.pill.invoiced { background: #E2E9F2; color: #39587E; }
.pill.paid { background: #DFEEE4; color: #2E6B44; }
.pill.cancelled { background: #F3DFDC; color: var(--red); }
.pill.active { background: #DFEEE4; color: #2E6B44; }
.pill.inactive { background: #EFE8DC; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stock-low { color: var(--red); font-weight: 600; }
.stock-ok { color: var(--green); font-weight: 500; }

/* ---------- forms ---------- */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.modal-bg { position: fixed; inset: 0; background: rgba(34,24,18,.35); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: var(--paper); border-radius: 20px; border: 1px solid var(--line); padding: 30px; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; }
.modal h2 { font-size: 24px; margin-bottom: 6px; }
.modal .actions { display: flex; gap: 10px; margin-top: 22px; justify-content: flex-end; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #FBF8F2; padding: 12px 24px; border-radius: 99px; z-index: 99; font-size: 14px; }
.toast.err { background: var(--red); }

/* ---------- catalog / shop ---------- */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; }
.frame-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 5px; transition: border-color .15s; }
.frame-card:hover { border-color: var(--tan); }
.frame-card .model { font-family: 'Playfair Display', serif; font-size: 21px; font-weight: 500; }
.frame-card .code { font-size: 11px; letter-spacing: .14em; color: var(--tan-2); font-weight: 600; }
.frame-card .price { font-size: 15px; font-weight: 500; }
.qty-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.qty-row input { width: 64px; text-align: center; padding: 7px; }
.cart-bar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--ink); color: #FBF8F2; padding: 14px 22px; display: flex; align-items: center; justify-content: space-between; z-index: 40; }

/* ---------- calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); text-align: center; padding: 6px 0; }
.cal-day { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; min-height: 84px; padding: 8px; font-size: 12px; }
.cal-day.other { opacity: .38; }
.cal-day.today { outline: 2px solid var(--tan); outline-offset: -2px; }
.cal-day .dnum { font-weight: 600; margin-bottom: 4px; }
.cal-ev { background: var(--tan-soft); border-left: 2px solid var(--tan); border-radius: 4px; padding: 2px 6px; margin-bottom: 3px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- plan page ---------- */
.plan-hero { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: 34px 34px 30px; margin-bottom: 16px; }
.plan-hero .q { font-family: 'Playfair Display', serif; font-size: 23px; line-height: 1.45; font-weight: 500; }
.plan-section { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 28px; margin-top: 16px; }
.plan-section h2 { font-size: 21px; margin-bottom: 4px; }
.plan-section .sub-note { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; margin-bottom: 14px; }
.plan-rows { display: grid; gap: 0; }
.plan-note { font-size: 13.5px; color: var(--ink-2); margin-top: 12px; line-height: 1.6; }
.scenario { border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.scenario .t { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 6px; }
.scenario .v { font-family: 'Playfair Display', serif; font-size: 26px; font-weight: 500; }
.scenario .d { font-size: 13px; color: var(--ink-2); margin-top: 6px; line-height: 1.5; }
.flag { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid #F2EDE4; font-size: 14px; align-items: baseline; }
.flag:last-child { border-bottom: none; }
.flag .dot { width: 7px; height: 7px; border-radius: 99px; background: var(--tan); flex-shrink: 0; transform: translateY(-1px); }

/* ---------- bottom nav (mobile) ---------- */
.bottomnav { display: none; }
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { display: none; }
  .main { padding: 22px 18px 120px; max-width: none; }
  .auth-card { padding: 40px 28px 34px; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
    background: var(--paper); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bottomnav button { background: none; border: none; color: var(--muted); font-size: 10.5px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 6px; }
  .bottomnav button.active { color: var(--tan-2); }
  .bottomnav svg { width: 20px; height: 20px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .topbar { display: flex; }
}
.topbar { display: none; background: var(--paper); border-bottom: 1px solid var(--line); color: var(--ink); padding: 14px 18px; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30; }
.topbar .word { font-family: 'Inter', sans-serif; font-weight: 300; font-size: 20px; letter-spacing: .08em; color: var(--tan); }
.topbar .sub { font-size: 9px; letter-spacing: .28em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 860px) { .topbar { display: flex; } }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .serif { font-size: 24px; color: var(--ink); margin-bottom: 6px; }
.link-row { display: flex; gap: 8px; align-items: center; }
.link-row input { flex: 1; font-size: 13px; }
.section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 26px 0 10px; }
.line-item { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid #F2EDE4; }
.line-item:last-child { border-bottom: none; }
.total-row { display: flex; justify-content: space-between; padding: 10px 0 2px; font-weight: 600; }
.order-line-editor { display: grid; grid-template-columns: 1fr 74px 90px 34px; gap: 8px; margin-bottom: 8px; align-items: center; }
