/* ═══════════════════════════════════════════════════════════
   Aoiro Kaikei — Style Sheet  (polished v2)
   Dark gold bookkeeping theme
═══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0a0e17;
  --surface:    #0d1117;
  --surface2:   #161d2e;
  --surface3:   #1e2840;
  --border:     rgba(255,255,255,.06);
  --border2:    rgba(255,255,255,.11);
  --border3:    rgba(255,255,255,.18);
  --gold:       #c9a84c;
  --gold-dim:   rgba(201,168,76,.26);
  --gold-glow:  rgba(201,168,76,.12);
  --text:       #e8e0d0;
  --text-dim:   #c0b090;
  --text-muted: #6a6a7a;
  --green:      #4a9a6a;
  --green-dim:  rgba(74,154,106,.18);
  --red:        #d9726e;
  --red-dim:    rgba(217,114,110,.18);
  --blue:       #7ab0e0;
  --blue-dim:   rgba(122,176,224,.18);
  --shadow-sm:  0 2px 8px rgba(0,0,0,.4);
  --shadow-md:  0 4px 20px rgba(0,0,0,.5);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.7);
  --radius:     10px;
  --radius-sm:  6px;
  --radius-lg:  14px;
  --ff:         'Hiragino Mincho ProN','Yu Mincho','Noto Serif JP',serif;
  --transition: 150ms ease;
  --border-color: rgba(255,255,255,.06);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff);
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--gold); text-decoration: none; }

/* ── Touch-friendly elements ─────────────────────────────── */
button, a[role="button"], input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::file-selector-button {
  min-height: 44px;
  min-width: 44px;
  padding: 12px 16px;
}

input, textarea, select {
  min-height: 44px;
  font-size: 16px;
}

/* ── Scrollbars ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); }

/* ── Focus ring (accessibility) ──────────────────────────── */
:focus-visible {
  outline: 2px solid var(--gold-dim);
  outline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════
   AUTH PAGE
═══════════════════════════════════════════════════════════ */
.auth-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 0%, rgba(201,168,76,.06) 0%, transparent 60%);
}
.auth-center { width: 100%; max-width: 400px; }
.auth-logo   { text-align: center; margin-bottom: 30px; animation: fadeSlideDown .5s ease; }

.logo-circle {
  width: 62px; height: 62px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e6c060, #6a4c10);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 14px;
  box-shadow: 0 0 0 1px rgba(201,168,76,.3), 0 8px 24px rgba(201,168,76,.2);
}
.logo-title { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: .1em; }
.logo-sub   { font-size: 10px; color: var(--gold); letter-spacing: .22em; margin-top: 5px; }

.lang-switcher {
  position: fixed; top: 16px; right: 16px;
  display: flex; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  background: var(--surface);
}
.lang-btn {
  background: transparent; border: none; color: var(--text-muted);
  padding: 5px 10px; cursor: pointer; font-size: 11px; font-family: var(--ff);
  border-left: 1px solid rgba(255,255,255,.06);
  transition: background var(--transition), color var(--transition);
}
.lang-btn:first-child { border-left: none; }
.lang-btn.active { background: var(--gold-glow); color: var(--gold); }
.lang-btn:hover:not(.active) { background: rgba(255,255,255,.04); color: var(--text-dim); }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 30px 26px;
  box-shadow: var(--shadow-lg);
  animation: fadeSlideDown .4s ease .1s both;
}

.auth-tabs {
  display: flex; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border2); margin-bottom: 24px; height: 42px;
}
.auth-tab {
  flex: 1; border: none; cursor: pointer; font-family: var(--ff);
  font-size: 13px; letter-spacing: .05em; background: transparent;
  color: var(--text-muted); font-weight: 400;
  transition: background var(--transition), color var(--transition);
}
.auth-tab.active { background: var(--surface2); color: var(--gold); font-weight: 600; }
.auth-tab:hover:not(.active) { background: rgba(255,255,255,.03); }

.auth-note { margin-top: 14px; font-size: 10px; color: var(--text-muted); text-align: center; line-height: 1.7; }

/* ══════════════════════════════════════════════════════════
   FORMS (shared)
═══════════════════════════════════════════════════════════ */
.form-group  { margin-bottom: 14px; }
.form-label  {
  display: block; font-size: 11px; color: var(--text-muted);
  margin-bottom: 6px; letter-spacing: .08em;
}
.form-input  {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  font-family: var(--ff);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
.form-input::placeholder { color: rgba(255,255,255,.12); }

.form-error {
  margin-top: 10px; color: var(--red); font-size: 12px;
  background: var(--red-dim); padding: 8px 12px;
  border-radius: var(--radius-sm); border: 1px solid rgba(217,114,110,.3);
  animation: fadeSlideDown .2s ease;
}

.input-pw-wrap { position: relative; }
.input-pw-wrap .form-input { padding-right: 40px; }
.pw-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 14px; padding: 2px; transition: color var(--transition);
}
.pw-toggle:hover { color: var(--text); }

/* ── Primary button ──────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, #8a6c20, #c9a84c);
  border: none; color: #0d1117; padding: 11px 18px;
  border-radius: var(--radius); cursor: pointer; font-size: 13px;
  font-family: var(--ff); font-weight: 700; letter-spacing: .08em;
  box-shadow: 0 4px 16px rgba(201,168,76,.2);
  transition: opacity var(--transition), box-shadow var(--transition), transform 80ms ease;
}
.btn-primary:hover  { opacity: .88; box-shadow: 0 6px 20px rgba(201,168,76,.3); }
.btn-primary:active { transform: scale(.98); }
.btn-wide { width: 100%; margin-top: 18px; }

/* ══════════════════════════════════════════════════════════
   APP HEADER
═══════════════════════════════════════════════════════════ */
.app-header {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
  border-bottom: 1px solid var(--gold-dim);
  padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  height: 54px;
  position: sticky; top: 0; z-index: 200;
  box-shadow: 0 2px 20px rgba(0,0,0,.4);
  gap: 10px;
}

.header-left {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}

.header-right {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
  /* no flex-wrap — keep header on one line */
}

.logo-circle-sm {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 35% 35%, #e6c060, #8a6c20);
  display: flex; align-items: center; justify-content: center; font-size: 14px;
  box-shadow: 0 0 0 1px rgba(201,168,76,.25);
}
.app-title { font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--text); white-space: nowrap; }
.app-sub   { font-size: 8px; color: var(--gold); letter-spacing: .18em; }

.lbl-year { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.sel-sm {
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text); padding: 4px 8px; border-radius: var(--radius-sm);
  font-size: 12px; font-family: var(--ff);
  transition: border-color var(--transition);
  cursor: pointer;
}
.sel-sm:hover  { border-color: var(--border3); }
.sel-sm:focus  { border-color: var(--gold-dim); box-shadow: 0 0 0 2px var(--gold-glow); outline: none; }
.sel-sm option { background: var(--surface2); }

.hdr-actions {
  display: flex; align-items: center; gap: 4px;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  padding: 0 8px;
}
.btn-hdr {
  padding: 4px 9px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 11px; font-family: var(--ff); font-weight: 600; white-space: nowrap;
  transition: opacity var(--transition), filter var(--transition);
  border: 1px solid transparent;
}
.btn-hdr:hover  { opacity: .82; filter: brightness(1.1); }
.btn-hdr:active { opacity: .7; }

.btn-hdr-green {
  background: var(--green-dim); border-color: rgba(74,154,106,.35); color: var(--green);
}
.btn-hdr-blue {
  background: var(--blue-dim); border-color: rgba(122,176,224,.3); color: var(--blue);
}

.lang-switcher-sm {
  display: flex; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid rgba(255,255,255,.1); background: var(--surface);
}

/* ── User menu ───────────────────────────────────────────── */
.user-menu { position: relative; }

.user-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text);
  padding: 5px 10px; border-radius: var(--radius-sm);
  cursor: pointer; font-family: var(--ff); font-size: 12px; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition);
}
.user-btn:hover { background: var(--surface3); border-color: var(--border3); }

.user-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--gold-dim); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
  border: 1px solid var(--gold-dim);
}
.caret { color: var(--text-muted); font-size: 10px; }

.role-badge {
  background: var(--gold-glow); color: var(--gold);
  border: 1px solid var(--gold-dim); border-radius: 4px;
  font-size: 9px; padding: 1px 5px; letter-spacing: .04em;
}

.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  min-width: 176px; z-index: 300;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: none; /* toggled via JS */
  animation: fadeSlideDown .15s ease;
}
.user-dropdown.open { display: block; }

.dropdown-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.dropdown-name { font-weight: 700; color: var(--gold); font-size: 13px; }
.dropdown-role { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.user-dropdown button {
  display: block; width: 100%; text-align: left;
  background: none; border: none; color: var(--text);
  padding: 9px 14px; cursor: pointer;
  font-family: var(--ff); font-size: 12px;
  transition: background var(--transition);
}
.user-dropdown button:hover { background: var(--surface2); }

.dropdown-divider { border: none; border-top: 1px solid var(--border); }
.logout-btn { color: var(--red) !important; }

/* ══════════════════════════════════════════════════════════
   NAV
═══════════════════════════════════════════════════════════ */
.app-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; overflow-x: auto; padding: 0 6px;
  scrollbar-width: none;
}
.app-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  background: none; border: none; color: var(--text-muted);
  padding: 11px 14px; cursor: pointer; font-family: var(--ff);
  font-size: 12px; white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.nav-btn:hover  { color: var(--text-dim); }
.nav-btn.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ══════════════════════════════════════════════════════════
   MAIN / LOADING
═══════════════════════════════════════════════════════════ */
.app-main {
  padding: 22px 20px;
  max-width: 920px;
  margin: 0 auto;
  min-height: calc(100vh - 108px);
}

.loading-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 80px 20px; color: var(--gold);
}
.loading-ring {
  width: 36px; height: 36px;
  border: 3px solid var(--border2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ══════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 12px; color: var(--text-dim);
  letter-spacing: .08em; margin-bottom: 12px; font-weight: 600;
}
.section-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  letter-spacing: .08em; margin-bottom: 18px;
  border-left: 3px solid var(--gold); padding-left: 11px;
  line-height: 1.3;
}

/* ══════════════════════════════════════════════════════════
   KPI GRID
═══════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.kpi-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 14px 16px; border: 1px solid;
  transition: box-shadow var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-sm); }
.kpi-label {
  font-size: 10px; color: var(--text-muted);
  letter-spacing: .12em; margin-bottom: 7px; text-transform: uppercase;
}
.kpi-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ══════════════════════════════════════════════════════════
   MONTHLY CHART
═══════════════════════════════════════════════════════════ */
.chart-bars  { display: flex; align-items: flex-end; gap: 3px; height: 80px; margin-bottom: 6px; }
.chart-month { display: flex; flex-direction: column; align-items: center; gap: 1px; flex: 1; }
.chart-bar-rev {
  background: var(--green); border-radius: 2px 2px 0 0; min-width: 5px;
  transition: height .4s cubic-bezier(.4,0,.2,1);
}
.chart-bar-exp {
  background: #c04040; border-radius: 2px 2px 0 0; min-width: 5px;
  transition: height .4s cubic-bezier(.4,0,.2,1);
}
.chart-mlabel { font-size: 8px; color: var(--text-muted); margin-top: 2px; }
.chart-legend { display: flex; gap: 14px; font-size: 10px; color: var(--text-muted); }
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }

/* ══════════════════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════════════════ */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  padding: 8px 7px; color: var(--text-muted); font-size: 10px;
  letter-spacing: .06em; font-weight: 500; text-align: left;
  border-bottom: 1px solid var(--border2); position: sticky; top: 0;
  background: var(--surface);
}
td {
  padding: 7px 7px; border-bottom: 1px solid var(--border);
  vertical-align: middle; color: var(--text-dim);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover td { background: rgba(255,255,255,.025); color: var(--text); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-nodata { text-align: center; color: var(--text-muted); padding: 30px; font-size: 12px; }

/* ── Table action buttons ────────────────────────────────── */
.tbl-btn {
  background: none; cursor: pointer; font-family: var(--ff); font-size: 11px;
  padding: 3px 8px; border-radius: 4px;
  transition: background var(--transition), color var(--transition);
}
.tbl-btn-edit {
  border: 1px solid var(--border2); color: var(--text-muted);
}
.tbl-btn-edit:hover { border-color: var(--border3); color: var(--text); background: var(--surface2); }
.tbl-btn-del  {
  border: 1px solid rgba(217,114,110,.3); color: var(--red);
  margin-left: 4px;
}
.tbl-btn-del:hover { background: var(--red-dim); }

/* ══════════════════════════════════════════════════════════
   ENTRY FORM
═══════════════════════════════════════════════════════════ */
.mode-toggle {
  display: flex; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border2); margin-bottom: 20px;
}
.mode-btn {
  flex: 1; border: none; background: transparent; color: var(--text-muted);
  padding: 11px; cursor: pointer; font-family: var(--ff); font-size: 13px;
  letter-spacing: .04em;
  transition: background var(--transition), color var(--transition);
}
.mode-btn.active-income  { background: #152b1f; color: var(--green); font-weight: 600; }
.mode-btn.active-expense { background: #2a1414; color: var(--red);   font-weight: 600; }
.mode-btn:hover:not(.active-income):not(.active-expense) { background: rgba(255,255,255,.03); }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 6px;
}
.cat-btn {
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text-dim);
  padding: 7px 6px; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--ff); font-size: 11px; text-align: center;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.cat-btn:hover { border-color: var(--border3); color: var(--text); }
.cat-btn.selected {
  border-color: var(--gold-dim); color: var(--gold);
  background: var(--gold-glow);
}

.preview-box {
  background: rgba(5,8,16,.8); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px; margin: 14px 0;
}
.preview-title { font-size: 10px; color: var(--gold); letter-spacing: .08em; margin-bottom: 10px; }
.preview-row   { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.preview-row:last-child { margin-bottom: 0; }
.preview-side  { font-size: 10px; color: var(--text-muted); }
.preview-name  { font-size: 12px; color: var(--text); margin-top: 1px; }
.preview-amt   { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--gold); }

.btn-submit {
  width: 100%; padding: 13px; border-radius: var(--radius); cursor: pointer;
  font-size: 14px; font-family: var(--ff); font-weight: 700; letter-spacing: .06em;
  margin-top: 14px; border: none;
  transition: opacity var(--transition), transform 80ms ease, box-shadow var(--transition);
}
.btn-submit:hover  { opacity: .88; }
.btn-submit:active { transform: scale(.99); }

.btn-submit-income  {
  background: linear-gradient(135deg, #1a5a3a, #2e9a5c);
  box-shadow: 0 4px 16px rgba(46,154,92,.2);
}
.btn-submit-expense {
  background: linear-gradient(135deg, #5a1f1f, #9a3838);
  box-shadow: 0 4px 16px rgba(154,56,56,.2);
}

/* ── Entry layout ────────────────────────────────────────── */
.entry-layout { max-width: 600px; margin: 0 auto; }
.entry-card   { padding: 20px; }

.entry-row-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}

/* ── Counterpart + company picker ────────────────────────── */
.counterpart-row {
  display: flex; gap: 6px; align-items: stretch;
}
.counterpart-row .form-input { flex: 1; }

.btn-company-pick {
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--gold); font-size: 16px; padding: 0 12px;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.btn-company-pick:hover { background: var(--gold-glow); border-color: var(--gold-dim); }

.company-picker {
  margin-top: 6px; background: var(--surface);
  border: 1px solid var(--gold-dim); border-radius: var(--radius);
  overflow: hidden; animation: fadeSlideDown .15s ease;
  box-shadow: var(--shadow-md);
}
.company-search-input {
  border: none !important; border-bottom: 1px solid var(--border) !important;
  border-radius: 0 !important; font-size: 12px;
}
.company-pick-list {
  max-height: 200px; overflow-y: auto;
}
.company-pick-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; border-bottom: 1px solid var(--border);
  padding: 8px 12px; cursor: pointer; font-family: var(--ff);
  transition: background var(--transition);
  color: var(--text);
}
.company-pick-item:last-child { border-bottom: none; }
.company-pick-item:hover { background: var(--gold-glow); }
.company-pick-name   { font-size: 12px; font-weight: 600; color: var(--text); }
.company-pick-detail { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.company-pick-empty  { padding: 16px; text-align: center; color: var(--text-muted); font-size: 11px; }

/* ── Attachment chips ────────────────────────────────────── */
.attach-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.attach-chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 5px; padding: 3px 8px;
}
.attach-link {
  font-size: 11px; color: var(--gold); text-decoration: none;
}
.attach-link:hover { text-decoration: underline; }
.attach-remove {
  background: none; border: none; color: var(--red); cursor: pointer;
  font-size: 11px; padding: 0 2px; transition: opacity var(--transition);
}
.attach-remove:hover { opacity: .7; }

.btn-attach-pick {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--blue-dim); border: 1px solid rgba(122,176,224,.3);
  color: var(--blue); padding: 5px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 11px; font-family: var(--ff); font-weight: 600;
  transition: opacity var(--transition);
}
.btn-attach-pick:hover { opacity: .82; }

.btn-cancel-entry {
  background: var(--surface); border: 1px solid var(--border2); color: var(--text-muted);
  padding: 11px 14px; border-radius: var(--radius); cursor: pointer;
  font-family: var(--ff); font-size: 13px;
  transition: background var(--transition), color var(--transition);
}
.btn-cancel-entry:hover { background: var(--surface2); color: var(--text); }

/* ══════════════════════════════════════════════════════════
   LEDGER ACCOUNT TABS
═══════════════════════════════════════════════════════════ */
.acct-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; }
.acct-tab {
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text-muted);
  padding: 4px 11px; border-radius: 5px; cursor: pointer;
  font-family: var(--ff); font-size: 11px;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.acct-tab:hover { color: var(--text-dim); border-color: var(--border3); }
.acct-tab.active { border-color: var(--gold-dim); color: var(--gold); background: var(--gold-glow); }

/* ══════════════════════════════════════════════════════════
   P&L
═══════════════════════════════════════════════════════════ */
.pl-section-title {
  font-size: 12px; color: var(--gold); letter-spacing: .08em;
  margin-bottom: 8px; padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.pl-row   { display: flex; justify-content: space-between; padding: 3px 5px; font-size: 12px; }
.pl-total {
  display: flex; justify-content: space-between; padding: 6px 5px;
  font-size: 13px; border-top: 1px solid var(--border);
  margin-top: 4px; font-weight: 600;
}
.pl-net {
  display: flex; justify-content: space-between; font-size: 16px; font-weight: 700;
  padding-top: 12px; margin-top: 12px; border-top: 2px solid var(--gold-dim);
}

/* ══════════════════════════════════════════════════════════
   BALANCE SHEET
═══════════════════════════════════════════════════════════ */
.bs-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 740px; }
.bs-row   {
  display: flex; justify-content: space-between;
  padding: 4px 3px; font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.bs-row:last-child { border-bottom: none; }
.bs-total {
  display: flex; justify-content: space-between;
  padding: 6px 3px; font-size: 13px;
  border-top: 2px solid var(--gold-dim); margin-top: 5px;
  font-weight: 700; color: var(--gold);
}

/* ══════════════════════════════════════════════════════════
   ADMIN PANEL
═══════════════════════════════════════════════════════════ */
.badge-admin {
  background: var(--gold-glow); color: var(--gold);
  border: 1px solid var(--gold-dim); border-radius: 4px;
  font-size: 10px; padding: 2px 7px;
}
.badge-user {
  background: rgba(255,255,255,.04); color: var(--text-muted);
  border: 1px solid var(--border2); border-radius: 4px;
  font-size: 10px; padding: 2px 7px;
}
.admin-action-btn {
  background: none; cursor: pointer; font-family: var(--ff);
  font-size: 10px; padding: 3px 8px; border-radius: 4px;
  margin-left: 4px;
  transition: background var(--transition);
}
.admin-action-btn:first-child { margin-left: 0; }
.admin-btn-promote { border: 1px solid var(--gold-dim); color: var(--gold); }
.admin-btn-promote:hover { background: var(--gold-glow); }
.admin-btn-demote  { border: 1px solid var(--border2); color: var(--text-muted); }
.admin-btn-demote:hover  { background: var(--surface2); }
.admin-btn-pw      { border: 1px solid rgba(122,176,224,.3); color: var(--blue); }
.admin-btn-pw:hover      { background: var(--blue-dim); }
.admin-btn-del     { border: 1px solid rgba(217,114,110,.3); color: var(--red); }
.admin-btn-del:hover     { background: var(--red-dim); }

/* ══════════════════════════════════════════════════════════
   FILTER BAR
═══════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.filter-bar select {
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text);
  padding: 5px 10px; border-radius: var(--radius-sm);
  font-size: 12px; font-family: var(--ff);
  transition: border-color var(--transition);
  cursor: pointer;
}
.filter-bar select:focus { border-color: var(--gold-dim); outline: none; }

/* ══════════════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-lg); padding: 26px 28px;
  max-width: 360px; width: 90%;
  box-shadow: var(--shadow-lg);
  animation: fadeSlideDown .2s ease;
}
.modal-icon  { font-size: 22px; margin-bottom: 10px; }
.modal-title { font-size: 15px; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.modal-sub   { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.modal-btns  { display: flex; gap: 10px; }
.modal-btns > * { flex: 1; }

.btn-modal-cancel {
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text-muted);
  padding: 10px; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--ff); font-size: 13px; text-align: center;
  transition: background var(--transition), color var(--transition);
}
.btn-modal-cancel:hover { background: var(--surface3); color: var(--text); }

.btn-danger {
  background: linear-gradient(135deg, #6a1c1c, #b03030);
  border: none; color: #fff; padding: 10px;
  border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--ff); font-weight: 700; font-size: 13px; text-align: center;
  transition: opacity var(--transition);
}
.btn-danger:hover { opacity: .88; }

/* ══════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════ */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  color: var(--text); padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow-md);
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  opacity: 0; transform: translateY(-8px);
}
.toast.toast-visible {
  opacity: 1; transform: translateY(0);
}
.toast-success { background: #162b1a; border: 1px solid rgba(74,154,74,.4); }
.toast-error   { background: #2a1212; border: 1px solid rgba(200,60,60,.4); }

/* ══════════════════════════════════════════════════════════
   RECENT TRANSACTIONS
═══════════════════════════════════════════════════════════ */
.recent-row {
  display: flex; align-items: center;
  padding: 8px 5px; border-bottom: 1px solid var(--border);
  font-size: 12px; gap: 8px;
  transition: background var(--transition);
}
.recent-row:hover    { background: rgba(255,255,255,.02); }
.recent-row:last-child { border-bottom: none; }
.recent-date { color: var(--text-muted); font-size: 10px; min-width: 68px; flex-shrink: 0; }
.recent-desc { color: var(--text-dim); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-amt-in  { color: var(--green); font-variant-numeric: tabular-nums; font-weight: 600; flex-shrink: 0; }
.recent-amt-out { color: var(--red);   font-variant-numeric: tabular-nums; font-weight: 600; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════
   UTILITY
═══════════════════════════════════════════════════════════ */
.text-gold   { color: var(--gold); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-blue   { color: var(--blue); }
.text-muted  { color: var(--text-muted); }
.text-dim    { color: var(--text-dim); }
.fw700       { font-weight: 700; }
.note        { font-size: 10px; color: var(--text-muted); line-height: 1.75; margin-top: 10px; }

/* ══════════════════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════════════════ */
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Global tweaks ───────────────────────────────────────── */
select option, select optgroup { background: var(--surface2); }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.4); cursor: pointer; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ── iOS safe area support ──────────────────────────────── */
@supports (padding: max(0px)) {
  body { padding-left: max(0px, env(safe-area-inset-left)); padding-right: max(0px, env(safe-area-inset-right)); }
  .app-main { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
}

/* ── Responsive: collapse hdr actions on very small screens ─ */
@media (max-width: 768px) {
  /* ══════════════════════════════════════════════════════════
     HEADER MOBILE
  ═══════════════════════════════════════════════════════════ */
  .app-header {
    height: auto;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .header-left {
    width: 100%;
    gap: 6px;
  }

  .logo-circle-sm {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  .app-title {
    display: none;
  }

  .app-sub {
    font-size: 7px;
  }

  .header-right {
    width: 100%;
    gap: 6px;
    flex-wrap: wrap;
  }

  .lbl-year {
    display: none;
  }

  .sel-sm {
    padding: 6px 6px;
    font-size: 11px;
  }

  .hdr-actions {
    display: none;
  }

  .lang-switcher-sm {
    font-size: 10px;
    border-radius: 4px;
  }

  .lang-btn {
    padding: 3px 6px;
    font-size: 10px;
  }

  .user-btn {
    padding: 6px 8px;
    font-size: 11px;
    gap: 4px;
  }

  .user-avatar {
    width: 18px;
    height: 18px;
    font-size: 9px;
  }

  .role-badge {
    font-size: 8px;
    padding: 1px 4px;
  }

  .user-dropdown {
    min-width: 150px;
    right: -8px;
  }

  /* ══════════════════════════════════════════════════════════
     NAV MOBILE
  ═══════════════════════════════════════════════════════════ */
  .app-nav {
    padding: 0 4px;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-btn {
    padding: 10px 10px;
    font-size: 11px;
    flex-shrink: 0;
    min-width: fit-content;
  }

  /* ══════════════════════════════════════════════════════════
     MAIN CONTENT MOBILE
  ═══════════════════════════════════════════════════════════ */
  .app-main {
    padding: 14px 12px;
    margin: 0;
    min-height: calc(100vh - 54px);
  }

  /* ══════════════════════════════════════════════════════════
     DASHBOARD MOBILE
  ═══════════════════════════════════════════════════════════ */
  .card {
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 8px;
  }

  .section-title {
    font-size: 14px;
    margin-bottom: 12px;
    padding-left: 9px;
  }

  .card-title {
    font-size: 11px;
    margin-bottom: 10px;
  }

  /* ── KPI Grid Mobile ──────────────────────────────────────── */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
  }

  .kpi-card {
    padding: 10px;
    border-radius: 8px;
  }

  .kpi-label {
    font-size: 9px;
    margin-bottom: 4px;
  }

  .kpi-value {
    font-size: 15px;
  }

  /* ── Monthly Chart Mobile ──────────────────────────────────── */
  .chart-bars {
    gap: 2px;
    height: 70px;
    margin-bottom: 8px;
  }

  .chart-bar-rev, .chart-bar-exp {
    min-width: 3px;
    border-radius: 2px 2px 0 0;
  }

  .chart-mlabel {
    font-size: 7px;
    margin-top: 2px;
  }

  .chart-legend {
    gap: 12px;
    font-size: 9px;
    flex-wrap: wrap;
  }

  .chart-legend span {
    gap: 4px;
  }

  /* ── Monthly Table Mobile ──────────────────────────────────── */
  table {
    font-size: 12px !important;
  }

  table thead {
    background-color: var(--surface3) !important;
  }

  table thead tr {
    border-bottom: 2px solid var(--border-color) !important;
  }

  table th {
    font-size: 10px !important;
    font-weight: 600 !important;
    padding: 8px 4px !important;
    text-align: center !important;
  }

  table th:not(:first-child) {
    text-align: right !important;
  }

  table td {
    padding: 8px 4px !important;
    font-size: 12px !important;
  }

  table td:first-child {
    text-align: center !important;
  }

  table td:not(:first-child) {
    text-align: right !important;
  }

  /* ── Recent Transactions Mobile ──────────────────────────────────── */
  .recent-row {
    padding: 10px 0;
    gap: 8px;
    font-size: 11px;
  }

  .recent-date {
    font-size: 10px;
    min-width: 50px;
    flex-shrink: 0;
  }

  .recent-desc {
    font-size: 12px;
    flex: 1;
  }

  .recent-amt-in, .recent-amt-out {
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
  }

  /* ══════════════════════════════════════════════════════════
     FORMS MOBILE
  ═══════════════════════════════════════════════════════════ */
  .form-group {
    margin-bottom: 12px;
  }

  .form-label {
    font-size: 10px;
    margin-bottom: 5px;
  }

  .form-input {
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 6px;
    -webkit-appearance: none;
    appearance: none;
  }

  .form-input:focus {
    box-shadow: 0 0 0 2px var(--gold-glow);
  }

  .form-error {
    font-size: 11px;
    padding: 8px 10px;
    margin-top: 8px;
  }

  .input-pw-wrap .form-input {
    padding-right: 44px;
  }

  .pw-toggle {
    right: 12px;
    font-size: 16px;
    padding: 4px;
  }

  /* ── Entry Form Mobile ──────────────────────────────────── */
  .entry-layout {
    max-width: 100%;
  }

  .entry-row-2 {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .counterpart-row {
    gap: 6px;
    flex-direction: row;
  }

  .counterpart-row .form-input {
    flex: 1;
  }

  .btn-company-pick {
    padding: 0 10px;
    font-size: 16px;
  }

  .btn-submit {
    padding: 14px;
    font-size: 14px;
    margin-top: 16px;
    border-radius: 8px;
    min-height: 44px;
  }

  /* ── Category buttons mobile ──────────────────────────────── */
  .cat-btn {
    padding: 8px 8px;
    font-size: 10px;
    border-radius: 6px;
    flex: 1;
    min-width: 0;
  }

  /* ── Preview box mobile ──────────────────────────────────── */
  .preview-box {
    padding: 10px;
    margin: 12px 0;
    border-radius: 6px;
  }

  .preview-title {
    font-size: 9px;
    margin-bottom: 8px;
  }

  .preview-row {
    margin-bottom: 6px;
    gap: 6px;
  }

  .preview-side {
    font-size: 9px;
  }

  .preview-name {
    font-size: 11px;
  }

  .preview-amt {
    font-size: 12px;
  }

  /* ══════════════════════════════════════════════════════════
     BUTTONS MOBILE
  ═══════════════════════════════════════════════════════════ */
  .btn-primary {
    padding: 12px 14px;
    font-size: 13px;
    width: 100%;
    border-radius: 8px;
  }

  .btn-wide {
    width: 100%;
    margin-top: 14px;
  }

  /* ══════════════════════════════════════════════════════════
     MODALS MOBILE
  ═══════════════════════════════════════════════════════════ */
  .modal-overlay {
    padding: 20px 12px;
  }

  .modal-box {
    max-width: 100%;
    width: 100%;
    padding: 20px 16px;
    border-radius: 12px;
    margin-top: 20px;
    animation: fadeSlideUp .25s ease;
  }

  .modal-icon {
    font-size: 28px;
    margin-bottom: 12px;
  }

  .modal-title {
    font-size: 14px;
    margin-bottom: 6px;
  }

  .modal-sub {
    font-size: 11px;
    margin-bottom: 14px;
  }

  .modal-btns {
    gap: 8px;
    flex-direction: column;
  }

  .modal-btns > * {
    flex: 1;
    padding: 12px;
    font-size: 13px;
  }

  .btn-modal-cancel {
    padding: 12px;
    border-radius: 8px;
  }

  .btn-danger {
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
  }

  /* ══════════════════════════════════════════════════════════
     COMPANY PICKER MOBILE
  ═══════════════════════════════════════════════════════════ */
  .company-picker {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
  }

  .company-pick-list {
    max-height: 300px;
  }

  .company-pick-item {
    padding: 12px 10px;
    font-size: 12px;
  }

  .company-pick-name {
    font-size: 13px;
    margin-bottom: 4px;
  }

  .company-pick-detail {
    font-size: 11px;
    margin-top: 2px;
  }

  .company-search-input {
    padding: 10px 12px !important;
    font-size: 13px;
  }

  /* ══════════════════════════════════════════════════════════
     TOAST MOBILE
  ═══════════════════════════════════════════════════════════ */
  .toast {
    top: 12px;
    right: 12px;
    left: 12px;
    padding: 12px 14px;
    font-size: 12px;
    border-radius: 8px;
  }

  /* ══════════════════════════════════════════════════════════
     SELECT DROPDOWN MOBILE
  ═══════════════════════════════════════════════════════════ */
  select {
    font-size: 14px;
    padding: 10px;
    min-height: 44px;
  }

  /* ══════════════════════════════════════════════════════════
     LOADING SCREEN
  ═══════════════════════════════════════════════════════════ */
  .loading-screen {
    padding: 60px 20px;
  }

  .loading-ring {
    width: 40px;
    height: 40px;
    border-width: 3px;
  }
}
