:root {
  --bg: #0a1420;
  --bg-panel: #0e2137;
  --bg-card: #122a41;
  --border: #23415e;
  --text: #eef4f9;
  --text-muted: #8fa7bd;
  --navy: #0d3157;
  --navy-strong: #17518a;
  --accent: #d21f1f;
  --accent-strong: #f13b3b;
  --ok: #3ecf8e;
  --warn: #e8935c;
  --error: #ef5b72;
  --radius: 10px;
  font-size: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.mono { font-variant-numeric: tabular-nums; font-family: "SF Mono", Consolas, Menlo, monospace; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85em; }

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: linear-gradient(180deg, var(--navy), var(--bg));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-logo-badge {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border-radius: 8px;
  padding: 5px 10px;
  line-height: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
.brand-logo { height: 26px; width: auto; display: block; }

.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a {
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.92em;
}
.topnav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: var(--text); }
.topnav a.active { background: rgba(210,31,31,0.18); color: var(--accent-strong); }
.topnav a.logout { color: var(--error); }

.content { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.page-header h1 { margin: 0; font-size: 1.5em; }

h2 { font-size: 1.05em; margin: 0 0 12px; color: var(--text); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card-hero { background: linear-gradient(135deg, var(--navy-strong), var(--navy)); border-color: var(--navy-strong); }
.card-small { padding: 10px 14px; }
.card-label { font-size: 0.78em; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.card-value { font-size: 1.6em; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; color: var(--accent-strong); }
.card-small .card-value { font-size: 1.15em; }
.card-sub { font-size: 0.8em; color: var(--text-muted); margin-top: 4px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 780px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel-header h2 { margin: 0; }

.currency-list { list-style: none; padding: 0; margin: 0 0 10px; }
.currency-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); display: inline-block; }
.currency-list li.warn .dot { background: var(--warn); }
.dot-neutral { background: var(--text-muted); }

.tag { font-size: 0.75em; padding: 2px 8px; border-radius: 999px; margin-left: 6px; }
.tag-warn { background: rgba(232,147,92,0.18); color: var(--warn); }
.tag-ok { background: rgba(62,207,142,0.18); color: var(--ok); }
.tag-error { background: rgba(232,99,124,0.18); color: var(--error); }
.tag-muted { background: rgba(255,255,255,0.08); color: var(--text-muted); }

.carryforward-input { width: 90px; }

.note-list { margin: 0; padding-left: 1.2em; }
.note-list li { margin-bottom: 6px; line-height: 1.4; }
.note-list li:last-child { margin-bottom: 0; }

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92em; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.table th { color: var(--text-muted); font-weight: 600; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.03em; }
.table tbody tr:hover { background: rgba(255,255,255,0.04); cursor: pointer; }
.table-compact th, .table-compact td { padding: 6px 8px; }
.row-actions { cursor: default; }
.row-actions form { display: inline; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.92em;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); text-decoration: none; }
.btn-secondary { background: rgba(255,255,255,0.08); color: var(--text); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); text-decoration: none; }
.btn-icon { background: transparent; border: none; color: var(--error); font-size: 1.1em; padding: 4px 8px; cursor: pointer; }
.btn-block { width: 100%; justify-content: center; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filter-bar select, .filter-bar input[type="text"] {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
}
.filter-bar input[type="text"] { flex: 1; min-width: 180px; }

.form-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 900px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; align-items: end; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) {
  .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr 1fr; }
}

label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85em; color: var(--text-muted); margin-bottom: 14px; }
.form-grid label, .form-grid-3 label, .form-grid-4 label { margin-bottom: 0; }
.hint { font-weight: 400; color: var(--text-muted); font-size: 0.85em; }

input[type="text"], input[type="date"], input[type="time"], input[type="number"], input[type="password"], select, textarea {
  background: #0d1e2c;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 0.95em;
  font-family: inherit;
}
textarea { resize: vertical; }

.checkbox-label { flex-direction: row; align-items: center; gap: 8px; font-size: 0.9em; }
.checkbox-label input { width: auto; }

.form-actions { display: flex; gap: 10px; margin-top: 6px; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 0.9em; }
.alert-error { background: rgba(232,99,124,0.15); color: var(--error); border: 1px solid rgba(232,99,124,0.35); }
.alert ul { margin: 0; padding-left: 18px; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 90vh; }
.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-icon { font-size: 2.2em; margin-bottom: 4px; }
.login-card h1 { font-size: 1.3em; margin: 4px 0 2px; }
.login-card label { text-align: left; }

.link { font-size: 0.9em; }
