/* ==========================================================================
   Studio portal — warm paper, ink, and a bill book.
   ========================================================================== */

:root {
  --paper:    #FBF6EE;
  --card:     #FFFDF8;
  --tint:     #F4E9DA;
  --tint-2:   #EFE1CE;
  --line:     #E3D5C2;
  --line-2:   #D3C0A8;
  --ink:      #241A1D;
  --muted:    #6B5A55;
  --plum:     #5C2B3E;
  --plum-soft:#7C4258;
  --saffron:  #D9A227;
  --olive:    #5A7052;
  --clay:     #A8492F;

  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --body:    "Karla", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r-s: 8px;
  --r-m: 12px;
  --r-l: 18px;
  --rail: 232px;
  --shadow: 0 1px 2px rgba(36,26,29,.05), 0 8px 24px -16px rgba(36,26,29,.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 12% 8%, rgba(217,162,39,.07), transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(92,43,62,.06), transparent 46%);
  background-attachment: fixed;
}

a { color: var(--plum); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--plum); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { font-family: var(--display); font-weight: 500; letter-spacing: -.015em; margin: 0; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.eyebrow {
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}

.muted { color: var(--muted); }
.hide { display: none !important; }

/* ------------------------------------------------------------------ shell */

.shell { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  border-right: 1px solid var(--line);
  padding: 26px 18px 26px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  background: rgba(251,246,238,.72);
  backdrop-filter: blur(6px);
}

.mark { display: block; }
.mark b {
  display: block; font-family: var(--display); font-size: 23px;
  font-weight: 600; letter-spacing: -.02em; line-height: 1.1;
}
.mark span { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-s);
  color: var(--ink); font-size: 14.5px; text-decoration: none;
  transition: background .15s ease;
}
.nav a:hover { background: var(--tint); text-decoration: none; }
.nav a.on { background: var(--plum); color: var(--paper); }
.nav a.on .dot { background: var(--saffron); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); flex: 0 0 6px; }

.who { margin-top: auto; border-top: 1px solid var(--line); padding-top: 16px; font-size: 13px; }
.who strong { display: block; font-size: 14px; }
.who button {
  margin-top: 8px; background: none; border: 0; padding: 0;
  color: var(--muted); font-family: var(--body); font-size: 13px; cursor: pointer; text-decoration: underline;
}

.main { flex: 1; min-width: 0; padding: 34px 40px 90px; }
.inner { max-width: 1000px; margin: 0 auto; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.head p { margin: 6px 0 0; color: var(--muted); }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--plum); color: var(--paper);
  border: 1px solid var(--plum);
  padding: 9px 16px; border-radius: 999px;
  font-family: var(--body); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .15s ease, transform .1s ease;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--plum-soft); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--tint); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; padding: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 30px; }
.tile {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-m); padding: 16px 18px;
  position: relative; overflow: hidden;
}
.tile::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line-2);
}
.tile.a::after { background: var(--plum); }
.tile.b::after { background: var(--saffron); }
.tile.c::after { background: var(--clay); }
.tile.d::after { background: var(--olive); }
.tile .k { font-size: 11.5px; letter-spacing: .11em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.tile .v { font-family: var(--mono); font-size: 27px; margin-top: 7px; letter-spacing: -.03em; }

.section { margin-bottom: 34px; }
.section > .bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }

/* ------------------------------------------------------------------- rows */

.list { border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; background: var(--card); }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background .13s ease;
  background: none; width: 100%; text-align: left; font: inherit; color: inherit;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--tint); }
.row.flat { cursor: default; }
.row.flat:hover { background: none; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 500; }
.row .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-family: var(--mono); font-size: 15px; white-space: nowrap; }

.pill {
  font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--tint-2); color: var(--muted); border: 1px solid var(--line-2);
}
.pill.go   { background: #E6EDE2; color: #3D5236; border-color: #C3D3BB; }
.pill.warn { background: #FBF0D8; color: #7A5B12; border-color: #E9D49B; }
.pill.hot  { background: #F8E6DF; color: #8A3A22; border-color: #E5C0B1; }
.pill.cool { background: #E7E7F0; color: #45456A; border-color: #C7C7DA; }

.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 14px; }

.avatar {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  background: var(--tint-2); border: 1px solid var(--line-2);
  display: grid; place-items: center;
  font-family: var(--display); font-size: 15px; color: var(--plum);
}

/* ------------------------------------------------------------------ forms */

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-s);
  background: var(--card); color: var(--ink);
  font-family: var(--body); font-size: 15px;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input.money { font-family: var(--mono); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ------------------------------------------------------------------ sheet */

.veil {
  position: fixed; inset: 0; background: rgba(36,26,29,.42);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 60; animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  background: var(--paper); border: 1px solid var(--line-2);
  border-radius: var(--r-l); width: 100%; max-width: 460px;
  max-height: 88vh; overflow-y: auto; padding: 24px 26px 26px;
  box-shadow: 0 24px 60px -20px rgba(36,26,29,.4);
  animation: rise .2s cubic-bezier(.2,.7,.3,1);
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.sheet h2 { margin-bottom: 18px; }
.sheet .acts { display: flex; gap: 10px; margin-top: 22px; }
.sheet .acts .btn { flex: 1; justify-content: center; }

/* ------------------------------------------------- the bill (the signature) */

.slip-wrap { max-width: 400px; margin: 0 auto; }
.slip {
  background: var(--card);
  border: 1px solid var(--line-2);
  border-bottom: 0;
  border-radius: var(--r-m) var(--r-m) 0 0;
  padding: 26px 26px 22px;
  position: relative;
  box-shadow: var(--shadow);
}
.slip::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: repeating-linear-gradient(90deg, var(--plum) 0 12px, var(--saffron) 12px 24px);
  border-radius: var(--r-m) var(--r-m) 0 0;
}
/* torn bottom edge */
.tear {
  height: 14px;
  background:
    radial-gradient(circle at 7px 0, transparent 6.5px, var(--card) 7px) repeat-x 0 0 / 14px 14px;
  filter: drop-shadow(0 1px 0 var(--line-2));
  margin-top: -1px;
}
.slip .who-line { text-align: center; margin-bottom: 20px; }
.slip .who-line b { font-family: var(--display); font-size: 22px; display: block; letter-spacing: -.02em; }
.slip .who-line span { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.slip .rule { height: 1px; background: var(--line); margin: 18px 0; }
.slip .rule.dash { background: none; border-top: 1px dashed var(--line-2); }
.slip .line { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14px; }
.slip .line .l { color: var(--muted); }
.slip .line .r { font-family: var(--mono); text-align: right; }
.slip .total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.slip .total .l { font-family: var(--display); font-size: 16px; }
.slip .total .r { font-family: var(--mono); font-size: 27px; letter-spacing: -.03em; }
.slip .qr { display: grid; place-items: center; padding: 6px 0 2px; }
.slip .qr canvas, .slip .qr img { width: 176px; height: 176px; image-rendering: pixelated; border-radius: 6px; }
.slip .upi { text-align: center; font-family: var(--mono); font-size: 13px; margin-top: 8px; word-break: break-all; }
.slip .foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 14px; }
.stamp {
  display: inline-block; transform: rotate(-6deg);
  border: 2px solid var(--olive); color: var(--olive);
  font-family: var(--display); font-size: 15px; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 12px; border-radius: 4px; opacity: .85;
}
.stamp.due { border-color: var(--clay); color: var(--clay); }

/* ------------------------------------------------------------------- gate */

.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-box { width: 100%; max-width: 380px; text-align: center; }
.gate-box .mark { margin-bottom: 8px; }
.gate-box .mark b { font-size: 38px; }
.gate-box p.lead { color: var(--muted); margin: 10px 0 28px; }
.gate-box input {
  width: 100%; text-align: center; letter-spacing: .3em; text-transform: uppercase;
  font-family: var(--mono); font-size: 18px; padding: 14px;
  border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--card); color: var(--ink);
}
.gate-box .btn { margin-top: 14px; }
.gate-note { margin-top: 26px; font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------------------ misc */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 11px 20px; border-radius: 999px; font-size: 14px;
  z-index: 90; box-shadow: 0 10px 30px -10px rgba(36,26,29,.6);
  animation: rise .2s ease;
}
.toast.bad { background: var(--clay); }

.loading { padding: 60px 0; text-align: center; color: var(--muted); }
.loading::after {
  content: ""; display: block; width: 22px; height: 22px; margin: 14px auto 0;
  border: 2px solid var(--line-2); border-top-color: var(--plum); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line-2); background: var(--card); color: var(--muted);
  padding: 5px 13px; border-radius: 999px; font-family: var(--body); font-size: 13px; cursor: pointer;
}
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.search {
  width: 100%; padding: 11px 14px; margin-bottom: 16px;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--card); font-family: var(--body); font-size: 15px; color: var(--ink);
}

.kv { display: flex; gap: 24px; flex-wrap: wrap; }
.kv > div .k { font-size: 11.5px; letter-spacing: .11em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kv > div .v { font-family: var(--mono); font-size: 19px; margin-top: 4px; }

.tab-bar { display: none; }

/* ------------------------------------------------------------- responsive */

@media (max-width: 860px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .main { padding: 22px 18px 92px; }
  .rail { display: none; }
  h1 { font-size: 25px; }

  .top {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; border-bottom: 1px solid var(--line);
  }
  .tab-bar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: rgba(251,246,238,.94); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line); padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
  }
  .tab-bar a {
    flex: 1; text-align: center; padding: 7px 2px; border-radius: var(--r-s);
    font-size: 11.5px; letter-spacing: .04em; color: var(--muted); text-decoration: none;
  }
  .tab-bar a.on { color: var(--plum); background: var(--tint); font-weight: 600; }
  .pair { grid-template-columns: 1fr; }
}

@media (min-width: 861px) { .top { display: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .rail, .tab-bar, .top, .btn, .no-print { display: none !important; }
  body { background: #fff; }
  .slip { border: 0; box-shadow: none; }
}
