@import url('https://fonts.googleapis.com/css2?family=Lora:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #1C2620;
  --paper: #F7F6F2;
  --panel: #FFFFFF;
  --primary: #12221E;
  --primary-light: #1E3831;
  --thu: #2F6F4E;
  --thu-bg: #E9F3EC;
  --chi: #A6402F;
  --chi-bg: #FBEBE7;
  --border: #DDD8CB;
  --muted: #746C5E;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, .brand, .hero-number {
  font-family: 'Lora', Georgia, serif;
}

a { color: inherit; }

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

/* Sidebar */
.sidebar {
  width: 230px;
  background: var(--primary);
  color: #EDEAE1;
  flex-shrink: 0;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  font-size: 19px;
  font-weight: 600;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 12px;
}
.sidebar .brand small { display: block; font-family: 'Inter'; font-size: 12px; color: #B9C4BC; font-weight: 400; margin-top: 4px;}
.sidebar nav { flex: 1; }
.sidebar a.nav-link {
  display: block;
  padding: 11px 20px;
  color: #CBD3CC;
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar a.nav-link.active {
  background: rgba(255,255,255,0.09);
  color: #fff;
  border-left-color: #C9A227;
  font-weight: 600;
}
.sidebar .logout-form { padding: 12px 20px 0; margin-top: auto; }
.sidebar .logout-form button {
  width: 100%; background: transparent; border: 1px solid rgba(255,255,255,0.25);
  color: #EDEAE1; padding: 9px; border-radius: var(--radius); cursor: pointer; font-size: 13px;
}
.sidebar .logout-form button:hover { background: rgba(255,255,255,0.08); }

.main {
  flex: 1;
  padding: 28px 36px 60px;
  max-width: 1100px;
}

.page-title { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

/* Cards */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-card .label { font-size: 12.5px; color: var(--muted); text-transform: none; margin-bottom: 6px; }
.stat-card .value { font-size: 24px; font-weight: 700; font-family: 'Lora', serif; }
.stat-card.thu .value { color: var(--thu); }
.stat-card.chi .value { color: var(--chi); }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 24px;
}
.panel h2 { font-size: 17px; margin: 0 0 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head h2 { margin: 0; }

/* Forms */
form.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 14px; font-family: inherit; background: #FCFBF9; min-width: 160px;
}
.field textarea { min-width: 260px; }
.btn {
  padding: 9px 18px; border-radius: 7px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: 'Inter';
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--ink); }
.btn-danger-text { background: none; border: none; color: var(--chi); cursor: pointer; font-size: 13px; padding: 4px 6px; }
.btn-danger-text:hover { text-decoration: underline; }

.alert { padding: 11px 14px; border-radius: 7px; margin-bottom: 16px; font-size: 13.5px; }
.alert-error { background: var(--chi-bg); color: var(--chi); border: 1px solid #E8C4BB; }
.alert-success { background: var(--thu-bg); color: var(--thu); border: 1px solid #C4DECB; }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { font-size: 12.5px; text-transform: none; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.amount, th.amount { text-align: right; font-variant-numeric: tabular-nums; }
.amount.thu { color: var(--thu); font-weight: 600; }
.amount.chi { color: var(--chi); font-weight: 600; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.tag.thu { background: var(--thu-bg); color: var(--thu); }
.tag.chi { background: var(--chi-bg); color: var(--chi); }
.empty-state { color: var(--muted); font-size: 14px; padding: 20px 0; text-align: center; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--primary); }
.login-card { background: var(--panel); padding: 40px 36px; border-radius: 14px; width: 340px; }
.login-card h1 { font-size: 21px; margin: 0 0 4px; }
.login-card p { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card input { width: 100%; padding: 10px 12px; }
.login-card .btn { width: 100%; margin-top: 6px; }

/* Public page */
.public-wrap { max-width: 760px; margin: 0 auto; padding: 40px 20px 70px; }
.public-header { text-align: center; margin-bottom: 30px; }
.public-header .eyebrow { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.public-header h1 { font-size: 26px; margin: 0 0 6px; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--thu); margin-right: 6px; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.35; } 100% { opacity: 1; } }
.live-indicator { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; justify-content: center; margin-top: 8px; }

.balance-hero { background: var(--primary); color: #F3F1E9; border-radius: 16px; padding: 30px; text-align: center; margin-bottom: 24px; }
.balance-hero .label { font-size: 13px; color: #B9C4BC; margin-bottom: 6px; }
.balance-hero .hero-number { font-size: 40px; font-weight: 700; }
.balance-hero .sub-row { display: flex; justify-content: center; gap: 34px; margin-top: 18px; font-size: 13.5px; color: #D8DED6; }
.balance-hero .sub-row .num { display: block; font-size: 16px; font-weight: 700; color: #fff; font-family: 'Lora'; }

.month-select-row { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.month-select-row select { padding: 7px 10px; border-radius: 7px; border: 1px solid var(--border); font-family: inherit; }

.activity-item { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.activity-item:last-child { border-bottom: none; }
.activity-item .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.footer-note { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 30px; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 10px; }
  .sidebar .brand { display: none; }
  .sidebar nav { display: flex; }
  .sidebar .logout-form { display: none; }
  .main { padding: 20px 16px 50px; }
  .stat-grid { grid-template-columns: 1fr; }
  form.inline-form { flex-direction: column; align-items: stretch; }
  .field input, .field select, .field textarea { min-width: 0; width: 100%; }
}
