:root {
  --bg: #10171f;
  --bg-soft: #141d26;
  --surface: #18232d;
  --surface-2: #1d2a35;
  --surface-3: #23333f;
  --border: rgba(180, 202, 211, .15);
  --border-strong: rgba(191, 211, 219, .26);
  --line: rgba(180, 202, 211, .10);
  --text: #edf3f4;
  --muted: #9aabb5;
  --muted-2: #748692;
  --yellow: #ddb466;
  --yellow-soft: rgba(221, 180, 102, .14);
  --blue: #5b9bb8;
  --blue-soft: rgba(91, 155, 184, .15);
  --green: #57b88a;
  --green-soft: rgba(87, 184, 138, .14);
  --red: #dc737d;
  --red-soft: rgba(220, 115, 125, .14);
  --purple: #9b89bd;
  --purple-soft: rgba(155, 137, 189, .14);
  --cyan: #63b5b3;
  --cyan-soft: rgba(99, 181, 179, .14);
  --shadow: 0 18px 50px rgba(3, 10, 15, .30);
  --radius: 14px;
  --sidebar: 256px;
  --topbar: 64px;
}

* { box-sizing: border-box; }
html { min-height: 100%; overflow-x: hidden; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { outline: none; }
/* Keyboard focus must stay visible, but only for controls that have no other
 * affordance. Text fields are excluded on purpose: their wrapper
 * (.search-control, .month-picker) already paints a soft focus ring, and
 * keeping the generic outline as well drew a hard square box around a rounded
 * field every time it was clicked, on top of the wrapper's own glow. */
button:focus-visible, a:focus-visible, select:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}
input:focus-visible, textarea:focus-visible { outline: none; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.hidden-field { display: none !important; }
.accent, .yellow-text { color: var(--yellow); }
.green-text, .tone-text-green { color: var(--green); }
.red-text, .tone-text-red, .tone-text-danger { color: var(--red); }
.blue-text, .tone-text-blue, .tone-text-info { color: #60a5fa; }
.muted, .tone-text-muted { color: var(--muted); }
.small-copy { font-size: 12px; line-height: 1.7; }

/* Shared controls */
.icon { display: inline-flex; align-items: center; justify-content: center; line-height: 1; font-style: normal; }
.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 15px;
  font-weight: 650;
  white-space: nowrap;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #17120a; background: var(--yellow); box-shadow: 0 8px 22px rgba(240, 185, 11, .15); }
.btn-primary:hover { background: #ffc72c; box-shadow: 0 10px 26px rgba(240, 185, 11, .24); }
.btn-secondary { color: var(--text); background: var(--surface-3); border-color: var(--border); }
.btn-secondary:hover { border-color: rgba(240, 185, 11, .65); color: var(--yellow); }
.btn-light { color: #17120a; background: #fff; }
.btn-light:hover { background: #f3f4f6; }
.btn-ghost-light { color: rgba(255, 255, 255, .86); background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); }
.btn-ghost-light:hover { background: rgba(255, 255, 255, .14); }
.btn-danger-ghost { color: var(--red); background: rgba(246, 70, 93, .08); border-color: rgba(246, 70, 93, .28); }
.btn-danger-ghost:hover { background: rgba(246, 70, 93, .15); }
.btn-small { min-height: 32px; padding: 5px 11px; font-size: 12px; }
.btn-wide { width: 100%; }
.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.icon-btn:hover { color: var(--yellow); background: var(--yellow-soft); border-color: rgba(240, 185, 11, .25); }
.theme-toggle { flex: 0 0 auto; }
.theme-icon { display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.theme-icon-moon { display: none; }
.icon-btn.danger:hover { color: var(--red); background: rgba(246, 70, 93, .11); border-color: rgba(246, 70, 93, .25); }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 650; white-space: nowrap; }
.badge-success { color: #6ee7a0; background: rgba(34, 197, 94, .13); }
.badge-danger { color: #ff8c9b; background: rgba(246, 70, 93, .13); }
.badge-warning { color: #fbd86a; background: rgba(240, 185, 11, .14); }
.badge-info { color: #8fc1ff; background: rgba(59, 130, 246, .14); }
.badge-muted { color: var(--muted); background: rgba(141, 150, 165, .14); }
.encryption-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 7px; color: #9be7bc; background: rgba(34, 197, 94, .10); font-size: 11px; white-space: nowrap; }
.eyebrow { display: block; color: var(--muted-2); font-size: 10px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.text-link { display: inline-flex; align-items: center; gap: 4px; color: var(--yellow); font-size: 12px; font-weight: 650; }
.text-link:hover { color: #ffd75a; }

/* Authentication — a plain, centred account form. The screen intentionally
 * carries no descriptive copy about what the workspace stores. */
.auth-shell { position: relative; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; overflow: hidden; }
.auth-backdrop { position: absolute; inset: 0; pointer-events: none; }
.auth-glow { position: absolute; width: 60vw; height: 60vw; min-width: 420px; min-height: 420px; border-radius: 50%; filter: blur(10px); opacity: .5; }
.auth-glow-a { top: -24vw; left: -14vw; background: radial-gradient(circle at 50% 50%, rgba(240, 185, 11, .20), transparent 62%); }
.auth-glow-b { right: -20vw; bottom: -26vw; background: radial-gradient(circle at 50% 50%, rgba(91, 155, 184, .22), transparent 62%); }
.auth-grid { position: absolute; inset: 0; opacity: .5; background-image: linear-gradient(to right, var(--line) 1px, transparent 1px), linear-gradient(to bottom, var(--line) 1px, transparent 1px); background-size: 56px 56px; mask-image: radial-gradient(circle at 50% 42%, #000 0%, transparent 72%); -webkit-mask-image: radial-gradient(circle at 50% 42%, #000 0%, transparent 72%); }
.auth-corner { position: absolute; top: 20px; right: 20px; z-index: 3; }
.auth-card {
  position: relative;
  z-index: 2;
  width: min(100%, 396px);
  padding: 38px 34px 34px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: auth-rise .45s cubic-bezier(.22, .68, .3, 1) both;
}
@keyframes auth-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .auth-card { animation: none; } }
.auth-mark {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 22px; color: #17120a; background: var(--yellow); border-radius: 12px; font-size: 22px; font-weight: 800;
}
.auth-card h1 { margin: 0 0 6px; font-size: 23px; line-height: 1.25; letter-spacing: 0; }
.auth-copy { color: var(--muted); margin: 0 0 26px; font-size: 13px; }
.auth-card .stack-form { gap: 15px; }
.auth-card label { color: var(--muted) !important; }
.auth-card .btn-wide { justify-content: center; height: 44px; margin-top: 4px; }
.stack-form { display: flex; flex-direction: column; gap: 17px; }
.stack-form label, .form-grid label { display: flex; flex-direction: column; gap: 7px; color: #c4cad3; font-size: 12px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  color: var(--text);
  background: #11151b;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 10px 12px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input::placeholder, textarea::placeholder { color: #596473; }
input:hover, select:hover, textarea:hover { border-color: rgba(255, 255, 255, .28); }
input:focus, select:focus, textarea:focus { border-color: rgba(240, 185, 11, .75); box-shadow: 0 0 0 3px rgba(240, 185, 11, .10); background: #141920; }
textarea { resize: vertical; min-height: 100px; line-height: 1.7; }
select { appearance: auto; }
.auth-key-warning { display: flex; align-items: flex-start; gap: 8px; padding: 10px 11px; margin-top: 16px; color: #f3d783; border: 1px solid rgba(240, 185, 11, .24); border-radius: 8px; background: rgba(240, 185, 11, .07); font-size: 10px; line-height: 1.6; }
.auth-key-warning .icon { flex: 0 0 auto; color: var(--yellow); margin-top: 2px; }

/* App frame and navigation */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column; width: var(--sidebar); background: #0b0e11; border-right: 1px solid #20262e; }
.brand-row { height: 80px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px 0 24px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--yellow); font-size: 23px; font-weight: 800; }
.brand .icon { font-size: 27px; }
.side-caption, .side-section-label { padding: 0 24px; color: #606b7b; font-size: 10px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.side-caption { margin: 8px 0 16px; }
.side-section-label { margin: 27px 0 10px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; padding: 0 12px; }
.nav-item { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border-radius: 11px; color: #c7cdd6; font-size: 13px; font-weight: 600; transition: color .18s ease, background .18s ease; }
.nav-item .icon { width: 20px; color: #8d96a5; font-size: 17px; }
.nav-item:hover { color: var(--yellow); background: rgba(255, 255, 255, .045); }
.nav-item:hover .icon, .nav-item.active .icon { color: var(--yellow); }
.nav-item.active { color: var(--yellow); background: #1d2939; }
.sidebar-footer { margin-top: auto; padding: 16px; border-top: 1px solid #20262e; }
.secure-status { display: flex; align-items: center; gap: 7px; margin-bottom: 15px; color: #8490a0; font-size: 11px; }
.status-dot { width: 7px; height: 7px; display: inline-block; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(34, 197, 94, .10); }
.user-mini { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar { width: 31px; height: 31px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: #17120a; background: var(--yellow); border-radius: 50%; font-size: 12px; font-weight: 800; }
.user-mini strong, .user-mini small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-mini strong { color: #dce1e8; font-size: 12px; }
.user-mini small { color: var(--muted-2); font-size: 10px; }
.logout-form { margin-left: auto; }
.mobile-menu, .mobile-close, .sidebar-backdrop { display: none; }
.main-shell { width: calc(100% - var(--sidebar)); min-width: 0; min-height: 100vh; margin-left: var(--sidebar); }
.topbar { height: var(--topbar); display: flex; align-items: center; gap: 18px; padding: 0 32px; border-bottom: 1px solid #20262e; background: rgba(11, 14, 17, .93); }
/* .topbar-search is defined once further down, in the shared search-control
 * block. The duplicate that used to live here (36px pill, 999px radius) was
 * overridden by it and only made the effective styles harder to find. */
.topbar-meta { display: flex; align-items: center; gap: 18px; margin-left: auto; color: var(--muted); font-size: 11px; }
.live-indicator { display: inline-flex; align-items: center; gap: 7px; color: #9fe3b7; }
.topbar-settings { margin-left: 2px; }
.content { width: 100%; max-width: 1680px; padding: clamp(22px, 2.2vw, 38px) clamp(16px, 2.4vw, 48px) 48px; margin: 0 auto; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 27px; }
.page-heading h1 { margin: 5px 0 4px; font-size: 28px; line-height: 1.2; letter-spacing: 0; }
.page-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.heading-actions { display: flex; gap: 9px; }
.alert { display: flex; align-items: center; gap: 8px; padding: 11px 14px; margin-bottom: 18px; border: 1px solid var(--border); border-radius: 10px; font-size: 12px; }
.alert-success { color: #a8edc2; background: rgba(34, 197, 94, .09); border-color: rgba(34, 197, 94, .22); }
.alert-danger { color: #ffabb5; background: rgba(246, 70, 93, .09); border-color: rgba(246, 70, 93, .24); }
.alert-warning { color: #f9df8a; background: rgba(240, 185, 11, .09); border-color: rgba(240, 185, 11, .24); }
.alert-info { color: #a9cdfd; background: rgba(59, 130, 246, .09); border-color: rgba(59, 130, 246, .23); }

/* Panels, dashboard, and cards */
.panel, .stat-card, .account-card, .focus-card, .quick-strip {
  background: rgba(30, 32, 38, .72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .10);
}
.panel { padding: 22px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.panel-header h2, .panel-header h3 { margin: 4px 0 0; font-size: 17px; line-height: 1.3; }
.panel-header h3 { font-size: 15px; }
.panel-subtitle { max-width: 520px; margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.backup-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 8px; }
.backup-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--text); font-size: 12px; }
.backup-list .text-link { white-space: nowrap; }
.dashboard-hero { position: relative; min-height: 190px; display: flex; align-items: center; overflow: hidden; padding: 30px 32px; margin-bottom: 24px; border: 1px solid rgba(113, 91, 212, .36); border-radius: 16px; background: linear-gradient(112deg, #173d82 0%, #38258f 54%, #581c87 100%); }
.dashboard-hero::after { content: ""; position: absolute; inset: 0; opacity: .12; background-image: radial-gradient(circle at 80% 18%, #fff 0, transparent 1px), radial-gradient(circle at 74% 72%, #fff 0, transparent 1px); background-size: 26px 26px, 34px 34px; }
.hero-copy { position: relative; z-index: 1; }
.hero-copy .eyebrow { color: rgba(255, 255, 255, .56); }
.hero-copy h2 { margin: 7px 0 8px; font-size: 31px; line-height: 1.15; }
.hero-copy h2 .accent { color: #f9d35b; }
.hero-copy p { margin: 0; color: rgba(255, 255, 255, .72); font-size: 13px; }
.hero-actions { display: flex; gap: 9px; margin-top: 19px; }
.hero-mark { position: absolute; right: 8%; bottom: -22px; z-index: 1; width: 160px; height: 160px; display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .13); border-radius: 50%; font-size: 54px; transform: rotate(-15deg); }
.dashboard-grid { display: grid; gap: 24px; }
.dashboard-grid-top { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); margin-bottom: 24px; }
.dashboard-grid-bottom { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.stat-card { min-height: 155px; padding: 18px; }
.stat-card:hover, .record-card:hover, .account-card:hover { border-color: rgba(240, 185, 11, .40); transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0, 0, 0, .20); }
.stat-card, .record-card, .account-card { transition: border-color .22s ease, transform .22s ease, box-shadow .22s ease; }
.stat-icon { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; border-radius: 9px; font-size: 17px; }
.tone-yellow { color: var(--yellow); background: rgba(240, 185, 11, .14); }
.tone-green { color: var(--green); background: rgba(34, 197, 94, .14); }
.tone-red { color: var(--red); background: rgba(246, 70, 93, .14); }
.tone-blue { color: #60a5fa; background: rgba(59, 130, 246, .14); }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { margin-top: 3px; color: #f1f4f7; font-size: 23px; font-weight: 750; line-height: 1.2; }
.stat-detail { margin-top: 9px; font-size: 11px; }
.focus-card { padding: 19px; }
.focus-heading, .section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.focus-heading { margin-bottom: 12px; color: #dce1e8; font-size: 13px; font-weight: 700; }
.focus-heading > span { display: inline-flex; align-items: center; gap: 7px; }
.focus-heading > span .icon { color: var(--yellow); }
.focus-heading a { color: var(--yellow); font-size: 11px; }
.focus-empty { min-height: 105px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; }
.check-ring { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; margin-bottom: 7px; color: var(--green); border: 1px solid rgba(34, 197, 94, .35); border-radius: 50%; background: rgba(34, 197, 94, .10); }
.focus-empty strong { color: #cbd2dc; font-size: 12px; }
.focus-empty small { margin-top: 2px; color: var(--muted-2); font-size: 10px; }
.due-list { display: flex; flex-direction: column; gap: 5px; }
.due-row { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 7px; border-radius: 8px; }
.due-row:hover { background: rgba(255, 255, 255, .04); }
.due-avatar, .customer-avatar { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: #17120a; background: #66a3ff; border-radius: 50%; font-size: 11px; font-weight: 800; }
.due-name { min-width: 0; flex: 1; }
.due-name strong, .due-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-name strong { color: #d9dfe8; font-size: 12px; }
.due-name small { color: var(--muted); font-size: 10px; }
.chart-panel, .recent-panel { min-height: 300px; }
.section-title { margin-bottom: 17px; }
.section-title h2 { margin: 0; color: #cfd5dd; font-size: 16px; }
.chart-summary { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.chart-summary strong { font-size: 23px; }
.chart-summary span { color: var(--muted); font-size: 11px; }
.bar-chart { height: 195px; display: flex; align-items: flex-end; gap: 12px; padding: 18px 2px 0; }
.bar-col { height: 100%; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 7px; }
.bar-value { min-height: 15px; color: var(--muted-2); font-size: 9px; white-space: nowrap; }
.bar-track { width: 100%; max-width: 32px; height: 130px; display: flex; align-items: flex-end; overflow: hidden; border-radius: 6px 6px 3px 3px; background: #252a34; }
.bar-fill { display: block; width: 100%; min-height: 5px; border-radius: 6px 6px 2px 2px; background: #416ca6; transition: height .4s ease; }
.bar-fill.current { background: var(--yellow); }
.bar-col small { color: var(--muted); font-size: 10px; }
.recent-list { display: flex; flex-direction: column; gap: 2px; }
.recent-row { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 7px; border-radius: 8px; }
.recent-row:hover { background: rgba(255, 255, 255, .04); }
.recent-file { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; color: #8ec1ff; background: rgba(59, 130, 246, .12); border-radius: 8px; }
.recent-row > span:nth-child(2) { min-width: 0; flex: 1; }
.recent-row strong, .recent-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-row strong { color: #dbe1e9; font-size: 12px; }
.recent-row small { max-width: 260px; color: var(--muted); font-size: 10px; }
.recent-row time { color: var(--muted-2); font-size: 10px; }
.quick-strip { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px 18px; margin-top: 24px; }
.quick-strip strong { display: block; margin-top: 3px; color: #cbd3de; font-size: 12px; font-weight: 600; }

/* Lists and forms */
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.segmented { display: inline-flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: #12161c; }
.segmented a { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 5px 11px; border-radius: 7px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.segmented a:hover { color: #dbe2eb; }
.segmented a.selected { color: #17120a; background: var(--yellow); font-weight: 700; }
.inline-search { width: min(300px, 100%); display: flex; align-items: center; gap: 5px; padding: 0 4px 0 11px; border: 1px solid var(--border); border-radius: 9px; background: #11151b; }
.inline-search input { height: 34px; padding: 0; border: 0; background: transparent; box-shadow: none; font-size: 12px; }
.inline-search input:focus { box-shadow: none; }
.category-pills { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 17px; }
.category-pills a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid transparent; border-radius: 7px; color: var(--muted); background: #14191f; font-size: 11px; }
.category-pills a:hover, .category-pills a.selected { color: var(--yellow); border-color: rgba(240, 185, 11, .34); background: var(--yellow-soft); }
.category-pills i, .category-tag i { width: 7px; height: 7px; display: inline-block; border-radius: 50%; }
.list-panel { min-height: 180px; }
.record-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.record-card { min-width: 0; display: flex; flex-direction: column; min-height: 190px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: rgba(20, 24, 30, .72); }
.record-card-top { display: flex; align-items: center; justify-content: space-between; }
.record-icon { width: 35px; height: 35px; display: flex; align-items: center; justify-content: center; color: var(--icon-color); background: rgba(255, 255, 255, .08); border-radius: 9px; }
.record-icon { background: color-mix(in srgb, var(--icon-color) 14%, transparent); }
.record-actions { display: flex; align-items: center; gap: 3px; }
.favorite { color: var(--yellow); font-size: 15px; }
.record-main { min-width: 0; flex: 1; padding-top: 15px; }
.record-main h3 { margin: 0 0 7px; overflow: hidden; color: #e2e6ec; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.record-main p { display: -webkit-box; overflow: hidden; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.record-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 13px; color: var(--muted-2); font-size: 10px; }
.record-meta span { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-link { margin: -9px 0 17px; }
.back-link a { color: var(--muted); font-size: 12px; }
.back-link a:hover { color: var(--yellow); }
.editor-layout, .detail-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 24px; align-items: start; }
.editor-side { display: flex; flex-direction: column; gap: 18px; }
.editor-panel, .form-panel { max-width: 900px; }
.narrow-form { max-width: 740px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 5px; }
.check-row { display: flex; flex-wrap: wrap; gap: 18px; }
.check-label { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 7px !important; color: var(--muted) !important; font-size: 12px !important; font-weight: 500 !important; }
.check-label input { width: 15px; height: 15px; accent-color: var(--yellow); }
.form-hint { margin: -4px 0 2px; color: var(--muted-2); font-size: 11px; }
.inline-hint { margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--border); }
.security-panel { padding: 20px; }
.security-icon { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; color: var(--green); border-radius: 10px; background: rgba(34, 197, 94, .12); font-size: 19px; }
.security-panel h3 { margin: 0 0 7px; font-size: 15px; }
.security-panel p { margin: 0 0 17px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.mini-line { display: flex; justify-content: space-between; gap: 10px; padding-top: 13px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.mini-line strong { color: #d7dee8; font-weight: 600; }
.attachments-panel { padding: 18px; }
.attachments-panel .panel-header { margin-bottom: 10px; }
.file-library-actions { display: flex; align-items: center; gap: 9px; }
.standalone-upload { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.standalone-upload .upload-progress { flex: 1 0 100%; min-width: 230px; margin-top: 3px; }
.standalone-upload select { width: 106px; height: 32px; padding: 4px 7px; font-size: 10px; }
/* The real <input type="file"> must stay focusable. A display:none control
   that is also `required` makes Chrome abort the submit with an invisible
   "invalid form control is not focusable" error, which looks like a dead
   upload button. Clip it visually instead. */
.standalone-upload input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.attachment-row { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 9px 0; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.attachment-row:last-of-type { border-bottom: 0; }
.attachment-icon { width: 29px; height: 29px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; color: #9cc7ff; background: rgba(59, 130, 246, .12); border-radius: 7px; }
.attachment-row > span:nth-child(2) { min-width: 0; flex: 1; }
.attachment-row strong, .attachment-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-row strong { color: #d7dee7; font-size: 11px; }
.attachment-row small { color: var(--muted-2); font-size: 10px; }
.upload-form { display: flex; flex-direction: column; gap: 9px; padding-top: 13px; }
.upload-progress { display: flex; flex-direction: column; gap: 6px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.upload-progress[hidden] { display: none !important; }
.upload-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10px; }
.upload-progress-head span { min-width: 0; overflow-wrap: anywhere; }
.upload-progress-head strong { color: var(--yellow); font-size: 11px; font-variant-numeric: tabular-nums; }
.upload-progress-track { width: 100%; height: 6px; overflow: hidden; border-radius: 999px; background: var(--bg-soft); }
.upload-progress-track > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--yellow); transition: width .16s ease; }
.btn:disabled { cursor: wait; opacity: .60; transform: none; }
.file-drop { display: flex !important; align-items: center; justify-content: center; gap: 7px; min-height: 66px; padding: 10px; border: 1px dashed #3b4655; border-radius: 9px; color: var(--muted); background: #12161c; text-align: center; font-size: 11px !important; cursor: pointer; }
.file-drop:hover { color: var(--yellow); border-color: rgba(240, 185, 11, .55); }
.file-drop { position: relative; }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-inline-alert { margin-top: 8px; font-size: 11px; line-height: 1.6; }
.upload-inline-alert[hidden] { display: none !important; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 19px; padding: 13px 15px; color: var(--muted); border: 1px solid rgba(246, 70, 93, .18); border-radius: 10px; background: rgba(246, 70, 93, .05); font-size: 11px; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 730px; border-collapse: collapse; }
th { padding: 0 10px 11px; color: var(--muted-2); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 10px; color: #bac3cf; border-top: 1px solid rgba(255, 255, 255, .065); font-size: 12px; vertical-align: middle; }
tbody tr:hover td { background: rgba(255, 255, 255, .018); }
td small { display: block; margin-top: 3px; color: var(--muted-2); font-size: 10px; }
.table-primary { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.table-primary > span:last-child, .table-primary > strong { min-width: 0; }
.table-primary strong { display: block; overflow: hidden; color: #dce2ea; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.table-icon { width: 31px; height: 31px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: #9dc8ff; border-radius: 8px; background: rgba(59, 130, 246, .12); }
.table-icon.small { width: 25px; height: 25px; font-size: 12px; }
.table-actions { display: flex; justify-content: flex-end; align-items: center; gap: 4px; white-space: nowrap; }
.align-right { text-align: right; }
.due-inline { display: block; margin-top: 5px; font-size: 10px; }
.masked-data { color: #c6cfdb; font-variant-numeric: tabular-nums; }

/* CRM */
.metric-strip { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)) minmax(220px, 1.5fr); gap: 1px; margin-bottom: 16px; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--border); }
.metric-strip > div, .metric-strip > form { min-height: 76px; display: flex; flex-direction: column; justify-content: center; padding: 13px 16px; background: var(--surface); }
.metric-label { color: var(--muted); font-size: 11px; }
.metric-strip strong { margin-top: 2px; font-size: 22px; line-height: 1.2; }
.crm-search { align-self: center; width: calc(100% - 22px); min-height: 36px !important; height: 36px; padding-top: 0 !important; padding-bottom: 0 !important; }
.crm-toolbar { justify-content: flex-start; }
.customer-avatar { color: #fff; background: #5b8def; }

/* Finance */
.finance-overview { display: grid; grid-template-columns: minmax(230px, 1.35fr) repeat(2, minmax(150px, .7fr)) 145px; gap: 1px; overflow: hidden; margin-bottom: 24px; border: 1px solid var(--border); border-radius: 13px; background: var(--border); }
.finance-overview > * { min-height: 104px; display: flex; flex-direction: column; justify-content: center; padding: 17px 19px; background: var(--surface); }
.finance-total strong { margin: 3px 0 2px; font-size: 27px; }
.finance-total small, .finance-metric small { color: var(--muted-2); font-size: 10px; }
.finance-metric span { color: var(--muted); font-size: 11px; }
.finance-metric strong { margin-top: 4px; font-size: 19px; }
.finance-add-account { align-items: center !important; gap: 7px; color: var(--yellow); font-size: 11px; font-weight: 650; }
.finance-add-account .icon { width: 27px; height: 27px; border: 1px solid rgba(240, 185, 11, .35); border-radius: 8px; }
.account-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 24px; }
.account-card { min-height: 185px; padding: 17px; }
.account-card.tone-border-red { border-color: rgba(246, 70, 93, .25); }
.account-card.tone-border-yellow { border-color: rgba(240, 185, 11, .22); }
.account-card.tone-border-blue { border-color: rgba(59, 130, 246, .24); }
.account-top { display: flex; align-items: center; justify-content: space-between; }
.account-mark { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 9px; }
.account-type { display: block; margin-top: 13px; color: var(--muted); font-size: 10px; }
.account-card h3 { overflow: hidden; margin: 3px 0 10px; color: #dbe1e8; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.account-balance { display: block; color: #f0f3f7; font-size: 21px; line-height: 1.2; }
.account-card > small { color: var(--muted-2); font-size: 10px; }
.account-empty { grid-column: 1 / -1; }
.finance-list .panel-header { align-items: center; }
.month-picker { display: flex; align-items: center; gap: 4px; }
.month-picker input { width: 145px; height: 34px; padding: 5px 9px; font-size: 11px; }

/* Detail and settings */
.detail-layout { grid-template-columns: 1fr; }
.detail-hero { display: flex; align-items: center; gap: 14px; }
.detail-avatar { width: 58px; height: 58px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; color: #17120a; background: var(--yellow); border-radius: 16px; font-size: 23px; font-weight: 800; }
.detail-title { min-width: 0; flex: 1; }
.detail-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.detail-title h2 { margin: 0; font-size: 22px; }
.detail-title p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.detail-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--border); }
.detail-stats > div { min-height: 94px; display: flex; flex-direction: column; justify-content: center; padding: 16px; background: var(--surface); }
.detail-stats span, .detail-stats small { color: var(--muted); font-size: 11px; }
.detail-stats strong { margin: 4px 0 2px; font-size: 17px; }
.detail-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .8fr); gap: 24px; }
.contact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.contact-grid small, .notes-block small { color: var(--muted-2); font-size: 10px; }
.contact-grid strong { display: block; margin-top: 4px; color: #dae1e9; font-size: 13px; overflow-wrap: anywhere; }
.notes-block { padding-top: 16px; margin-top: 17px; border-top: 1px solid var(--border); }
.notes-block p { margin: 5px 0 0; color: #b7c0cc; font-size: 12px; line-height: 1.75; }
/* Settings rows: two equal columns where both cells stretch to the same
 * height, so the page reads as tidy rows instead of ragged boxes. */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 24px; margin-bottom: 24px; }
.settings-grid > .panel { min-width: 0; max-width: none; display: flex; flex-direction: column; }
.settings-grid > .panel > .panel-header { flex: 0 0 auto; }
.settings-grid > .panel > .stack-form { flex: 1; }
.settings-grid > .panel > .stack-form > .form-actions { margin-top: auto; padding-top: 10px; }
.settings-grid > .panel > .notice { margin-top: auto; }
.security-list { display: flex; flex-direction: column; gap: 2px; }
.security-list > div { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.security-list > div:last-child { border-bottom: 0; }
.security-list > div > span:first-child { width: 29px; height: 29px; display: flex; align-items: center; justify-content: center; color: var(--yellow); border-radius: 7px; background: var(--yellow-soft); }
.security-list > div > span:nth-child(2) { min-width: 0; flex: 1; }
.security-list strong, .security-list small { display: block; }
.security-list strong { color: #d9e0e8; font-size: 12px; }
.security-list small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.security-list b { font-size: 10px; font-weight: 650; white-space: nowrap; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; color: #9fe3b7; font-size: 11px; }
.notice { padding: 11px 12px; margin-top: 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 11px; line-height: 1.6; }
.notice-warning { color: #ead58d; background: rgba(240, 185, 11, .07); border-color: rgba(240, 185, 11, .20); }
.settings-tags { display: flex; flex-wrap: wrap; gap: 7px; min-height: 36px; }
.category-tag { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; color: #c8d0dc; border: 1px solid var(--border); border-radius: 7px; background: #14191f; font-size: 11px; }
.dot-green { background: var(--green); }
.dot-red { background: var(--red); }
.inline-add-form { display: flex; align-items: center; gap: 7px; padding-top: 15px; margin-top: 14px; border-top: 1px solid var(--border); }
.inline-add-form input:not([type="color"]), .inline-add-form select { min-width: 0; height: 34px; padding: 6px 9px; font-size: 11px; }
.inline-add-form input:not([type="color"]) { flex: 1; }
.inline-add-form input[type="color"] { width: 34px; height: 34px; padding: 3px; }

/* Empty state */
.empty-state { min-height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 25px 15px; text-align: center; }
.empty-icon { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; margin-bottom: 11px; color: var(--yellow); border: 1px solid rgba(240, 185, 11, .28); border-radius: 12px; background: var(--yellow-soft); font-size: 20px; }
.empty-state h3 { margin: 0; color: #d6dde7; font-size: 14px; }
.empty-state p { max-width: 310px; margin: 5px 0 14px; color: var(--muted); font-size: 11px; }

/* Day theme tokens. Surfaces stay neutral while the warm action color remains
 * legible against a soft, low-glare background. */
html[data-theme="light"] {
  --bg: #f3f6f4;
  --bg-soft: #e7eeeb;
  --surface: #ffffff;
  --surface-2: #f8fbfa;
  --surface-3: #edf3f0;
  --border: rgba(35, 55, 64, .14);
  --border-strong: rgba(35, 55, 64, .24);
  --line: rgba(35, 55, 64, .10);
  --text: #24323a;
  --muted: #60727c;
  --muted-2: #81919a;
  --yellow: #b4863a;
  --yellow-soft: rgba(180, 134, 58, .13);
  --blue: #3f7e9a;
  --blue-soft: rgba(63, 126, 154, .12);
  --green: #338b68;
  --green-soft: rgba(51, 139, 104, .12);
  --red: #c45e69;
  --red-soft: rgba(196, 94, 105, .12);
  --purple: #8875a8;
  --purple-soft: rgba(136, 117, 168, .12);
  --cyan: #3e8e8b;
  --cyan-soft: rgba(62, 142, 139, .12);
  --shadow: 0 18px 50px rgba(31, 58, 67, .12);
}
html[data-theme="light"] body { background: var(--bg); }
html[data-theme="light"] .btn-primary { color: #fff; background: #b77900; }
html[data-theme="light"] .btn-primary:hover { background: #9d6800; }
html[data-theme="light"] .btn-secondary { background: var(--surface-3); }
html[data-theme="light"] .btn-light { color: #1d2733; background: #fff; }
html[data-theme="light"] .btn-ghost-light { color: #fff; background: rgba(0, 0, 0, .16); border-color: rgba(255, 255, 255, .28); }
html[data-theme="light"] .stack-form label, html[data-theme="light"] .form-grid label { color: #455568; }
html[data-theme="light"] input, html[data-theme="light"] select, html[data-theme="light"] textarea { color: var(--text); background: #fff; }
html[data-theme="light"] input::placeholder, html[data-theme="light"] textarea::placeholder { color: #8b98a8; }
html[data-theme="light"] input:hover, html[data-theme="light"] select:hover, html[data-theme="light"] textarea:hover { border-color: rgba(15, 23, 42, .30); }
html[data-theme="light"] input:focus, html[data-theme="light"] select:focus, html[data-theme="light"] textarea:focus { background: #fff; }
html[data-theme="light"] .sidebar { background: #fff; border-right-color: var(--border); }
html[data-theme="light"] .side-caption, html[data-theme="light"] .side-section-label { color: #8693a3; }
html[data-theme="light"] .nav-item { color: #536276; }
html[data-theme="light"] .nav-item .icon { color: #7a899b; }
html[data-theme="light"] .nav-item:hover { background: #f2f5f8; }
html[data-theme="light"] .nav-item.active { background: #fff5d8; }
html[data-theme="light"] .sidebar-footer, html[data-theme="light"] .topbar { border-color: var(--border); }
html[data-theme="light"] .secure-status { color: #708094; }
html[data-theme="light"] .user-mini strong { color: #273442; }
html[data-theme="light"] .topbar { background: rgba(255, 255, 255, .94); }
html[data-theme="light"] .topbar-search { border-color: var(--border-strong); background: #f3f6f9; }
html[data-theme="light"] .topbar-search .icon { color: #718096; }
html[data-theme="light"] .panel, html[data-theme="light"] .stat-card, html[data-theme="light"] .account-card, html[data-theme="light"] .focus-card, html[data-theme="light"] .quick-strip { background: rgba(255, 255, 255, .90); box-shadow: 0 8px 28px rgba(38, 52, 70, .08); }
html[data-theme="light"] .stat-value, html[data-theme="light"] .account-balance { color: #1d2733; }
html[data-theme="light"] .focus-heading, html[data-theme="light"] .section-title h2, html[data-theme="light"] .record-main h3, html[data-theme="light"] .recent-row strong, html[data-theme="light"] .account-card h3, html[data-theme="light"] .contact-grid strong, html[data-theme="light"] .security-list strong { color: #273442; }
html[data-theme="light"] .focus-empty strong, html[data-theme="light"] .quick-strip strong { color: #344457; }
html[data-theme="light"] .bar-track { background: #e4e9ef; }
html[data-theme="light"] .bar-fill { background: #5b8def; }
html[data-theme="light"] .segmented, html[data-theme="light"] .inline-search, html[data-theme="light"] .category-pills a, html[data-theme="light"] .category-tag, html[data-theme="light"] .file-drop { background: #f6f8fa; }
html[data-theme="light"] .record-card { background: #fff; }
html[data-theme="light"] .record-icon { background: color-mix(in srgb, var(--icon-color) 12%, #fff); }
html[data-theme="light"] td { color: #526174; border-top-color: var(--line); }
html[data-theme="light"] .table-primary strong, html[data-theme="light"] .masked-data { color: #2d3b4b; }
html[data-theme="light"] tbody tr:hover td, html[data-theme="light"] .recent-row:hover, html[data-theme="light"] .due-row:hover { background: rgba(15, 23, 42, .035); }
html[data-theme="light"] .attachment-row, html[data-theme="light"] .security-list > div { border-bottom-color: var(--line); }
html[data-theme="light"] .file-drop { border-color: #aeb9c6; }
html[data-theme="light"] .mini-line strong { color: #344457; }
html[data-theme="light"] .notes-block p { color: #526174; }
html[data-theme="light"] .empty-state h3 { color: #344457; }
html[data-theme="light"] .theme-icon-sun { display: none; }
html[data-theme="light"] .theme-icon-moon { display: inline-flex; }

@media (min-width: 1320px) {
  .record-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1120px) {
  .content { padding-left: 24px; padding-right: 24px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .dashboard-grid-top, .dashboard-grid-bottom { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .finance-overview { grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(130px, .8fr)) 125px; }
}
@media (max-width: 1100px) {
  .auth-card { width: min(100%, 440px); }
}
@media (max-width: 980px) {
  :root { --sidebar: 0px; }
  .auth-shell { padding: 32px 18px; }
  .auth-card { width: min(100%, 440px); padding: 32px 26px 28px; }
  .sidebar { width: 270px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: 16px 0 40px rgba(0, 0, 0, .35); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 19; display: block; visibility: hidden; opacity: 0; background: rgba(0, 0, 0, .54); transition: opacity .22s ease, visibility .22s ease; }
  .sidebar.open + .sidebar-backdrop { visibility: visible; opacity: 1; }
  .mobile-menu, .mobile-close { display: inline-flex; }
  .main-shell { width: 100%; margin-left: 0; }
  .topbar { gap: 10px; padding: 0 16px; }
  .topbar-search { width: auto; min-width: 0; flex: 1; }
  .topbar-meta { display: none; }
  .content { padding: 24px 16px 40px; }
  .page-heading { align-items: flex-start; flex-direction: column; margin-bottom: 21px; }
  .heading-actions { width: 100%; }
  .heading-actions .btn { flex: 1; }
  .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-layout, .detail-columns { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .finance-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-total { grid-column: 1 / -1; }
  .finance-add-account { min-height: 70px !important; }
  .metric-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-strip > form { grid-column: 1 / -1; }
  .crm-search { width: 100%; }
}
@media (min-width: 1800px) {
  .stats-grid { gap: 20px; }
  .record-grid { gap: 20px; }
  .account-grid { gap: 20px; }
  .panel { padding: 26px; }
}
@media (max-width: 560px) {
  .topbar-settings { display: none; }
  .page-heading h1 { font-size: 24px; }
  .dashboard-hero { min-height: 220px; padding: 25px 22px; }
  .hero-copy h2 { font-size: 28px; }
  .hero-mark { right: -20px; width: 135px; height: 135px; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 105px; }
  .stat-icon { float: right; margin-bottom: 0; }
  .stat-value { font-size: 21px; }
  .quick-strip { align-items: flex-start; flex-direction: column; }
  .record-grid, .form-grid, .contact-grid { grid-template-columns: 1fr; }
  .toolbar-row { align-items: stretch; flex-direction: column; }
  .inline-search { width: 100%; }
  .segmented { width: 100%; overflow-x: auto; }
  .segmented a { flex: 1; justify-content: center; }
  .metric-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-strip > div { padding: 10px; }
  .metric-strip strong { font-size: 18px; }
  .finance-overview { grid-template-columns: 1fr 1fr; }
  .account-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .account-card { min-height: 160px; padding: 13px; }
  .account-card h3 { font-size: 12px; }
  .account-balance { font-size: 17px; }
  .detail-hero { align-items: flex-start; flex-wrap: wrap; }
  .detail-hero > .btn { margin-left: auto; }
  .detail-stats { grid-template-columns: 1fr; }
  .danger-zone { align-items: flex-start; flex-direction: column; }
  .danger-zone .btn { width: 100%; }
  .form-actions { justify-content: stretch; }
  .form-actions .btn { flex: 1; }
  .inline-add-form { flex-wrap: wrap; }
  .inline-add-form input:not([type="color"]) { flex-basis: 100%; }
  .file-library-actions { align-items: flex-start; flex-direction: column; }
  .standalone-upload { flex-wrap: wrap; justify-content: flex-end; }
  .standalone-upload select { flex: 1; }
  .bar-chart { gap: 7px; }
}
@media (max-width: 380px) {
  .content { padding-left: 12px; padding-right: 12px; }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .auth-shell { padding: 20px 12px; }
  .auth-card { padding-left: 20px; padding-right: 20px; }
  .account-grid { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .metric-strip > form { grid-column: 1 / -1; }
  .metric-strip > div:last-of-type { grid-column: 1 / -1; }
}

/* Refined palette: one calm blue-grey foundation with a warm, readable accent. */
.blue-text, .tone-text-blue, .tone-text-info { color: var(--blue); }
.btn-primary {
  color: #17232a;
  background: var(--yellow);
  box-shadow: 0 8px 22px rgba(221, 180, 102, .18);
}
.btn-primary:hover {
  color: #17232a;
  background: #edc47d;
  box-shadow: 0 10px 26px rgba(221, 180, 102, .26);
}
.btn-secondary { background: var(--surface-3); border-color: var(--border); }
.btn-secondary:hover { color: var(--yellow); border-color: rgba(221, 180, 102, .56); }
.btn-light { color: #17232a; background: #f7faf9; }
.btn-light:hover { background: #e9f0ed; }
.btn-ghost-light { color: rgba(237, 243, 244, .88); background: rgba(237, 243, 244, .08); border-color: rgba(237, 243, 244, .18); }
.btn-ghost-light:hover { background: rgba(237, 243, 244, .14); }
.btn-danger-ghost { color: var(--red); background: var(--red-soft); border-color: rgba(220, 115, 125, .30); }
.btn-danger-ghost:hover { background: rgba(220, 115, 125, .22); }
.icon-btn:hover { color: var(--yellow); background: var(--yellow-soft); border-color: rgba(221, 180, 102, .30); }
.icon-btn.danger:hover { color: var(--red); background: var(--red-soft); border-color: rgba(220, 115, 125, .30); }
.badge-success { color: #a8dfc2; background: var(--green-soft); }
.badge-danger { color: #f3b1b7; background: var(--red-soft); }
.badge-warning { color: #f2d493; background: var(--yellow-soft); }
.badge-info { color: #a7d4df; background: var(--blue-soft); }
.encryption-chip { color: #a8dfc2; background: var(--green-soft); }
.text-link:hover { color: #f1cb86; }

input, select, textarea { background: var(--bg-soft); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  border-color: rgba(221, 180, 102, .75);
  box-shadow: 0 0 0 3px rgba(221, 180, 102, .13);
  background: var(--surface);
}
.stack-form label, .form-grid label { color: var(--muted); }
.auth-key-warning { color: #e8c987; border-color: rgba(221, 180, 102, .28); background: rgba(221, 180, 102, .09); }


.sidebar { background: #121c24; border-right-color: var(--line); }
.side-caption, .side-section-label { color: var(--muted-2); }
.nav-item { color: #c5d1d5; }
.nav-item .icon { color: #8396a0; }
.nav-item:hover { color: var(--yellow); background: rgba(221, 180, 102, .07); }
.nav-item.active { color: var(--yellow); background: var(--yellow-soft); }
.sidebar-footer, .topbar { border-color: var(--line); }
.secure-status { color: var(--muted); }
.status-dot { box-shadow: 0 0 0 4px var(--green-soft); }
.avatar, .detail-avatar { color: #17232a; }
.user-mini strong { color: #dce8e9; }
.topbar { background: rgba(16, 23, 31, .94); }
.topbar-search { border-color: var(--border-strong); background: var(--bg-soft); }
.topbar-search .icon { color: var(--muted); }
.live-indicator, .status-pill { color: #a8dfc2; }

.alert-success { color: #a8dfc2; background: var(--green-soft); border-color: rgba(87, 184, 138, .28); }
.alert-danger { color: #f2b0b6; background: var(--red-soft); border-color: rgba(220, 115, 125, .28); }
.alert-warning { color: #f0d294; background: var(--yellow-soft); border-color: rgba(221, 180, 102, .28); }
.alert-info { color: #a8d4de; background: var(--blue-soft); border-color: rgba(91, 155, 184, .28); }

.panel, .stat-card, .account-card, .focus-card, .quick-strip { background: var(--surface); border-color: var(--border); box-shadow: 0 10px 30px rgba(3, 10, 15, .16); }
.dashboard-hero {
  border-color: rgba(99, 181, 179, .34);
  background: linear-gradient(112deg, #214653 0%, #29434f 56%, #354851 100%);
}
.hero-copy h2 .accent { color: #f0c97e; }
.stat-card:hover, .record-card:hover, .account-card:hover { border-color: rgba(221, 180, 102, .46); box-shadow: 0 12px 30px rgba(3, 10, 15, .24); }
.tone-yellow { color: var(--yellow); background: var(--yellow-soft); }
.tone-green { color: var(--green); background: var(--green-soft); }
.tone-red { color: var(--red); background: var(--red-soft); }
.tone-blue { color: var(--blue); background: var(--blue-soft); }
.stat-value { color: #edf3f4; }
.focus-heading, .section-title h2, .record-main h3, .recent-row strong, .account-card h3, .contact-grid strong, .security-list strong { color: #dce8e9; }
.focus-empty strong, .quick-strip strong, .mini-line strong { color: #cbd9dc; }
.check-ring, .security-icon { color: var(--green); background: var(--green-soft); border-color: rgba(87, 184, 138, .34); }
.due-row:hover, .recent-row:hover, tbody tr:hover td { background: rgba(190, 211, 217, .045); }
.due-avatar, .customer-avatar { color: #17232a; background: #7fb5c5; }
.bar-track { background: #253844; }
.bar-fill { background: #4f879f; }
.bar-fill.current { background: var(--yellow); }
.recent-file, .table-icon, .attachment-icon { color: #a7d4df; background: var(--blue-soft); }
.segmented, .inline-search, .category-pills a, .category-tag, .file-drop { background: var(--bg-soft); }
.segmented a:hover { color: #dce8e9; }
.segmented a.selected { color: #17232a; background: var(--yellow); }
.category-pills a:hover, .category-pills a.selected { color: var(--yellow); border-color: rgba(221, 180, 102, .38); background: var(--yellow-soft); }
.record-card { background: var(--surface-2); }
.record-icon { background: color-mix(in srgb, var(--icon-color) 15%, var(--surface-2)); }
.file-drop { border-color: #536b76; }
.file-drop:hover { color: var(--yellow); border-color: rgba(221, 180, 102, .62); }
.danger-zone { color: var(--muted); border-color: rgba(220, 115, 125, .24); background: rgba(220, 115, 125, .07); }
td { color: #b9cbd0; border-top-color: var(--line); }
.table-primary strong { color: #dce8e9; }
.masked-data { color: #c6d6d9; }
.metric-strip, .finance-overview, .detail-stats { background: var(--border); }
.metric-strip > div, .metric-strip > form, .finance-overview > *, .detail-stats > div { background: var(--surface); }
.finance-add-account { color: var(--yellow); }
.finance-add-account .icon { border-color: rgba(221, 180, 102, .38); }
.account-card.tone-border-red { border-color: rgba(220, 115, 125, .30); }
.account-card.tone-border-yellow { border-color: rgba(221, 180, 102, .28); }
.account-card.tone-border-blue { border-color: rgba(91, 155, 184, .30); }
.notes-block p { color: #b9cbd0; }
.security-list > div, .attachment-row { border-bottom-color: var(--line); }
.notice-warning { color: #e8c987; background: rgba(221, 180, 102, .08); border-color: rgba(221, 180, 102, .24); }
.category-tag { color: #c5d3d7; }
.empty-icon { color: var(--yellow); border-color: rgba(221, 180, 102, .32); background: var(--yellow-soft); }
.empty-state h3 { color: #dce8e9; }

html[data-theme="light"] .btn-primary { color: #fff; background: var(--yellow); }
html[data-theme="light"] .btn-primary:hover { color: #fff; background: #9a6f2b; }
html[data-theme="light"] .btn-secondary { color: var(--text); background: var(--surface-3); }
html[data-theme="light"] .btn-light { color: var(--text); background: #fff; }
html[data-theme="light"] .stack-form label, html[data-theme="light"] .form-grid label { color: #52656e; }
html[data-theme="light"] input, html[data-theme="light"] select, html[data-theme="light"] textarea { background: #fff; }
html[data-theme="light"] input:focus, html[data-theme="light"] select:focus, html[data-theme="light"] textarea:focus { background: #fff; }
html[data-theme="light"] .sidebar { background: #fbfdfc; }
html[data-theme="light"] .nav-item { color: #53666e; }
html[data-theme="light"] .nav-item .icon { color: #7d9197; }
html[data-theme="light"] .nav-item:hover { background: rgba(180, 134, 58, .08); }
html[data-theme="light"] .nav-item.active { background: var(--yellow-soft); }
html[data-theme="light"] .topbar { background: rgba(255, 255, 255, .95); }
html[data-theme="light"] .topbar-search { background: #f0f5f3; }
html[data-theme="light"] .panel, html[data-theme="light"] .stat-card, html[data-theme="light"] .account-card, html[data-theme="light"] .focus-card, html[data-theme="light"] .quick-strip { background: #fff; box-shadow: 0 10px 28px rgba(31, 58, 67, .08); }
html[data-theme="light"] .dashboard-hero { border-color: #bdd4ce; background: linear-gradient(112deg, #d8e9e4 0%, #e6efeb 58%, #f0e7d5 100%); }
html[data-theme="light"] .hero-copy .eyebrow { color: #5c7476; }
html[data-theme="light"] .hero-copy h2, html[data-theme="light"] .hero-copy p { color: #24323a; }
html[data-theme="light"] .hero-copy h2 .accent { color: #9a6f2b; }
html[data-theme="light"] .hero-copy p { color: rgba(36, 50, 58, .72); }
html[data-theme="light"] .hero-mark { color: rgba(63, 126, 154, .20); border-color: rgba(63, 126, 154, .20); }
html[data-theme="light"] .stat-value, html[data-theme="light"] .account-balance { color: #24323a; }
html[data-theme="light"] .focus-heading, html[data-theme="light"] .section-title h2, html[data-theme="light"] .record-main h3, html[data-theme="light"] .recent-row strong, html[data-theme="light"] .account-card h3, html[data-theme="light"] .contact-grid strong, html[data-theme="light"] .security-list strong { color: #2b3c44; }
html[data-theme="light"] .focus-empty strong, html[data-theme="light"] .quick-strip strong, html[data-theme="light"] .mini-line strong { color: #3b5058; }
html[data-theme="light"] .bar-track { background: #dfeae6; }
html[data-theme="light"] .bar-fill { background: #6194a4; }
html[data-theme="light"] .bar-fill.current { background: var(--yellow); }
html[data-theme="light"] .record-card { background: #fff; }
html[data-theme="light"] td { color: #5b6d75; }
html[data-theme="light"] .table-primary strong, html[data-theme="light"] .masked-data { color: #2d4048; }
html[data-theme="light"] .file-drop { border-color: #a5b9b8; }
html[data-theme="light"] .notes-block p { color: #5b6d75; }
html[data-theme="light"] .empty-state h3 { color: #3b5058; }

/* Vault reader and encrypted attachment previews */
.note-detail-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); gap: 24px; align-items: start; }
.note-reader { min-height: 460px; padding: clamp(24px, 3vw, 42px); }
.note-reader-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.note-reader-header h2 { margin: 12px 0 7px; font-size: 27px; line-height: 1.3; overflow-wrap: anywhere; }
.note-reader-header p { margin: 0; color: var(--muted); font-size: 11px; }
.note-reader-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.note-reader-actions, .danger-actions, .attachment-actions { display: flex; align-items: center; gap: 7px; }
.note-reader-actions { flex: 0 0 auto; }
.attachment-actions form, .danger-actions form { margin: 0; }
.note-reminder { display: flex; align-items: center; gap: 8px; width: fit-content; margin: 22px 0 0; padding: 8px 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 11px; }
.note-reminder .icon { color: var(--yellow); }
.note-reminder strong { color: var(--text); font-weight: 650; }
.note-content { padding-top: 28px; color: var(--text); font-size: 15px; line-height: 1.9; overflow-wrap: anywhere; white-space: normal; }
.note-content > p:first-child { margin-top: 0; }
.note-attachments { min-width: 0; padding: 20px; }
.note-attachments .panel-header { margin-bottom: 14px; }

.inline-image-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; margin-bottom: 15px; }
.inline-image-item { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.image-preview-button { position: relative; width: 100%; display: block; overflow: hidden; padding: 0; border: 0; border-radius: 0; background: var(--bg-soft); }
.image-preview-button img { width: 100%; height: 100%; display: block; object-fit: cover; }
.inline-image-item .image-preview-button { aspect-ratio: 4 / 3; }
.image-preview-hint { position: absolute; inset: auto 8px 8px auto; display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px; color: #fff; border-radius: 6px; background: rgba(8, 19, 25, .72); font-size: 10px; opacity: 0; transform: translateY(3px); transition: opacity .18s ease, transform .18s ease; }
.image-preview-button:hover .image-preview-hint, .image-preview-button:focus-visible .image-preview-hint { opacity: 1; transform: translateY(0); }
.inline-image-meta { display: flex; align-items: center; justify-content: space-between; gap: 7px; padding: 9px; }
.inline-image-meta > span, .file-card-heading > span { min-width: 0; }
.inline-image-meta strong, .inline-image-meta small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-image-meta strong { color: var(--text); font-size: 10px; }
.inline-image-meta small { margin-top: 2px; color: var(--muted-2); font-size: 9px; }

.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 15px; }
.file-card { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease; }
.file-card:hover { border-color: rgba(221, 180, 102, .40); transform: translateY(-2px); box-shadow: 0 12px 28px rgba(3, 10, 15, .18); }
.file-card-preview, .file-card-placeholder { width: 100%; aspect-ratio: 16 / 10; }
.file-card-placeholder { position: relative; display: flex; align-items: center; justify-content: center; color: var(--blue); background: var(--bg-soft); font-size: 38px; }
.file-extension { position: absolute; left: 12px; bottom: 10px; color: var(--muted); font-size: 10px; font-weight: 750; }
.file-card-body { padding: 13px; }
.file-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.file-card-heading strong, .file-card-heading small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card-heading strong { color: var(--text); font-size: 12px; }
.file-card-heading small { max-width: 160px; margin-top: 3px; color: var(--muted-2); font-size: 9px; }
.file-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; color: var(--muted-2); font-size: 9px; }
.file-association { max-width: 100%; display: flex; align-items: center; gap: 4px; overflow: hidden; margin-top: 11px; padding-top: 10px; color: var(--muted); border-top: 1px solid var(--line); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
a.file-association:hover { color: var(--yellow); }
.danger-zone > span strong, .danger-zone > span small { display: block; }
.danger-zone > span strong { color: var(--text); font-size: 12px; }
.danger-zone > span small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.app-dialog { width: min(92vw, 500px); padding: 22px; color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.app-dialog::backdrop { background: rgba(3, 10, 15, .72); backdrop-filter: blur(3px); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.dialog-header h2 { margin: 5px 0 0; font-size: 20px; }
.app-dialog > p { margin: 18px 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.app-dialog > p strong { color: var(--text); }
.delete-confirm-field { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 11px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.image-dialog { width: min(94vw, 1040px); }
.image-dialog-stage { height: min(68vh, 720px); display: flex; align-items: center; justify-content: center; overflow: hidden; margin-top: 17px; padding: 12px; background: #0b1117; }
.image-dialog-stage img { max-width: 100%; max-height: 100%; display: block; object-fit: contain; }

html[data-theme="light"] .inline-image-item, html[data-theme="light"] .file-card { background: #fff; }
html[data-theme="light"] .image-preview-hint { background: rgba(36, 50, 58, .78); }
html[data-theme="light"] .app-dialog { background: #fff; }

@media (max-width: 980px) {
  .note-detail-layout { grid-template-columns: 1fr; }
  .note-reader { min-height: 340px; }
  .inline-image-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .note-reader { padding: 20px; }
  .note-reader-header { flex-direction: column; }
  .note-reader-actions, .note-reader-actions .btn { width: 100%; }
  .note-reader-actions .btn { justify-content: center; }
  .note-content { padding-top: 22px; font-size: 14px; }
  .inline-image-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .file-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .file-card-body { padding: 10px; }
  .file-card-heading { align-items: center; }
  .file-card-heading small { max-width: 110px; }
  .danger-actions { width: 100%; align-items: stretch; flex-direction: column; }
  .danger-actions form, .danger-actions .btn { width: 100%; }
  .dialog-actions .btn { flex: 1; }
  .image-dialog { padding: 14px; }
  .image-dialog-stage { height: 62vh; margin-top: 12px; padding: 6px; }
}

@media (max-width: 380px) {
  .inline-image-gallery, .file-grid { grid-template-columns: 1fr; }
}

/* KK.YUN-inspired daytime theme: clean white surfaces with a confident
 * service blue, restrained borders, and readable neutral text. */
html[data-theme="light"] {
  --bg: #f7f9fc;
  --bg-soft: #f0f4fa;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --surface-3: #eef4ff;
  --border: rgba(35, 61, 92, .12);
  --border-strong: rgba(35, 61, 92, .22);
  --line: rgba(35, 61, 92, .09);
  --text: #232f3e;
  --muted: #697586;
  --muted-2: #96a0ae;
  --yellow: #1677ff;
  --yellow-soft: rgba(22, 119, 255, .12);
  --blue: #1677ff;
  --blue-soft: rgba(22, 119, 255, .10);
  --green: #16a36a;
  --green-soft: rgba(22, 163, 106, .11);
  --red: #d85a66;
  --red-soft: rgba(216, 90, 102, .11);
  --purple: #7667d8;
  --purple-soft: rgba(118, 103, 216, .11);
  --cyan: #0b9aa3;
  --cyan-soft: rgba(11, 154, 163, .11);
  --shadow: 0 18px 50px rgba(34, 75, 125, .10);
}

html[data-theme="light"] body { background: var(--bg); }
html[data-theme="light"] .accent,
html[data-theme="light"] .yellow-text,
html[data-theme="light"] .text-link,
html[data-theme="light"] .finance-add-account { color: #0d63d8; }
html[data-theme="light"] .text-link:hover,
html[data-theme="light"] a.file-association:hover { color: #0454c5; }

html[data-theme="light"] .btn-primary {
  color: #fff;
  background: #1677ff;
  box-shadow: 0 7px 18px rgba(22, 119, 255, .18);
}
html[data-theme="light"] .btn-primary:hover {
  color: #fff;
  background: #0d63d8;
  box-shadow: 0 9px 22px rgba(22, 119, 255, .25);
}
html[data-theme="light"] .btn-secondary {
  color: #334155;
  background: #f2f6fb;
  border-color: #dce6f2;
}
html[data-theme="light"] .btn-secondary:hover {
  color: #0d63d8;
  background: #e8f1ff;
  border-color: #a8c9f5;
}
html[data-theme="light"] .btn-light { color: #17457f; background: #fff; }
html[data-theme="light"] .btn-light:hover { background: #edf4ff; }
html[data-theme="light"] .btn-ghost-light {
  color: rgba(255, 255, 255, .94);
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .32);
}
html[data-theme="light"] .btn-ghost-light:hover { background: rgba(255, 255, 255, .20); }
html[data-theme="light"] .btn-danger-ghost { color: #c43f50; background: var(--red-soft); border-color: rgba(216, 90, 102, .28); }
html[data-theme="light"] .btn-danger-ghost:hover { background: rgba(216, 90, 102, .17); }
html[data-theme="light"] .icon-btn:hover { color: #0d63d8; background: var(--blue-soft); border-color: rgba(22, 119, 255, .24); }

html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea { color: var(--text); background: #fff; border-color: #dce5ee; }
html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder { color: #9aa6b5; }
html[data-theme="light"] input:hover,
html[data-theme="light"] select:hover,
html[data-theme="light"] textarea:hover { border-color: #b8c9dc; }
html[data-theme="light"] input:focus,
html[data-theme="light"] select:focus,
html[data-theme="light"] textarea:focus {
  border-color: rgba(22, 119, 255, .72);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, .12);
  background: #fff;
}
html[data-theme="light"] .stack-form label,
html[data-theme="light"] .form-grid label { color: #526174; }


html[data-theme="light"] .sidebar { background: #fff; border-right-color: #e1e8f0; }
html[data-theme="light"] .side-caption,
html[data-theme="light"] .side-section-label { color: #8a98aa; }
html[data-theme="light"] .nav-item { color: #526174; }
html[data-theme="light"] .nav-item .icon { color: #8292a7; }
html[data-theme="light"] .nav-item:hover { color: #0d63d8; background: #f2f6fb; }
html[data-theme="light"] .nav-item.active { color: #0753bb; background: #e7f0ff; }
html[data-theme="light"] .sidebar-footer { border-color: #e1e8f0; }
html[data-theme="light"] .secure-status { color: #75849a; }
html[data-theme="light"] .user-mini strong { color: #27384e; }

/* The reference site uses a solid blue service bar. Keep the workspace
 * controls readable by giving them a translucent white treatment. */
html[data-theme="light"] .topbar {
  color: #fff;
  background: #0454c5;
  border-bottom-color: rgba(255, 255, 255, .22);
}
html[data-theme="light"] .topbar-search {
  border-color: rgba(255, 255, 255, .32);
  background: rgba(255, 255, 255, .14);
}
html[data-theme="light"] .topbar-search .icon,
html[data-theme="light"] .topbar-search input { color: #fff; }
html[data-theme="light"] .topbar-search input::placeholder { color: rgba(255, 255, 255, .74); }
html[data-theme="light"] .topbar-search input:focus { background: transparent; }
html[data-theme="light"] .topbar-meta { color: rgba(255, 255, 255, .86); }
html[data-theme="light"] .live-indicator { color: #baf3d4; }
html[data-theme="light"] .topbar .icon-btn { color: rgba(255, 255, 255, .92); }
html[data-theme="light"] .topbar .icon-btn:hover { color: #fff; background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .24); }
html[data-theme="light"] .auth-corner .theme-toggle { color: #0d63d8; background: #e7f0ff; border-color: #c7dcfa; }
html[data-theme="light"] .auth-corner .theme-toggle:hover { color: #0454c5; background: #d9eaff; border-color: #a8c9f5; }

html[data-theme="light"] .panel,
html[data-theme="light"] .stat-card,
html[data-theme="light"] .account-card,
html[data-theme="light"] .focus-card,
html[data-theme="light"] .quick-strip {
  background: #fff;
  border-color: #e4ebf3;
  box-shadow: 0 5px 18px rgba(38, 77, 126, .06);
}
html[data-theme="light"] .dashboard-hero {
  border-color: #0d63d8;
  background: linear-gradient(110deg, #0454c5 0%, #0d6ce0 55%, #1677ff 100%);
}
html[data-theme="light"] .hero-copy .eyebrow { color: rgba(255, 255, 255, .72); }
html[data-theme="light"] .hero-copy h2,
html[data-theme="light"] .hero-copy p { color: #fff; }
html[data-theme="light"] .hero-copy h2 .accent { color: #dbeafe; }
html[data-theme="light"] .hero-copy p { color: rgba(255, 255, 255, .82); }
html[data-theme="light"] .hero-mark { color: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .22); }
html[data-theme="light"] .stat-value,
html[data-theme="light"] .account-balance { color: #233b59; }
html[data-theme="light"] .focus-heading,
html[data-theme="light"] .section-title h2,
html[data-theme="light"] .record-main h3,
html[data-theme="light"] .recent-row strong,
html[data-theme="light"] .account-card h3,
html[data-theme="light"] .contact-grid strong,
html[data-theme="light"] .security-list strong { color: #294360; }
html[data-theme="light"] .focus-empty strong,
html[data-theme="light"] .quick-strip strong,
html[data-theme="light"] .mini-line strong { color: #3c5875; }
html[data-theme="light"] .stat-card:hover,
html[data-theme="light"] .record-card:hover,
html[data-theme="light"] .account-card:hover { border-color: rgba(22, 119, 255, .42); box-shadow: 0 10px 24px rgba(38, 77, 126, .11); }
html[data-theme="light"] .due-row:hover,
html[data-theme="light"] .recent-row:hover,
html[data-theme="light"] tbody tr:hover td { background: rgba(22, 119, 255, .045); }
html[data-theme="light"] .due-avatar,
html[data-theme="light"] .customer-avatar { color: #0753bb; background: #dbeafe; }
html[data-theme="light"] .bar-track { background: #e7eef7; }
html[data-theme="light"] .bar-fill { background: #78a9f5; }
html[data-theme="light"] .bar-fill.current { background: #1677ff; }

html[data-theme="light"] .segmented,
html[data-theme="light"] .inline-search,
html[data-theme="light"] .category-pills a,
html[data-theme="light"] .category-tag,
html[data-theme="light"] .file-drop { background: #f3f7fc; }
html[data-theme="light"] .segmented a:hover { color: #0753bb; }
html[data-theme="light"] .segmented a.selected { color: #fff; background: #1677ff; }
html[data-theme="light"] .category-pills a:hover,
html[data-theme="light"] .category-pills a.selected { color: #0753bb; border-color: #a8c9f5; background: #e7f0ff; }
html[data-theme="light"] .record-card,
html[data-theme="light"] .inline-image-item,
html[data-theme="light"] .file-card { background: #fff; border-color: #e4ebf3; }
html[data-theme="light"] .record-icon { background: color-mix(in srgb, var(--icon-color) 12%, #fff); }
html[data-theme="light"] .file-card:hover { border-color: rgba(22, 119, 255, .42); box-shadow: 0 10px 24px rgba(38, 77, 126, .10); }
html[data-theme="light"] td { color: #596a7e; border-top-color: #edf1f5; }
html[data-theme="light"] .table-primary strong,
html[data-theme="light"] .masked-data { color: #2c4663; }
html[data-theme="light"] .file-drop { border-color: #b8c8da; }
html[data-theme="light"] .file-drop:hover { color: #0d63d8; border-color: rgba(22, 119, 255, .58); background: #edf4ff; }
html[data-theme="light"] .notes-block p { color: #596a7e; }
html[data-theme="light"] .empty-state h3 { color: #3c5875; }
html[data-theme="light"] .empty-icon { color: #1677ff; border-color: rgba(22, 119, 255, .28); background: #e7f0ff; }

html[data-theme="light"] .metric-strip,
html[data-theme="light"] .finance-overview,
html[data-theme="light"] .detail-stats { background: #e5edf6; border-color: #e5edf6; }
html[data-theme="light"] .metric-strip > div,
html[data-theme="light"] .metric-strip > form,
html[data-theme="light"] .finance-overview > *,
html[data-theme="light"] .detail-stats > div { background: #fff; }
html[data-theme="light"] .finance-add-account { color: #0d63d8; }
html[data-theme="light"] .finance-add-account .icon { border-color: rgba(22, 119, 255, .32); }
html[data-theme="light"] .account-card.tone-border-red { border-color: rgba(216, 90, 102, .30); }
html[data-theme="light"] .account-card.tone-border-yellow,
html[data-theme="light"] .account-card.tone-border-blue { border-color: rgba(22, 119, 255, .28); }
html[data-theme="light"] .security-list > div,
html[data-theme="light"] .attachment-row { border-bottom-color: #edf1f5; }
html[data-theme="light"] .notice-warning { color: #94651b; background: #fff7e6; border-color: #f0d59e; }
html[data-theme="light"] .category-tag { color: #526174; border-color: #dce6f2; }
html[data-theme="light"] .image-preview-hint { background: rgba(4, 84, 197, .86); }
html[data-theme="light"] .app-dialog { background: #fff; border-color: #dce5ee; }
html[data-theme="light"] .image-dialog-stage { background: #edf3fb; }

/* Unified search and filter controls. Keep the shell responsible for focus
 * feedback so the nested input never creates a second, uneven outline. */
.search-control { min-width: 0; }
.search-control input {
  min-width: 0;
  color: var(--text);
}
.search-control input::placeholder { color: var(--muted-2); }
.search-control input:focus {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.topbar-search {
  width: min(440px, 38vw);
  min-width: 220px;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 4px 13px rgba(3, 10, 15, .12);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.topbar-search:hover { border-color: rgba(221, 180, 102, .52); }
.topbar-search:focus-within {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px var(--yellow-soft), 0 5px 16px rgba(3, 10, 15, .15);
}
.topbar-search > .icon {
  flex: 0 0 auto;
  color: var(--yellow);
  font-size: 18px;
}
.topbar-search input {
  flex: 1;
  width: auto;
  height: 40px;
  min-width: 0;
  padding: 0;
  color: var(--text);
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
}

.inline-search {
  width: min(360px, 100%);
  min-width: 0;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(3, 10, 15, .09);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.inline-search:hover { border-color: rgba(221, 180, 102, .52); }
.inline-search:focus-within {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px var(--yellow-soft), 0 4px 13px rgba(3, 10, 15, .12);
}
.inline-search > .icon {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 17px;
}
.inline-search input {
  flex: 1;
  width: auto;
  height: 32px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
}
.inline-search > .icon-btn,
.month-picker > .icon-btn {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  color: var(--yellow);
  border: 0;
  border-radius: 8px;
  background: var(--yellow-soft);
}
.inline-search > .icon-btn:hover,
.month-picker > .icon-btn:hover {
  color: #17232a;
  border-color: transparent;
  background: var(--yellow);
}

/* The CRM metrics row gives its form a column layout. Reassert the search
 * row here so the input and submit button remain side by side. */
.metric-strip > form.inline-search.crm-search {
  width: calc(100% - 24px);
  min-width: 0;
  min-height: 42px !important;
  height: 42px;
  align-self: center;
  flex-direction: row;
  align-items: center;
  justify-content: initial;
  gap: 8px;
  padding: 4px 6px 4px 13px;
}

.month-picker {
  min-width: 0;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(3, 10, 15, .08);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.month-picker:hover { border-color: rgba(221, 180, 102, .52); }
.month-picker:focus-within {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px var(--yellow-soft), 0 4px 13px rgba(3, 10, 15, .12);
}
.month-picker input {
  flex: 1;
  width: 145px;
  min-width: 0;
  height: 32px;
  padding: 5px 2px;
  color: var(--text);
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
}
.month-picker input:focus {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

/* Light mode uses a white search surface on the blue service bar and clear
 * blue submit affordances in the content area. */
html[data-theme="light"] .topbar-search {
  border-color: #d4e1ef;
  background: #fff;
  box-shadow: 0 4px 13px rgba(19, 70, 128, .18);
}
html[data-theme="light"] .topbar-search:hover { border-color: #9fc2ec; }
html[data-theme="light"] .topbar-search:focus-within {
  border-color: #1677ff;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, .18), 0 5px 16px rgba(19, 70, 128, .20);
}
html[data-theme="light"] .topbar-search > .icon { color: #1677ff; }
html[data-theme="light"] .topbar-search input { color: #243b5a; }
html[data-theme="light"] .topbar-search input::placeholder { color: #8293a8; }

html[data-theme="light"] .inline-search,
html[data-theme="light"] .month-picker {
  border-color: #d6e2ef;
  background: #fff;
  box-shadow: 0 3px 10px rgba(35, 76, 125, .08);
}
html[data-theme="light"] .inline-search:hover,
html[data-theme="light"] .month-picker:hover { border-color: #a9c7e8; }
html[data-theme="light"] .inline-search:focus-within,
html[data-theme="light"] .month-picker:focus-within {
  border-color: #1677ff;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, .14), 0 4px 13px rgba(35, 76, 125, .11);
}
html[data-theme="light"] .inline-search > .icon,
html[data-theme="light"] .month-picker > .icon { color: #6d87a4; }
html[data-theme="light"] .inline-search input,
html[data-theme="light"] .month-picker input { color: #2c4663; }
html[data-theme="light"] .inline-search input::placeholder { color: #8b9bad; }
html[data-theme="light"] .inline-search > .icon-btn,
html[data-theme="light"] .month-picker > .icon-btn {
  color: #fff;
  background: #1677ff;
  box-shadow: 0 3px 8px rgba(22, 119, 255, .20);
}
html[data-theme="light"] .inline-search > .icon-btn:hover,
html[data-theme="light"] .month-picker > .icon-btn:hover {
  color: #fff;
  background: #0d63d8;
  box-shadow: 0 4px 10px rgba(22, 119, 255, .26);
}

@media (max-width: 980px) {
  .topbar-search { width: auto; min-width: 0; flex: 1; }
  .metric-strip > form.inline-search.crm-search { width: calc(100% - 24px); }
}

@media (max-width: 700px) {
  .topbar-search { height: 40px; padding-left: 12px; padding-right: 10px; }
  .topbar-search input { height: 38px; font-size: 12px; }
  .toolbar-row { gap: 10px; }
  .inline-search { width: 100%; }
  .month-picker { width: 100%; }
  .month-picker input { width: auto; }
}

@media (max-width: 380px) {
  .topbar-search { gap: 7px; padding-left: 10px; }
  .topbar-search > .icon { font-size: 16px; }
  .inline-search { padding-left: 10px; }
}

/* Backup and account-security controls share the same restrained surface as
 * the rest of Settings. The restore area is visually separated because it
 * replaces the live database. */
.backup-panel { min-width: 0; }
.backup-create-form { margin-top: 16px; }
.backup-panel .backup-list { margin-top: 18px; }
.backup-list li > span { min-width: 0; flex: 1; }
.backup-list li strong,
.backup-list li small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backup-list li strong { color: var(--text); font-size: 11px; font-weight: 650; }
.backup-list li small { margin-top: 3px; color: var(--muted-2); font-size: 10px; }
.backup-restore-box { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.backup-restore-box .panel-header { margin-bottom: 10px; }
.backup-restore-box h3 { margin: 0; color: var(--text); font-size: 15px; }
.backup-restore-box .form-hint { line-height: 1.7; }
.backup-restore-box code { padding: 2px 5px; color: var(--text); border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); font-size: 10px; }
.status-pill-warning { color: var(--red); }
.status-pill-warning .status-dot { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.security-settings-panel { max-width: 900px; }
.security-settings-panel .panel-header { align-items: flex-start; }
.security-settings-panel .panel-subtitle { max-width: 520px; margin-top: 5px; }
.security-settings-panel .stack-form { margin-top: 5px; }

html[data-theme="light"] .backup-restore-box { border-top-color: #e5ebf1; }
html[data-theme="light"] .backup-list li strong,
html[data-theme="light"] .backup-restore-box h3 { color: #263f5e; }
html[data-theme="light"] .backup-list li small { color: #8190a2; }
html[data-theme="light"] .backup-restore-box code { color: #30547b; border-color: #d5e1ec; background: #f5f8fc; }
html[data-theme="light"] .status-pill-warning { color: #bd4d5a; }

@media (max-width: 700px) {
  .backup-restore-box .panel-header { flex-direction: column; gap: 8px; }
  .security-settings-panel .panel-header { flex-direction: column; }
}

/* --------------------------------------------------------------------------
 * Small shared utilities
 * ------------------------------------------------------------------------ */
.inline-form { display: inline-flex; margin: 0; }
.panel-header-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.panel-header-actions form { margin: 0; }
.col-actions { width: 58px; text-align: right; }
.danger-text { color: var(--red); }
.danger-text:hover { color: #f08b93; }
.notice-info { color: var(--muted); background: var(--surface-2); }
.btn-tiny { height: 26px; padding: 0 9px; font-size: 11px; border-radius: 7px; }
.btn-ghost { color: var(--muted); background: transparent; border-color: var(--border); }
.btn-ghost:hover { color: var(--yellow); border-color: rgba(221, 180, 102, .5); }
.icon-btn.tiny { width: 26px; height: 26px; min-height: 26px; font-size: 12px; border-radius: 7px; }
.icon-btn.tiny.active { color: var(--yellow); background: var(--yellow-soft); border-color: rgba(221, 180, 102, .42); }
button[disabled] { opacity: .45; cursor: not-allowed; }

/* --------------------------------------------------------------------------
 * PIN confirmation dialog
 * ------------------------------------------------------------------------ */
.pin-dialog { max-width: 420px; }
.pin-dialog p { margin: 0 0 16px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.pin-field { display: block; }
.pin-field input { letter-spacing: .32em; text-align: center; font-size: 17px; }
.pin-hint { margin: 10px 0 0 !important; color: var(--muted-2); font-size: 11px; min-height: 14px; }
.pin-hint.is-error { color: var(--red); }

/* --------------------------------------------------------------------------
 * Bookmarks
 * ------------------------------------------------------------------------ */
.bookmark-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.bookmark-search { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 320px; padding: 0 6px 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); }
.bookmark-search .icon { flex: 0 0 auto; color: var(--muted); }
.bookmark-search input { width: auto; flex: 1; min-width: 0; height: 38px; border: 0; background: transparent; }
.bookmark-search input:focus { box-shadow: none; background: transparent; }
.bookmark-search .btn { flex: 0 0 auto; height: 30px; padding: 0 13px; font-size: 12px; }
.bookmark-summary { color: var(--muted); font-size: 12px; }
.bookmark-summary strong { color: var(--text); }
/* Matches the ring the other search shells draw, so focusing this field does
 * not fall back to the browser's default outline. */
.bookmark-search:focus-within {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px var(--yellow-soft);
}

.bookmark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 15px; }
.bookmark-card { display: flex; flex-direction: column; padding: 16px 17px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); transition: border-color .18s ease, transform .18s ease; }
.bookmark-card:hover { border-color: var(--border-strong); }
.bookmark-card.is-pinned { border-color: rgba(240, 185, 11, .34); background: var(--yellow-soft); }
.bookmark-top { display: flex; align-items: flex-start; gap: 11px; }
.bookmark-mark { width: 34px; height: 34px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; color: #17120a; background: var(--yellow); border-radius: 10px; font-size: 15px; font-weight: 800; }
.bookmark-heading { min-width: 0; flex: 1; }
.bookmark-heading h3 { margin: 0; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.bookmark-heading small { display: block; margin-top: 2px; color: var(--muted-2); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.pin-flag { display: inline-flex; align-items: center; color: var(--yellow); font-size: 11px; }
.pin-flag.small { font-size: 10px; }

.bookmark-fields { display: grid; gap: 8px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--border); }
.bookmark-card.is-name-only .bookmark-fields { display: none; }
.bookmark-field { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: 12px; }
.bookmark-field-label { flex: 0 0 34px; color: var(--muted-2); font-size: 10px; }
.bookmark-field > .secret, .bookmark-field > a, .bookmark-field > span:not([class]) { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-link { color: var(--blue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-link:hover { color: var(--yellow); }
.bookmark-note { align-items: flex-start; }
.bookmark-note > span:last-child { color: var(--muted); font-size: 11px; line-height: 1.65; overflow-wrap: anywhere; }

.secret { font-variant-numeric: tabular-nums; letter-spacing: .06em; }
.secret .secret-plain { letter-spacing: 0; }
.bookmark-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--border); }
.bookmark-mode { color: var(--muted-2); font-size: 10px; }

.bookmark-panel { margin-bottom: 24px; }
.bookmark-quick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--border); }
.bookmark-quick-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); }
.bookmark-quick-row:hover { background: var(--surface-2); }
.bookmark-dot { width: 26px; height: 26px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; color: #17120a; background: var(--yellow); border-radius: 8px; font-size: 12px; font-weight: 800; }
.bookmark-quick-name { min-width: 0; flex: 1; }
.bookmark-quick-name strong { display: block; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-quick-name small { display: block; margin-top: 1px; color: var(--muted-2); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-quick-actions { display: flex; align-items: center; gap: 3px; flex: 0 0 auto; }
.bookmark-more { margin-top: 12px; font-size: 11px; }

.backup-row-actions { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.backup-list li.backup-hint { border-top: 0; padding-top: 2px; font-size: 11px; }

@media (max-width: 700px) {
  .bookmark-toolbar { flex-direction: column; align-items: stretch; }
  .bookmark-search { flex: 1 1 auto; }
  .bookmark-grid, .bookmark-quick-list { grid-template-columns: 1fr; }
  .panel-header-actions { flex-wrap: wrap; }
}
.icon-btn.tiny.copied { color: var(--green); background: var(--green-soft); border-color: rgba(87, 184, 138, .4); }
.bookmark-card.is-revealed .bookmark-fields { display: grid; }

/* Finance unlock screen: a narrow centred panel inside the app frame. */
.finance-gate { margin: 0 auto; }
.finance-gate .panel-subtitle { max-width: 460px; }

/* Keep the dashboard's second row visually balanced when the bookmark widget
 * has fewer rows than the recent-notes panel beside it. */
.bookmark-panel { min-height: 300px; }
