/* ============================================================
   Shona Trade Links — Ledger Workspace
   Design: forest-green sidebar, warm off-white, muted lime accents
   ============================================================ */

/* --- Design Tokens --- */
:root {
  /* Primary palette */
  --forest-900: #0e2f27;
  --forest-800: #123d34;
  --forest-700: #1a5246;
  --forest-600: #1f6354;
  --forest-500: #247562;
  --forest-400: #31584c;
  --forest-300: #4a7d6f;

  /* Neutral palette */
  --sage-100: #f5f7f5;
  --sage-200: #edf0ea;
  --sage-300: #e2e7df;
  --sage-400: #d9e1da;
  --sage-500: #c3d4cd;
  --sage-600: #8fac9f;
  --sage-700: #7c8b83;
  --sage-800: #5a6b62;
  --sage-900: #223a36;

  /* Accent — muted lime */
  --lime-100: #f0f5e2;
  --lime-200: #e8efda;
  --lime-300: #dce9ad;
  --lime-400: #d9e3c9;
  --lime-500: #c4d49a;

  /* Semantic */
  --positive: #2c7654;
  --negative: #b87944;
  --error: #b04632;
  --badge-recv-bg: #eaf3e8;
  --badge-recv: #3a7651;
  --badge-pay-bg: #fff0df;
  --badge-pay: #a36e33;
  --badge-zero-bg: #eef0eb;
  --badge-zero: #859184;

  /* Typography */
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-display: 'Manrope', system-ui, sans-serif;

  /* Layout */
  --sidebar-w: 240px;
  --radius: 12px;
  --radius-sm: 7px;
  --shadow-dialog: 0 25px 100px rgba(18, 61, 52, 0.2);
  --transition: 0.2s ease;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--sage-900);
  background: var(--sage-100);
  line-height: 1.5;
  min-height: 100dvh;
}

/* --- Sidebar --- */
aside#sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--forest-800);
  color: #fff;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: 2px;
  font-size: 16px;
  font-weight: 600;
}

.brand b {
  background: var(--lime-300);
  color: var(--forest-800);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 20px;
  letter-spacing: -2px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.brand small {
  font-size: 9px;
  letter-spacing: 3px;
  font-weight: 500;
  opacity: 0.85;
}

.nav-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--sage-600);
  margin: 48px 10px 16px;
  font-weight: 500;
}

nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: none;
  color: var(--sage-500);
  border: 0;
  padding: 13px 14px;
  margin: 3px 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

nav button:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

nav button.active {
  background: var(--forest-400);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

nav button .nav-icon {
  font-size: 16px;
  opacity: 0.6;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

nav button.active .nav-icon { opacity: 1; }

.aside-foot {
  margin-top: auto;
  padding-top: 24px;
  font-size: 12px;
  color: var(--lime-400);
  line-height: 1.8;
}

.aside-foot small {
  color: var(--sage-600);
  font-size: 10px;
}

/* --- Main --- */
main {
  margin-left: var(--sidebar-w);
  padding: 36px 40px;
  max-width: 1700px;
  min-height: 100dvh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--sage-700);
  font-weight: 500;
}

h1 {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: -1.2px;
  margin: 8px 0 0;
  font-weight: 700;
}

h2 {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: -0.4px;
  font-weight: 600;
}

/* --- Buttons --- */
button, .link {
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  transition: all var(--transition);
}

button {
  border: 1px solid var(--sage-400);
  background: white;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: inherit;
  font-weight: 500;
}

button:hover { filter: brightness(0.96); }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--forest-600);
  outline-offset: 2px;
}

.primary {
  background: var(--forest-700);
  color: white;
  border-color: var(--forest-700);
  padding: 12px 20px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.primary:hover {
  background: var(--forest-600);
  border-color: var(--forest-600);
}

.danger { background: var(--error); border-color: var(--error); }
.danger:hover { filter: brightness(1.1); }

.text-btn {
  padding: 5px 10px;
  border: 0;
  background: var(--sage-200);
  font-size: 11px;
  border-radius: 5px;
  font-weight: 500;
  white-space: nowrap;
}

.text-btn:hover { background: var(--sage-300); }

.link {
  text-decoration: underline;
  font-size: 11px;
  background: none;
  border: none;
  color: inherit;
  padding: 0;
}

/* --- Notice bar --- */
.notice {
  font-size: 11px;
  color: var(--sage-700);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--sage-300);
  padding-bottom: 18px;
  margin-bottom: 26px;
}

.notice button { padding: 5px 10px; font-size: 11px; }

/* --- Summary Cards --- */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 20px 0 28px;
}

.card {
  background: #fff;
  border: 1px solid var(--sage-300);
  border-radius: var(--radius);
  padding: 22px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(18, 61, 52, 0.06);
}

.card.featured {
  background: var(--lime-200);
  border-color: var(--lime-500);
}

.card small {
  font-size: 11px;
  color: var(--sage-700);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: -0.8px;
  margin: 14px 0 6px;
  font-weight: 700;
}

.card p {
  font-size: 11px;
  margin: 0;
  color: var(--sage-700);
}

/* --- Panels --- */
.panel {
  background: white;
  border: 1px solid var(--sage-300);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 18px 22px;
}

.panel-head p, .sub {
  color: var(--sage-700);
  font-size: 12px;
  margin: 6px 0;
  line-height: 1.6;
}

/* --- Controls --- */
.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
  align-items: center;
}

.controls input[type="text"],
.controls input[type="search"] {
  min-width: 240px;
  flex: 1;
  max-width: 380px;
}

/* --- Tables --- */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

th {
  background: var(--sage-100);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sage-700);
  font-weight: 600;
  padding: 14px 18px;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--sage-200);
  line-height: 1.5;
}

tr:last-child td { border-bottom: 0; }

tr:hover td { background: rgba(245, 247, 245, 0.5); }

td.amount, th.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 500;
}

.positive { color: var(--positive); }
.negative { color: var(--negative); }

/* --- Badges --- */
.badge {
  display: inline-block;
  border-radius: 5px;
  font-size: 10px;
  padding: 4px 8px;
  background: var(--badge-recv-bg);
  color: var(--badge-recv);
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge.pay { background: var(--badge-pay-bg); color: var(--badge-pay); }
.badge.zero { background: var(--badge-zero-bg); color: var(--badge-zero); }

.party { font-weight: 600; }
.tiny { font-size: 10px; color: var(--sage-700); margin-top: 2px; }

.empty {
  padding: 48px;
  color: var(--sage-700);
  text-align: center;
  font-size: 13px;
}

/* --- Form elements --- */
input, select, textarea {
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--sage-400);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  color: inherit;
  max-width: 100%;
  transition: border-color var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--forest-600);
}

select { min-width: 180px; }

label {
  font-size: 12px;
  display: block;
  font-weight: 500;
  color: var(--sage-800);
}

label input, label select, label textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
}

/* --- Dialog --- */
dialog {
  border: 0;
  border-radius: 16px;
  padding: 28px;
  width: 580px;
  max-width: 94vw;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-dialog);
}

dialog::backdrop {
  background: rgba(14, 47, 39, 0.45);
  backdrop-filter: blur(2px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.dialog-head button {
  border: 0;
  font-size: 22px;
  background: none;
  color: var(--sage-700);
  padding: 4px 8px;
  border-radius: 6px;
}

.dialog-head button:hover { background: var(--sage-200); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.full { grid-column: 1 / -1; }

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

#modal-error, #confirm-message {
  color: var(--error);
  font-size: 12px;
  min-height: 18px;
}

#confirm-message { color: var(--sage-900); font-size: 13px; line-height: 1.6; }

/* --- Toast --- */
#toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--forest-800);
  color: white;
  padding: 14px 22px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(14, 47, 39, 0.25);
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 1000;
  max-width: 420px;
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* --- Note Templates grid --- */
.templates {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.template {
  padding: 20px;
  background: white;
  border: 1px solid var(--sage-300);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.7;
  transition: box-shadow var(--transition);
}

.template:hover { box-shadow: 0 2px 12px rgba(18, 61, 52, 0.06); }
.template .template-actions { margin-top: 14px; display: flex; gap: 6px; }

.rule {
  background: var(--lime-100);
  padding: 16px 20px;
  font-size: 12px;
  border-radius: 8px;
  margin-bottom: 18px;
  border-left: 3px solid var(--lime-500);
  color: var(--sage-800);
}

/* --- Footer --- */
footer {
  font-size: 10px;
  color: var(--sage-700);
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--sage-200);
}

/* --- Mobile nav toggle --- */
#mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--forest-800);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 18px;
}

.mobile-only { display: none; }

/* --- Print styles for statements --- */
.print-header {
  display: none;
}

/* ============================================================
   Responsive breakpoints
   ============================================================ */

@media (max-width: 1080px) {
  aside#sidebar { width: 200px; }
  main { margin-left: 200px; padding: 28px 24px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .templates { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  #mobile-nav-toggle { display: block; }

  aside#sidebar {
    transform: translateX(-100%);
    width: 260px;
    padding-top: 56px;
  }

  aside#sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }

  main {
    margin-left: 0;
    padding: 60px 16px 24px;
  }

  header { flex-wrap: wrap; }
  h1 { font-size: 24px; }
  .eyebrow { font-size: 8px; }

  .cards { grid-template-columns: 1fr 1fr; }
  .card { padding: 16px; }
  .card strong { font-size: 20px; }

  .templates { grid-template-columns: 1fr; }

  .panel-head { padding: 14px; flex-wrap: wrap; }
  td, th { padding: 10px 12px; }

  .form-grid { grid-template-columns: 1fr; }
  .full { grid-column: auto; }

  .controls input[type="text"],
  .controls input[type="search"] {
    min-width: 0;
    max-width: none;
    width: 100%;
    flex: 1 1 100%;
  }
}

@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
  .brand { font-size: 14px; }
  #new-txn-btn { font-size: 12px; padding: 10px 14px; }
}

/* ============================================================
   Print styles
   ============================================================ */
@media print {
  aside, header button, .notice, .controls, footer, .text-btn, #toast,
  #mobile-nav-toggle, .actions-col {
    display: none !important;
  }

  main {
    margin: 0;
    padding: 0;
  }

  .print-header {
    display: block;
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--sage-300);
  }

  .print-header h2 { font-size: 22px; margin-bottom: 4px; }
  .print-header p { font-size: 12px; color: var(--sage-700); margin: 2px 0; }

  .panel { border: 0; }
  .cards { grid-template-columns: repeat(4, 1fr); }

  body { background: white; font-size: 11px; }
  td, th { padding: 6px 8px; }
  .card { page-break-inside: avoid; }
}

body:not(.signed-in) > aside,body:not(.signed-in) > main,body:not(.signed-in) > #mobile-nav-toggle {display:none!important}
#login-screen {min-height:100vh;display:grid;place-items:center;padding:24px;background:#eff4f4}
#login-form {width:min(100%,420px);background:white;padding:36px;border-radius:20px;box-shadow:0 16px 60px #1232}
#login-form label {display:grid;gap:8px;margin:20px 0;font-weight:600}
#login-form input {width:100%;padding:12px;border:1px solid #ccd5d4;border-radius:8px;font:inherit}
#login-error {color:#a52929;min-height:24px}
.signed-in #login-screen {display:none}
.saving button,.saving input,.saving select {pointer-events:none;opacity:.65}
