:root {
  --wood-1: #1c120d;
  --wood-2: #2f1d13;
  --wood-3: #4b2d1a;
  --ink: #2c1d12;
  --paper: #e8d9ba;
  --paper-soft: #f2e7cd;
  --paper-edge: #d2bd95;
  --brass: #a8702d;
  --brass-dark: #7d511f;
  --olive: #5d6b39;
  --danger: #7d2b23;
  --warning: #996620;
  --muted: #6a594b;
  --white: #fff8ee;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(183, 111, 44, 0.18), transparent 24%),
    radial-gradient(circle at 80% 0%, rgba(183, 111, 44, 0.12), transparent 20%),
    linear-gradient(90deg, rgba(255,255,255,0.02) 0, rgba(255,255,255,0.00) 40px),
    linear-gradient(180deg, var(--wood-2), var(--wood-1));
  background-size: auto, auto, 80px 100%, 100% 100%;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea {
  font: inherit;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: 'Cormorant Garamond', serif;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brass-dark);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.app-shell {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
}

.sidebar {
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  background: linear-gradient(180deg, rgba(36,21,13,0.95), rgba(25,14,9,0.97));
  border: 1px solid rgba(196, 145, 73, 0.18);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar::before,
.login-card::before,
.panel::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
}

.sidebar-head {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(196,145,73,0.16);
  color: #f2dcc0;
}

.brand-mark {
  width: 62px;
  height: 62px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #b98540, #7d4b1d);
  color: #fff7eb;
  font-family: 'Cormorant Garamond', serif;
  font-size: 34px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 10px 18px rgba(0,0,0,0.18);
}
.brand-mark.small { width: 48px; height: 48px; font-size: 26px; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: #e9d7bd;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: .2s ease;
}
.sidebar-link:hover,
.sidebar-link.is-active {
  background: rgba(215, 171, 105, 0.08);
  border-color: rgba(196,145,73,0.25);
  transform: translateX(2px);
}
.sidebar-icon { width: 22px; text-align: center; color: #cb9b52; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(196,145,73,0.16);
  color: #f0dfc5;
}
.sidebar-foot span,
.small-muted,
.muted-row { color: #b8a387; font-size: 13px; }

.main-shell {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: rgba(232, 217, 186, 0.94);
  border: 1px solid rgba(125,81,31,0.16);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.topbar h1 { font-size: 42px; color: #2f1f13; }
.mobile-nav-toggle { display: none; }

.content-shell {
  padding: 24px 0 40px;
}

.panel,
.stat-card,
.login-card {
  position: relative;
}
.panel {
  background: linear-gradient(180deg, var(--paper-soft), var(--paper));
  border: 1px solid rgba(125,81,31,0.20);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
}
.panel::before,
.login-card::before {
  border: 1px solid rgba(255,255,255,0.34);
  inset: 10px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.panel-head h3 { font-size: 32px; }

.dashboard-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.stat-card {
  background: linear-gradient(160deg, rgba(242,231,205,0.95), rgba(226, 207, 171, 0.96));
  border: 1px solid rgba(125,81,31,0.16);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.stat-card.wide { grid-column: span 2; }
.stat-label { display: block; font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.stat-card strong { font-size: 34px; font-family: 'Cormorant Garamond', serif; }

.page-grid,
.panel-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .95fr);
}
.page-grid.two-rows { grid-template-columns: minmax(0, 1.35fr) minmax(320px, .95fr); }
.page-grid.two-rows .tall { grid-row: span 2; }
.panel-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.table-wrap { overflow-x: auto; }
.ledger-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
.ledger-table th,
.ledger-table td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(125,81,31,0.14);
  vertical-align: top;
}
.ledger-table th {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}
.ledger-table tbody tr:hover { background: rgba(255,255,255,0.28); }

.stack-form { display: flex; flex-direction: column; gap: 14px; }
.stack-form label { display: flex; flex-direction: column; gap: 8px; font-weight: 600; }
.stack-form span { color: #473221; }
input, select, textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(92,57,27,0.18);
  background: rgba(255, 251, 243, 0.72);
  color: var(--ink);
  padding: 14px 16px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(168,112,45,0.65);
  box-shadow: 0 0 0 4px rgba(168,112,45,0.11);
}
textarea { resize: vertical; min-height: 110px; }
.two-col {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(180deg, #9a6428, #724117);
  color: var(--white);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 12px 24px rgba(57, 28, 8, 0.24);
}
.btn-secondary {
  background: linear-gradient(180deg, #f5ead2, #dbc49d);
  color: #3b2415;
  border: 1px solid rgba(125,81,31,0.18);
}
.btn-ghost {
  background: rgba(255,255,255,0.4);
  color: #4a301c;
  border: 1px solid rgba(125,81,31,0.18);
}
.btn-small { padding: 10px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.alert {
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 16px;
  font-weight: 600;
  border: 1px solid rgba(0,0,0,0.08);
}
.alert-success { background: rgba(93,107,57,0.15); color: #30411c; }
.alert-danger { background: rgba(125,43,35,0.12); color: #5f1812; }
.alert-warning { background: rgba(153,102,32,0.12); color: #69420c; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-success { background: rgba(93,107,57,0.14); color: #324217; }
.badge-warning { background: rgba(153,102,32,0.15); color: #71490f; }
.badge-danger { background: rgba(125,43,35,0.16); color: #6d1f19; }
.badge-muted { background: rgba(72,55,40,0.10); color: #4d3b2d; }

.subsection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}
.subsection-head h4 { font-size: 24px; }
.dynamic-lines { display: flex; flex-direction: column; gap: 10px; }
.dynamic-line {
  display: grid;
  gap: 10px;
  grid-template-columns: 1.3fr .8fr .7fr;
}
.dynamic-line-sale {
  grid-template-columns: 1.2fr .9fr .7fr .8fr;
}
.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.small-input { max-width: 110px; padding: 10px 12px; }
.settings-boxes {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.setting-box, .profile-card {
  border-radius: 16px;
  padding: 18px;
  background: rgba(255,255,255,0.36);
  border: 1px solid rgba(125,81,31,0.14);
}
.setting-box strong { display: block; margin-top: 8px; font-size: 28px; font-family: 'Cormorant Garamond', serif; }
.profile-card { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-shell {
  width: min(1120px, 100%);
}
.login-card {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  min-height: 650px;
  border-radius: 34px;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0,0,0,0.35);
  background:
    linear-gradient(120deg, rgba(36, 23, 15, 0.9), rgba(52, 31, 17, 0.88)) 0 0 / 44% 100% no-repeat,
    linear-gradient(180deg, #f0e1c3, #e0cfab);
}
.login-brand {
  padding: 56px;
  color: #f3e3c6;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}
.login-brand h1 { font-size: 68px; line-height: .95; }
.lede { font-size: 18px; color: #dcc6a6; max-width: 460px; line-height: 1.6; }
.brand-notes { display: grid; gap: 16px; margin-top: 10px; }
.brand-note {
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}
.brand-note span { display: block; color: #b99667; text-transform: uppercase; letter-spacing: .18em; font-size: 11px; margin-bottom: 6px; }
.brand-note strong { font-family: 'Cormorant Garamond', serif; font-size: 26px; }

.login-form-wrap {
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.form-plaque {
  align-self: flex-start;
  margin-bottom: 24px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(125,81,31,0.10);
  color: #613d1e;
  font-weight: 700;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.form-footnote { color: var(--muted); margin-top: 18px; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; inset: 18px auto 18px 18px; width: min(320px, calc(100vw - 36px)); transform: translateX(-120%); transition: transform .25s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-nav-toggle { display: inline-flex; }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-grid, .panel-grid.cols-2, .page-grid.two-rows { grid-template-columns: 1fr; }
  .stat-card.wide { grid-column: span 1; }
  .login-card { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar h1 { font-size: 34px; }
  .login-brand, .login-form-wrap, .panel, .topbar { padding: 22px; }
  .login-brand h1 { font-size: 50px; }
  .dashboard-grid, .two-col, .dynamic-line, .dynamic-line-sale, .settings-boxes { grid-template-columns: 1fr; }
}
