/* ═══════════════════════════════════════════════════
   MLCHAU Finance v12 — Professional Design System
   ═══════════════════════════════════════════════════ */
:root {
  --navy-950: #0a1628;
  --navy-900: #0f1f3d;
  --navy-800: #1a3260;
  --navy-700: #1e4080;
  --ink: #111927;
  --ink-soft: #2c3e50;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --surface: #ffffff;
  --canvas: #f8fafc;
  --sidebar-bg: #0f1f3d;
  --sidebar-w: 240px;
  --topbar-h: 64px;
  --mint: #10b981;
  --mint-light: #d1fae5;
  --mint-dark: #059669;
  --coral: #f59e0b;
  --coral-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;
  --blue: #3b82f6;
  --blue-light: #dbeafe;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.12);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { color: var(--ink); background: var(--canvas); font-size: 14px; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: none; background: none; }
img { max-width: 100%; }

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

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 100; overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-symbol {
  display: grid; width: 36px; height: 36px;
  place-items: center; border-radius: 10px 10px 10px 3px;
  background: var(--mint); color: var(--navy-950);
  font-family: Georgia, serif; font-size: 22px; flex-shrink: 0;
}
.brand-text { color: #e2e8f0; font-size: 13px; font-weight: 750; letter-spacing: .06em; }
.brand-text em { color: var(--mint); font-style: normal; font-weight: 400; }
.sidebar-nav { padding: 12px 10px; flex: 1; }
.nav-section { margin-bottom: 6px; }
.nav-label {
  padding: 10px 10px 5px;
  color: rgba(255,255,255,.3); font-size: 10px; font-weight: 800; letter-spacing: .14em;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.65); font-size: 13px; font-weight: 600;
  transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(16,185,129,.15); color: var(--mint); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .7; }
.nav-item.active .nav-icon { opacity: 1; }
.sidebar-footer { padding: 14px 10px; border-top: 1px solid rgba(255,255,255,.08); }

/* ── Main content ────────────────────────────────────────── */
.main-wrap { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px;
}
.topbar-title { color: var(--navy-950); font-size: 18px; font-weight: 750; letter-spacing: -.02em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 99px;
  background: var(--canvas); border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 12px; font-weight: 600;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--mint); color: var(--navy-950);
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
}
.page-content { padding: 28px 32px 60px; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 0; margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 750; color: var(--navy-950); }
.card-body { padding: 0 22px 22px; }
.card-body-full { padding: 22px; }

/* ── Metric cards ────────────────────────────────────────── */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.metric-card { padding: 20px 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.metric-card__icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 14px; font-size: 18px; }
.metric-card__label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.metric-card__value { font-size: clamp(22px, 2.5vw, 30px); font-weight: 800; letter-spacing: -.04em; color: var(--navy-950); }
.metric-card__sub { font-size: 11px; color: var(--muted-light); margin-top: 4px; }
.metric-card--mint .metric-card__icon { background: var(--mint-light); }
.metric-card--mint .metric-card__value { color: var(--mint-dark); }
.metric-card--coral .metric-card__icon { background: var(--coral-light); }
.metric-card--coral .metric-card__value { color: #b45309; }
.metric-card--purple .metric-card__icon { background: var(--purple-light); }
.metric-card--purple .metric-card__value { color: var(--purple); }
.metric-card--blue .metric-card__icon { background: var(--blue-light); }
.metric-card--blue .metric-card__value { color: var(--blue); }

/* ── Content grid ────────────────────────────────────────── */
.content-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 16px; }
.content-grid--thirds { grid-template-columns: 1fr 1fr 1fr; }
.full-width { grid-column: 1 / -1; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); color: var(--ink-soft); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: var(--canvas); }
.data-table td:last-child, .data-table th:last-child { text-align: right; }
.amount-pos { color: var(--mint-dark); font-weight: 750; }
.amount-neg { color: #dc2626; font-weight: 750; }
.amount-neu { color: var(--navy-800); font-weight: 750; }

/* ── Form elements ───────────────────────────────────────── */
.form-section { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 18px; }
.form-section .field-full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .field > span { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(16,185,129,.12);
}
.field input::placeholder { color: var(--muted-light); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 700; transition: all .15s; white-space: nowrap; cursor: pointer; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--navy-900); color: #fff; border: 1px solid var(--navy-900); }
.btn-primary:hover { background: var(--navy-800); box-shadow: var(--shadow); }
.btn-mint { background: var(--mint); color: #fff; border: 1px solid var(--mint); }
.btn-mint:hover { background: var(--mint-dark); }
.btn-outline { background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line); }
.btn-outline:hover { border-color: var(--mint); color: var(--mint-dark); }
.btn-danger { background: var(--surface); color: var(--danger); border: 1px solid #fca5a5; }
.btn-danger:hover { background: var(--danger-light); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 11px; }
.btn-icon { width: 36px; padding: 0; }
.btn-full { width: 100%; }

/* ── Badges / Pills ──────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.badge-mint { background: var(--mint-light); color: var(--mint-dark); }
.badge-coral { background: var(--coral-light); color: #b45309; }
.badge-danger { background: var(--danger-light); color: #dc2626; }
.badge-blue { background: var(--blue-light); color: #1d4ed8; }
.badge-purple { background: var(--purple-light); color: #7c3aed; }
.badge-gray { background: var(--line-soft); color: var(--muted); }
.badge-navy { background: #e0e7ff; color: var(--navy-800); }

/* ── Toast / Alert ───────────────────────────────────────── */
.toast { font-size: 13px; min-height: 20px; }
.toast-success { color: var(--mint-dark); }
.toast-error { color: var(--danger); }
.toast-info { color: var(--blue); }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }
.alert-success { background: var(--mint-light); color: var(--mint-dark); border: 1px solid #6ee7b7; }
.alert-error { background: var(--danger-light); color: #dc2626; border: 1px solid #fca5a5; }
.alert-info { background: var(--blue-light); color: #1d4ed8; border: 1px solid #93c5fd; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state { padding: 40px 22px; text-align: center; color: var(--muted); font-size: 13px; }
.empty-state strong { display: block; font-size: 15px; margin-bottom: 6px; color: var(--ink-soft); }

/* ── Data rows (mini list) ───────────────────────────────── */
.data-rows { display: flex; flex-direction: column; }
.data-row-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0; border-bottom: 1px solid var(--line-soft); gap: 12px;
}
.data-row-item:last-child { border-bottom: 0; }
.data-row-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; font-size: 15px; }
.data-row-main { flex: 1; min-width: 0; }
.data-row-title { font-size: 13px; font-weight: 700; color: var(--navy-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-row-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.data-row-amount { font-size: 14px; font-weight: 800; flex-shrink: 0; }

/* ── Chart container ─────────────────────────────────────── */
.chart-wrap { position: relative; min-height: 220px; }

/* ── Period toolbar ──────────────────────────────────────── */
.period-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--canvas); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 18px;
}
.period-bar label { font-size: 12px; font-weight: 700; color: var(--muted); }
.period-bar input, .period-bar select { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; color: var(--ink); background: var(--surface); }

/* ── Moving / Tasks ──────────────────────────────────────── */
.task-item { display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.task-item:last-child { border-bottom: 0; }
.task-item input[type=checkbox] { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--mint); flex-shrink: 0; }
.task-item.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-title { font-size: 13px; font-weight: 600; color: var(--navy-900); }
.task-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.priority-high { color: var(--danger); }
.priority-normal { color: var(--blue); }
.priority-low { color: var(--muted); }

/* ── Progress bar ────────────────────────────────────────── */
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 6px 0; }
.progress-bar { height: 100%; border-radius: 99px; background: var(--mint); transition: width .4s; }

/* ── Section heading ─────────────────────────────────────── */
.section-heading { margin-bottom: 18px; }
.section-heading h1 { font-size: clamp(24px, 3vw, 32px); font-weight: 800; color: var(--navy-950); letter-spacing: -.04em; margin-bottom: 4px; }
.section-heading p { color: var(--muted); font-size: 13px; }
.eyebrow { font-size: 10px; font-weight: 800; letter-spacing: .14em; color: var(--mint); text-transform: uppercase; margin-bottom: 4px; }

/* ── Inline actions ──────────────────────────────────────── */
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ── Changelog ───────────────────────────────────────────── */
.cl-card { margin-bottom: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); overflow: hidden; }
.cl-card--current { border-color: var(--mint); }
.cl-header { display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line-soft); background: var(--canvas); }
.cl-version { padding: 4px 12px; border-radius: 99px; background: var(--navy-900); color: #fff; font-size: 12px; font-weight: 800; }
.cl-card--current .cl-version { background: var(--mint); }
.cl-date { font-size: 12px; color: var(--muted); }
.cl-title { font-size: 16px; font-weight: 750; padding: 14px 22px 0; color: var(--navy-950); }
.cl-items { list-style: none; padding: 12px 22px 18px; display: grid; gap: 7px; }
.cl-items li { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.cl-tag { flex-shrink: 0; padding: 2px 8px; border-radius: 5px; font-size: 10px; font-weight: 800; }
.cl-tag-new { background: var(--mint-light); color: var(--mint-dark); }
.cl-tag-fix { background: var(--coral-light); color: #b45309; }
.cl-tag-change { background: var(--purple-light); color: #7c3aed; }

/* ── Upload drop zone ────────────────────────────────────── */
.upload-zone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 36px 22px; text-align: center; cursor: pointer; transition: all .15s; position: relative; }
.upload-zone:hover { border-color: var(--mint); background: var(--mint-light); }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-zone-icon { font-size: 36px; margin-bottom: 10px; }
.upload-zone-label { font-size: 14px; font-weight: 700; color: var(--navy-900); }
.upload-zone-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Workflow steps ──────────────────────────────────────── */
.steps { display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; align-items: flex-start; gap: 12px; }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--mint-light); color: var(--mint-dark); display: grid; place-items: center; font-size: 11px; font-weight: 800; flex-shrink: 0; }
.step-text { font-size: 13px; color: var(--ink-soft); line-height: 1.55; }

/* ── Login / Auth ─────────────────────────────────────────── */
.auth-page { min-height: 100vh; background: var(--canvas); display: grid; grid-template-columns: 1fr 1fr; }
.auth-brand { background: linear-gradient(145deg, var(--navy-950), var(--navy-800)); display: flex; flex-direction: column; justify-content: space-between; padding: 54px 60px; color: #fff; }
.auth-brand-copy { max-width: 440px; margin: auto 0; }
.auth-brand h1 { font-size: clamp(34px, 4vw, 52px); font-weight: 800; letter-spacing: -.05em; line-height: 1.1; margin-bottom: 18px; }
.auth-brand p { color: #94a3b8; font-size: 15px; line-height: 1.75; }
.auth-form-wrap { display: grid; place-items: center; padding: 40px 60px; background: var(--surface); }
.auth-form-card { width: min(100%, 420px); }
.auth-form-card h2 { font-size: 28px; font-weight: 800; color: var(--navy-950); letter-spacing: -.04em; margin-bottom: 6px; }
.auth-form-card p { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.auth-field { margin-bottom: 16px; }
.auth-field label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.auth-field input { display: block; width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.auth-field input:focus { outline: none; border-color: var(--mint); box-shadow: 0 0 0 3px rgba(16,185,129,.12); }
.auth-field input::placeholder { color: var(--muted-light); }
.pw-wrap { position: relative; }
.pw-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--mint-dark); font-size: 12px; font-weight: 700; }
.auth-btn { width: 100%; height: 48px; background: var(--navy-900); color: #fff; border-radius: var(--radius-sm); font-size: 14px; font-weight: 800; margin-top: 6px; transition: background .15s, box-shadow .15s; }
.auth-btn:hover { background: var(--navy-800); box-shadow: var(--shadow); }
.auth-btn:disabled { opacity: .6; cursor: wait; }
.auth-link { color: var(--mint-dark); font-size: 13px; font-weight: 700; }
.auth-link:hover { text-decoration: underline; }
.auth-msg { font-size: 13px; margin-top: 12px; min-height: 20px; }
.auth-msg-error { color: var(--danger); }
.auth-msg-success { color: var(--mint-dark); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .content-grid--thirds { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); --sidebar-w: 240px; }
  .main-wrap { margin-left: 0; }
  .page-content { padding: 18px 16px 50px; }
  .topbar { padding: 0 16px; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-form-wrap { padding: 30px 20px; }
  .content-grid--thirds { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .form-section { grid-template-columns: 1fr; }
  .form-section .field-full { grid-column: auto; }
}

/* ── v13 additions ─────────────────────────────────────── */
/* OCR parse table: scrollable, wider columns */
.parse-table-wrap { overflow-x: auto; }
.parse-table { min-width: 900px; }
.parse-table th, .parse-table td { padding: 10px 8px; font-size: 12px; white-space: nowrap; vertical-align: middle; }
.parse-table th:nth-child(3), .parse-table td:nth-child(3) { min-width: 200px; white-space: normal; }
.parse-table input, .parse-table select { height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; box-sizing: border-box; }
/* Credit card utilisation */
.cc-card { padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.util-bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.util-fill { height: 100%; border-radius: 99px; }
/* Bill reminder urgency */
.due-urgent { color: var(--danger) !important; font-weight: 750; }
.due-soon { color: #b45309 !important; }
