/* ==================================================================
   Lailatil Account Handler
   Visual direction: a bound ledger book. Ruled paper, ink-dark chrome,
   rosewood accent carried over from the Lailatil brand. Figures are set
   in a tabular mono so columns of taka line up down the page.
   ================================================================== */

:root {
  --ink:        #12211F;
  --ink-2:      #1C302C;
  --ink-soft:   #55645F;
  --ink-faint:  #8A9793;

  --paper:      #EFF1EC;
  --card:       #FFFFFF;
  --rule:       #DCE1D9;
  --rule-soft:  #E9EDE5;

  --brand:      #7C3A3E;
  --brand-dim:  #7C3A3E14;
  --gold:       #B98A2E;

  --in:         #14795C;
  --in-dim:     #14795C14;
  --out:        #B5442C;
  --out-dim:    #B5442C14;
  --flag:       #A9761B;
  --flag-dim:   #A9761B16;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;

  --shadow-1: 0 1px 2px rgba(18,33,31,.05);
  --shadow-2: 0 2px 4px rgba(18,33,31,.05), 0 10px 26px -12px rgba(18,33,31,.16);
  --shadow-3: 0 24px 60px -18px rgba(18,33,31,.4);

  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, 'Hind Siliguri', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display { font-family: Newsreader, Georgia, serif; font-weight: 500; margin: 0; }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
::selection { background: var(--ink); color: var(--paper); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #C9CFC4; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

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

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

.boot {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); font-size: 14px; letter-spacing: .02em;
}

.fade { animation: fade .3s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- Sign in */
.signin-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--ink); padding: 22px;
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(255,255,255,.028) 31px 32px);
}
.signin-card {
  width: 100%; max-width: 372px; background: var(--ink-2);
  border: 1px solid #2A3F3A; border-radius: var(--r-lg); padding: 28px;
}
.signin-mark {
  width: 46px; height: 46px; border-radius: 12px; margin: 0 auto 14px;
  background: linear-gradient(158deg, var(--gold), #7E5D18);
  display: flex; align-items: center; justify-content: center;
  font-family: Newsreader, serif; font-size: 22px; color: #1A1405; font-weight: 600;
}

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

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--ink); color: #E6EAE4;
  display: flex; flex-direction: column; padding: 20px 12px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(158deg, var(--gold), #7E5D18);
  display: flex; align-items: center; justify-content: center;
  font-family: Newsreader, serif; font-weight: 600; font-size: 17px; color: #1A1405;
}
.brand-name { font-family: Newsreader, serif; font-size: 17px; color: #F1F3EC; }
.brand-sub { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: #8C9A95; }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-group {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: #6E7C77; padding: 14px 12px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 12px; border: none; background: transparent; border-radius: var(--r-sm);
  color: #CBD4CF; font-size: 13.5px; font-weight: 500; transition: background .14s, color .14s;
}
.nav-item:hover { background: #FFFFFF10; color: #F1F3EC; }
.nav-item.on { background: #FFFFFF1A; color: #FFFFFF; font-weight: 600; }
.nav-item.on .nav-dot { background: var(--gold); }
.nav-dot { width: 5px; height: 5px; border-radius: 50%; background: #4C5B56; flex-shrink: 0; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid #2A3B37; }
.who { padding: 8px 12px 10px; }
.who-name { font-size: 13px; color: #E6EAE4; font-weight: 600; }
.who-role { font-size: 11px; color: #8C9A95; letter-spacing: .04em; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 16px 28px;
  border-bottom: 1px solid var(--rule); background: #FBFCF9;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 21px; }
.topbar-sub { font-size: 12px; color: var(--ink-soft); }
.page { padding: 24px 28px 64px; max-width: 1240px; width: 100%; margin: 0 auto; flex: 1; }

.menu-btn { display: none; }

/* ---------------------------------------------------------------- Cards */
.card {
  background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--r); box-shadow: var(--shadow-1);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; border-bottom: 1px solid var(--rule-soft);
}
.card-title { font-family: Newsreader, serif; font-size: 16.5px; }
.card-note { font-size: 12px; color: var(--ink-soft); }

.eyebrow {
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600;
}

.grid { display: grid; gap: 14px; }
.g-auto { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.g-2 { grid-template-columns: 1fr 1fr; }
.g-3-1 { grid-template-columns: 2.1fr 1fr; align-items: start; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------------------------------------------------------------- Position strip
   The signature element: every account as a proportional band, so the
   shape of where the money sits is readable at a glance. */
.position {
  background: var(--ink); border-radius: var(--r); padding: 20px 22px; color: #E6EAE4;
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, rgba(255,255,255,.022) 27px 28px);
}
.position-total { font-family: 'IBM Plex Mono', monospace; font-size: 34px; letter-spacing: -.02em; color: #FFF; }
.position-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #FFFFFF12; margin: 16px 0 12px; }
.position-seg { transition: width .5s cubic-bezier(.2,.7,.3,1); min-width: 2px; }
.position-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: #C2CCC7; }
.legend-swatch { width: 9px; height: 9px; border-radius: 2.5px; }
.legend-amt { font-family: 'IBM Plex Mono', monospace; color: #F1F3EC; }

/* ---------------------------------------------------------------- Stats */
.stat { background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); padding: 16px 18px; }
.stat-label { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); font-weight: 600; }
.stat-value { font-family: 'IBM Plex Mono', monospace; font-size: 25px; margin-top: 6px; letter-spacing: -.015em; }
.stat-sub { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.stat.in    { border-left: 3px solid var(--in); }
.stat.out   { border-left: 3px solid var(--out); }
.stat.net   { border-left: 3px solid var(--ink); }
.stat.flag  { border-left: 3px solid var(--flag); }
.v-in { color: var(--in); } .v-out { color: var(--out); } .v-flag { color: var(--flag); }

/* ---------------------------------------------------------------- Forms */
label.lbl {
  display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 6px;
}
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%; background: #FFF; border: 1px solid var(--rule); border-radius: 10px;
  padding: 10px 12px; color: var(--ink); transition: border-color .14s, box-shadow .14s;
}
textarea { resize: vertical; min-height: 68px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-dim);
}
input:disabled, select:disabled { background: #F4F6F1; color: var(--ink-faint); }
input.money { font-family: 'IBM Plex Mono', monospace; font-size: 16px; }
.field { margin-bottom: 14px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fields-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 5px; }

.dark-field {
  background: #12211F; border-color: #33463F; color: #EEF1EA;
}
.dark-field:focus { border-color: var(--gold); box-shadow: 0 0 0 3px #B98A2E22; }

/* ---------------------------------------------------------------- Buttons */
.btn {
  border: 1px solid var(--rule); background: #FFF; color: var(--ink);
  border-radius: 10px; padding: 9px 15px; font-weight: 600; font-size: 13.5px;
  transition: background .14s, border-color .14s, transform .1s;
}
.btn:hover { background: #F6F8F3; border-color: #C8D0C3; }
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #F1F3EC; }
.btn.primary:hover { background: #1C302C; }
.btn.accent { background: var(--brand); border-color: var(--brand); color: #FFF; }
.btn.accent:hover { background: #6A3034; }
.btn.on { background: var(--ink); border-color: var(--ink); color: #F1F3EC; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.wide { width: 100%; justify-content: center; padding: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.danger { color: var(--out); border-color: transparent; background: transparent; }
.btn.danger:hover { background: var(--out-dim); border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #00000008; }

.seg { display: inline-flex; background: #E7EAE3; border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  border: none; background: transparent; padding: 7px 14px; border-radius: 8px;
  font-weight: 600; font-size: 13px; color: var(--ink-soft);
}
.seg button.on { background: #FFF; color: var(--ink); box-shadow: var(--shadow-1); }
.seg.big button { padding: 11px 0; flex: 1; }
.seg.big button.on.income { background: var(--in-dim); color: var(--in); box-shadow: inset 0 0 0 1px var(--in); }
.seg.big button.on.expense { background: var(--out-dim); color: var(--out); box-shadow: inset 0 0 0 1px var(--out); }

/* ---------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th {
  text-align: left; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 700; padding: 10px 14px;
  border-bottom: 1px solid var(--rule); white-space: nowrap; background: #FBFCF9;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFBF7; }
td.num, th.num { text-align: right; font-family: 'IBM Plex Mono', monospace; white-space: nowrap; }
td.tight { white-space: nowrap; }
.sub { font-size: 11.5px; color: var(--ink-faint); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.tag.in { background: var(--in-dim); color: var(--in); }
.tag.out { background: var(--out-dim); color: var(--out); }
.tag.flag { background: var(--flag-dim); color: var(--flag); }
.tag.quiet { background: #EDEFE9; color: var(--ink-soft); }
.tag.brand { background: var(--brand-dim); color: var(--brand); }

.bar-track { height: 6px; border-radius: 999px; background: #EDEFE9; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }

.empty { padding: 44px 20px; text-align: center; color: var(--ink-soft); }
.empty-title { font-family: Newsreader, serif; font-size: 17px; color: var(--ink); margin-bottom: 6px; }

.notice {
  border-radius: 10px; padding: 11px 14px; font-size: 12.5px; line-height: 1.55;
  border: 1px solid; display: flex; gap: 9px;
}
.notice.info { background: #F3F6F0; border-color: var(--rule); color: var(--ink-soft); }
.notice.warn { background: var(--flag-dim); border-color: #E4D2A9; color: #6E4C0C; }
.notice.err  { background: var(--out-dim); border-color: #EBC4BA; color: #8A3220; }

/* ---------------------------------------------------------------- Bills */
.bill-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.bill-thumb {
  width: 74px; height: 74px; border-radius: 9px; border: 1px solid var(--rule);
  object-fit: cover; background: #F4F6F1; cursor: pointer; display: block;
}
.bill-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  border: 1px solid var(--rule); border-radius: 999px; font-size: 12px; background: #FFF;
}
.dropzone {
  border: 1.5px dashed var(--rule); border-radius: var(--r); padding: 20px;
  text-align: center; background: #FBFCF9; transition: border-color .14s, background .14s;
}
.dropzone.hot { border-color: var(--brand); background: var(--brand-dim); }

/* ---------------------------------------------------------------- Modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(18,33,31,.5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 60;
  animation: fade .16s ease both; overflow-y: auto;
}
.modal {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg);
  width: 100%; max-width: 520px; box-shadow: var(--shadow-3); max-height: 90vh;
  display: flex; flex-direction: column; margin: auto;
}
.modal.wide { max-width: 760px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--rule-soft); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 15px 22px; border-top: 1px solid var(--rule-soft); display: flex; gap: 10px; justify-content: flex-end; }
.x-btn { border: none; background: transparent; font-size: 20px; line-height: 1; color: var(--ink-soft); padding: 4px 8px; border-radius: 6px; }
.x-btn:hover { background: #00000008; color: var(--ink); }

.lightbox {
  position: fixed; inset: 0; background: rgba(10,18,17,.92); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 20px; flex-direction: column; gap: 14px;
}
.lightbox img { max-width: 100%; max-height: 82vh; border-radius: 10px; }

/* ---------------------------------------------------------------- Toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: #F1F3EC; padding: 12px 20px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; z-index: 90; box-shadow: var(--shadow-3);
  animation: fade .18s ease both; max-width: calc(100vw - 32px);
}
.toast.bad { background: var(--out); }
.toast.good { background: var(--in); }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; flex-direction: row; align-items: center;
    padding: 10px 12px; gap: 10px; overflow-x: auto;
  }
  .brand { padding: 0 8px 0 4px; }
  .brand-text, .nav-group, .sidebar-foot .who { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav-item { white-space: nowrap; padding: 8px 11px; font-size: 12.5px; }
  .nav-dot { display: none; }
  .sidebar-foot { margin-top: 0; padding-top: 0; border: none; margin-left: auto; }
  .topbar { padding: 13px 16px; }
  .topbar h1 { font-size: 18px; }
  .page { padding: 16px 14px 56px; }
  .g-2, .g-3-1, .fields-2, .fields-3 { grid-template-columns: 1fr; }
  .position-total { font-size: 28px; }
  .modal { max-height: 94vh; }
}

@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  body { background: #FFF; }
  .card { box-shadow: none; border-color: #CCC; }
}
