/* =====================================================================
   STM FinTrack — ธีม "Modern Navy & Gold" (SaaS Dashboard)
   ฟอนต์: Prompt (ภาษาไทย/เนื้อหาหลัก) / Inter (ตัวเลข)
   ===================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Prompt:wght@300;400;500;600;700&display=swap');

:root {
  /* Modern Slate/Navy Palette */
  --navy-900: #0F172A;
  --navy-800: #1E293B;
  --navy-700: #334155;
  --navy-100: #F1F5F9;
  
  /* Vibrant Gold Palette */
  --gold-500: #EAB308;
  --gold-400: #FACC15;
  --gold-100: #FEF9C3;
  
  /* Modern Base Colors */
  --paper: #F8FAFC;
  --surface: #FFFFFF;
  --ink: #0F172A;
  --muted: #64748B;
  --line: #E2E8F0;
  
  /* Semantic */
  --green: #10B981;
  --orange: #F59E0B;
  --red: #EF4444;
  
  /* Structure */
  --radius: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Prompt', sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}
h1, h2, h3 { 
  font-weight: 600; 
  color: var(--navy-900); 
  margin: 0 0 8px; 
  letter-spacing: -0.02em;
}
a { color: var(--navy-800); text-decoration: none; transition: 0.2s ease; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

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

.app-sidebar {
  width: 260px; 
  flex-shrink: 0;
  background: var(--navy-900);
  color: #fff; 
  padding: 24px 20px; 
  display: flex; 
  flex-direction: column;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 32px; }
.brand-seal {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
  color: var(--navy-900);
  display: flex; align-items: center; justify-content: center; 
  font-size: 20px; font-weight: 700;
}
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: 0.5px; }
.brand-sub { font-size: 12px; color: #94A3B8; font-weight: 300; }

.side-nav { display: flex; flex-direction: column; gap: 6px; }
.side-link {
  color: #CBD5E1; padding: 12px 14px; border-radius: 8px; font-size: 14px;
  display: flex; align-items: center; gap: 12px; transition: 0.2s ease;
  font-weight: 400;
}
.side-link .ic { width: 20px; text-align: center; color: #94A3B8; transition: 0.2s; }
.side-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.side-link:hover .ic { color: var(--gold-400); }
.side-link.active { background: var(--navy-800); color: #fff; font-weight: 500; }
.side-link.active .ic { color: var(--gold-400); }

.side-footer { margin-top: auto; padding-top: 20px; font-size: 12px; color: #64748B; }
.side-footer-line { height: 1px; background: rgba(255,255,255,0.1); margin-bottom: 12px; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
  background: var(--surface); 
  border-bottom: 1px solid var(--line);
  padding: 16px 32px; 
  display: flex; align-items: center; justify-content: space-between;
}
.app-topbar-title { font-size: 18px; font-weight: 600; }
.app-topbar-user { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.user-chip { color: var(--navy-800); font-weight: 500; }
.user-chip em { color: var(--muted); font-style: normal; font-weight: 400; }

.app-content { padding: 32px; flex: 1; }
.app-footer { padding: 16px 32px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); background: var(--surface); }

/* ---------- Grid helpers ---------- */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
.mb-24 { margin-bottom: 24px; }
@media (max-width: 900px){ .grid-4 { grid-template-columns: 1fr 1fr; } .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Cards / Panels ---------- */
.panel {
  background: var(--surface); 
  border: 1px solid var(--line); 
  border-radius: var(--radius);
  padding: 24px; 
  box-shadow: var(--shadow-sm);
}
.panel-title { 
  font-size: 16px; 
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 20px; 
}
.panel-title::before {
  content: ''; display: block; width: 4px; height: 16px; 
  background: var(--gold-500); border-radius: 4px;
}
.panel-subtitle { font-size: 14px; margin-top: 16px; color: var(--muted); }

.stat-card {
  background: var(--surface); 
  border: 1px solid var(--line); 
  border-radius: var(--radius); 
  padding: 20px; 
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
.stat-value { font-family: 'Inter', sans-serif; font-size: 28px; font-weight: 700; color: var(--navy-900); letter-spacing: -0.5px; }

/* ---------- Ledger table ---------- */
.ledger-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ledger-table td, .ledger-table th { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; }
.ledger-table th {
  background: #F8FAFC; color: var(--muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
  position: sticky; top: 0; z-index: 10;
  border-bottom: 2px solid var(--line);
}
.ledger-table td { color: var(--navy-800); }
.ledger-table .num { text-align: right; font-family: 'Inter', sans-serif; font-weight: 500; }
.ledger-table.full tbody tr:hover { background: var(--navy-100); }
.row-overdue td { background: #FEF2F2; color: var(--red); }
.table-scroll { overflow-x: auto; margin-top: 16px; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- Status ring ---------- */
.status-ring-wrap { position: relative; max-width: 240px; margin: 0 auto; }
.status-ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-total { font-family: 'Inter', sans-serif; font-size: 28px; font-weight: 700; color: var(--navy-900); }
.ring-total-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.legend-list { list-style: none; padding: 0; margin: 24px 0 0; font-size: 13px; display: flex; flex-direction: column; gap: 10px; }
.legend-list li { display: flex; align-items: center; justify-content: space-between; color: var(--navy-800); }
.legend-list .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 10px; }

/* ---------- Due list ---------- */
.due-list { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 12px; }
.due-list li { display: flex; align-items: center; gap: 12px; font-size: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.due-list li:last-child { border-bottom: none; padding-bottom: 0; }
.due-list a { flex: 1; font-weight: 500; color: var(--navy-800); }
.due-date { font-family: 'Inter', sans-serif; color: var(--muted); font-size: 12px; background: var(--navy-100); padding: 4px 8px; border-radius: 6px; }
.badge { color: #fff; font-size: 11px; padding: 4px 10px; border-radius: 20px; white-space: nowrap; font-weight: 500; }

/* ---------- Forms ---------- */
.form-panel { max-width: 820px; }
.doc-form label { display: block; font-size: 13px; color: var(--navy-700); margin-bottom: 6px; font-weight: 500; }
.form-group { margin-bottom: 20px; flex: 1; }
.form-row { display: flex; gap: 20px; }
.doc-form input[type=text], .doc-form input[type=number], .doc-form input[type=date],
.doc-form input[type=password], .doc-form select, .doc-form textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 14px; background: #fff; color: var(--navy-900);
  transition: all 0.2s ease;
}
.doc-form input:hover, .doc-form select:hover { border-color: #CBD5E1; }
.doc-form input:focus, .doc-form select:focus, .doc-form textarea:focus {
  outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.15);
}
.form-actions { display: flex; gap: 12px; margin-top: 12px; }

.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-bar input[type=text], .filter-bar select { 
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; 
}
.filter-bar input[type=text] { flex: 1; min-width: 240px; }

.status-form { display: inline-block; }
.status-select {
  border: none; border-radius: 20px; padding: 6px 14px; font-size: 12px; color: #fff;
  background: var(--c, var(--navy-800)); font-weight: 500; cursor: pointer; outline: none;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none;
  transition: all 0.2s;
}
.btn-primary { background: var(--navy-900); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--navy-700); transform: translateY(-1px); }
.btn-gold { background: var(--gold-500); color: #fff; box-shadow: var(--shadow-sm); }
.btn-gold:hover { background: var(--gold-400); transform: translateY(-1px); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--navy-700); }
.btn-ghost:hover { background: var(--navy-100); border-color: #CBD5E1; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ---------- Alerts ---------- */
.alert { padding: 14px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; display: flex; align-items: center; gap: 12px; }
.alert-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

/* ---------- Login page ---------- */
.login-body {
  background: var(--navy-900);
  background-image: radial-gradient(circle at top right, var(--navy-700) 0%, transparent 40%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-wrap { padding: 24px; width: 100%; max-width: 400px; }
.login-card {
  background: var(--surface); border: none; border-radius: 16px;
  padding: 40px 32px; text-align: center; box-shadow: var(--shadow-lg);
}
.login-seal { 
  width: 56px; height: 56px; margin: 0 auto 20px; border-radius: 14px;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
  color: var(--navy-900); display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; box-shadow: var(--shadow-sm);
}
.login-title { font-size: 22px; font-weight: 600; color: var(--navy-900); }
.login-sub { font-size: 14px; color: var(--muted); margin-bottom: 32px; }
.login-form { text-align: left; display: flex; flex-direction: column; gap: 16px; }
.login-form label { font-size: 13px; font-weight: 500; color: var(--navy-800); margin-bottom: -10px; }
.login-form input {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #F8FAFC;
}
.login-form input:focus { outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.15); background: #fff; }
.login-footnote { margin-top: 24px; font-size: 12px; color: var(--muted); }
```css


/* =====================================================
   STM FinTrack — Responsive Sidebar Layout
   ===================================================== */

.app-shell {
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.app-sidebar {
  width: 260px;
  min-width: 260px;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0F172A 0%, #172554 100%);
  color: #fff;
  z-index: 1000;
  transition: width .3s ease, min-width .3s ease, transform .3s ease;
  overflow: visible;
}

.brand {
  height: 105px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.10);
  overflow: hidden;
}

.brand-logo {
  width: 64px;
  height: 64px;
  min-width: 64px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,.25);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-seal-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy-900);
  font-size: 26px;
  font-weight: 700;
}

.brand-text {
  min-width: 0;
  white-space: nowrap;
  transition: opacity .2s ease;
}

.brand-name {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: .5px;
}

.brand-sub {
  font-size: 12px;
  color: #94A3B8;
  font-weight: 300;
  margin-top: 2px;
}

.sidebar-toggle {
  position: absolute;
  top: 82px;
  right: -16px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--navy-900);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  box-shadow: 0 3px 12px rgba(0,0,0,.25);
  z-index: 1100;
  transition: transform .2s ease, box-shadow .2s ease;
}

.sidebar-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 5px 18px rgba(0,0,0,.30);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 14px;
}

.side-link {
  color: #CBD5E1;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: .2s ease;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
}

.side-link:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.side-link:hover .ic,
.side-link.active .ic {
  color: var(--gold-400);
}

.side-link.active {
  background: var(--navy-800);
  color: #fff;
  font-weight: 500;
}

.side-link .ic {
  width: 22px;
  min-width: 22px;
  text-align: center;
  color: #94A3B8;
  font-size: 17px;
  transition: .2s ease;
}

.menu-text {
  white-space: nowrap;
}

.side-footer {
  margin-top: auto;
  padding: 20px;
  font-size: 12px;
  color: #64748B;
  overflow: hidden;
}

.side-footer-line {
  height: 1px;
  background: rgba(255,255,255,.10);
  margin-bottom: 12px;
}

.side-footer p {
  margin: 0;
  white-space: nowrap;
}

/* ---------- Main / Header ---------- */

.app-main {
  min-height: 100vh;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left .3s ease;
}

.app-topbar {
  min-height: 72px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 900;
}

.app-topbar-title {
  font-size: 18px;
  font-weight: 600;
}

.app-topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.user-chip {
  color: var(--navy-800);
  font-weight: 500;
}

.user-chip em {
  color: var(--muted);
  font-style: normal;
  font-weight: 400;
}

.app-content {
  padding: 32px;
  flex: 1;
  min-width: 0;
}

/* ---------- Collapsed desktop ---------- */

body.sidebar-collapsed .app-sidebar {
  width: 78px;
  min-width: 78px;
}

body.sidebar-collapsed .app-main {
  margin-left: 78px;
}

body.sidebar-collapsed .brand {
  justify-content: center;
  padding: 16px 8px;
}

body.sidebar-collapsed .brand-logo {
  width: 50px;
  height: 50px;
  min-width: 50px;
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .menu-text,
body.sidebar-collapsed .side-footer p {
  display: none;
}

body.sidebar-collapsed .side-nav {
  padding: 20px 10px;
}

body.sidebar-collapsed .side-link {
  justify-content: center;
  padding: 12px 8px;
}

body.sidebar-collapsed .side-link .ic {
  width: 24px;
  min-width: 24px;
  font-size: 19px;
}

body.sidebar-collapsed .side-footer {
  padding: 15px 5px;
}

/* ---------- Mobile ---------- */

@media (max-width: 768px) {
  .app-sidebar {
    width: 260px;
    min-width: 260px;
    transform: translateX(-100%);
    box-shadow: 5px 0 25px rgba(0,0,0,.20);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .app-main,
  body.sidebar-collapsed .app-main {
    margin-left: 0;
  }

  .app-topbar {
    padding: 14px 18px;
  }

  .app-topbar-title {
    font-size: 16px;
  }

  .app-topbar-user .user-chip {
    display: none;
  }

  .app-content {
    padding: 20px 16px;
  }

  .sidebar-toggle {
    right: -42px;
  }

  body.sidebar-open .sidebar-toggle {
    right: 10px;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 480px) {
  .app-topbar {
    min-height: 64px;
  }

  .app-topbar-user .btn {
    padding: 7px 10px;
    font-size: 12px;
  }

  .app-content {
    padding: 16px 12px;
  }

  .panel {
    padding: 18px;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }
}
