:root {
  --navy: #183153;
  --navy-deep: #10263f;
  --green: #214f39;
  --ink: #1f2937;
  --muted: #566777;
  --line: #dfe5eb;
  --bg: #f4f7f9;
  --shadow: 0 8px 24px rgb(24 49 83 / 8%);
  font: 15px/1.5 Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2.25rem); line-height: 1.2; color: var(--navy-deep); letter-spacing: -.025em; }
h2 { font-size: 1.12rem; line-height: 1.3; color: var(--navy); }
.icon { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.app-shell { min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30; width: 252px;
  display: flex; flex-direction: column; background: var(--navy-deep);
  color: #dbe6ee; box-shadow: 6px 0 20px rgb(16 38 63 / 12%);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 22px; min-height: 82px; color: white; border-bottom: 1px solid rgb(255 255 255 / 12%); }
.brand strong { font-size: 1.3rem; letter-spacing: -.02em; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: #254e45; color: #b9dfc5; }
.brand-mark .icon { width: 22px; height: 22px; }
.side-nav { flex: 1; overflow: auto; padding: 16px 12px; }
.side-nav p { margin: 14px 12px 7px; color: #a8bdcb; font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.side-nav p:not(:first-child) { margin-top: 24px; }
button, summary, input, select { font: inherit; }
button, .new-menu summary {
  display: inline-flex; gap: 8px; align-items: center; justify-content: center; min-height: 40px;
  border: 1px solid var(--navy); border-radius: 8px; background: var(--navy);
  color: white; font-weight: 700; padding: 8px 14px; cursor: pointer;
}
button:hover, .new-menu summary:hover { background: #24466f; }
button:disabled { opacity: .45; cursor: default; }
button.secondary { background: white; border-color: var(--line); color: var(--navy); }
button.secondary:hover { background: #edf3f7; }
button.nav-item { width: 100%; justify-content: flex-start; border: 0; background: transparent; color: #dbe6ee; padding: 10px 12px; gap: 11px; text-align: left; font-weight: 600; }
button.nav-item:hover { background: rgb(255 255 255 / 8%); }
button.nav-item[aria-current="page"] { background: rgb(255 255 255 / 13%); color: white; box-shadow: inset 3px 0 #8bc39d; }
.nav-item .icon { color: #a9bcc9; }
.nav-item[aria-current="page"] .icon { color: #a8d5b5; }
.sidebar-footer { border-top: 1px solid rgb(255 255 255 / 12%); padding: 14px 12px; }
.agency-switch { margin: 0 0 6px; padding: 8px 10px; border-radius: 8px; background: rgb(255 255 255 / 7%); color: #c2d5e0; }
.agency-switch label { margin-bottom: 5px; }
.sidebar-footer select { background: var(--navy-deep); color: white; border-color: #516981; }
.profile { display: grid; grid-template-columns: 34px minmax(0, 1fr) 34px; align-items: center; gap: 9px; margin-top: 9px; padding: 12px 2px 0; border-top: 1px solid rgb(255 255 255 / 12%); }
.profile strong, .profile small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
.profile small { color: #a8bdcb; }
.avatar { display: grid; place-items: center; border-radius: 50%; width: 34px; height: 34px; background: #2b5a43; font-weight: 700; }
button.signout { padding: 6px; justify-content: center; }
.main-shell { margin-left: 252px; min-height: 100dvh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; min-height: 70px; padding: 10px clamp(18px, 3vw, 36px); border-bottom: 1px solid var(--line); background: white; }
.breadcrumb { min-width: 0; flex: 1; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.breadcrumb span, .breadcrumb strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumb strong { color: var(--navy); }
.breadcrumb .icon { width: 13px; height: 13px; }
.new-menu { position: relative; }
.new-menu summary { list-style: none; }
.new-menu summary::-webkit-details-marker { display: none; }
.new-menu summary .icon:last-child { width: 13px; transform: rotate(90deg); }
.new-options { position: absolute; top: calc(100% + 8px); right: 0; width: 225px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: var(--shadow); }
.new-options p { padding: 7px 9px; font-size: .77rem; color: var(--muted); font-weight: 700; }
.new-options button { width: 100%; justify-content: flex-start; border-color: transparent; }
.content-area { padding: 30px clamp(18px, 3vw, 36px) 48px; max-width: 1600px; margin: auto; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; }
.page-head p { margin-top: 7px; color: var(--muted); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.metric-card, .card { border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow); }
.metric-card { display: flex; align-items: center; gap: 12px; padding: 16px; }
.metric-card div { min-width: 0; }
.metric-card div span { color: var(--muted); font-size: .8rem; font-weight: 700; }
.metric-card strong { display: block; color: var(--navy-deep); font-size: clamp(1.1rem, 2vw, 1.65rem); line-height: 1.35; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.metric-icon { display: grid; flex: none; place-items: center; width: 40px; height: 40px; border-radius: 9px; }
.metric-icon.navy { background: #e9eef5; color: var(--navy); }
.metric-icon.green { background: #e7f1eb; color: var(--green); }
.metric-icon.amber { background: #fbf1df; color: #875808; }
.metric-icon.blue { background: #e5f0f6; color: #265c80; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.card { min-width: 0; margin-bottom: 16px; padding: 18px 20px; }
.card h2 { margin-bottom: 12px; }
.panel-link { margin-top: 12px; }
.muted { color: var(--muted); }
form { display: grid; gap: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); align-items: end; gap: 12px; }
label { display: grid; gap: 5px; font-size: .85rem; font-weight: 700; }
label.inline { display: flex; align-items: center; min-height: 40px; }
input:not([type="checkbox"]), select { width: 100%; min-width: 0; min-height: 40px; padding: 8px 10px; border: 1px solid #a9b9c8; border-radius: 8px; background: white; color: var(--ink); }
:focus-visible { outline: 3px solid #5684ad; outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th, td { text-align: left; vertical-align: top; padding: 10px; border-bottom: 1px solid #edf1f4; }
th { color: var(--muted); background: #f5f8fa; white-space: nowrap; }
tbody tr:hover { background: #f7fafc; }
td.number { font-variant-numeric: tabular-nums; white-space: nowrap; }
.register-filter { grid-template-columns: minmax(0, 320px) auto; align-items: end; justify-content: start; margin-bottom: 14px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
dialog { width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border: 1px solid var(--line); border-radius: 12px; padding: 0; color: var(--ink); box-shadow: 0 18px 60px rgb(16 38 63 / 30%); }
dialog::backdrop { background: rgb(16 38 63 / 54%); }
dialog header { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; background: white; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 18px 20px; }
.dialog-message:not(:empty) { margin-top: 12px; color: #8f302c; }
fieldset { min-width: 0; margin: 0 0 9px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
legend { padding: 0 5px; font-weight: 700; }
.auth-shell { width: min(460px, calc(100% - 32px)); margin: clamp(24px, 8vh, 88px) auto; }
.auth-shell .brand { min-height: 64px; padding: 12px 18px; background: var(--navy-deep); border-radius: 12px; margin-bottom: 16px; }
.auth h1 { margin-bottom: 16px; }
.auth p { margin-bottom: 12px; }
.loading { padding: 24px; }
#notice:not(:empty) { position: fixed; z-index: 35; right: 16px; bottom: 16px; max-width: min(520px, calc(100vw - 32px)); padding: 12px 16px; background: var(--green); color: white; border-radius: 8px; box-shadow: var(--shadow); }
#notice.error { background: #8f302c; }
.mobile-menu, .scrim { display: none; }
@media (max-width: 1200px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 850px) {
  .sidebar { visibility: hidden; transform: translateX(-100%); }
  .nav-open .sidebar { visibility: visible; transform: none; }
  .main-shell { margin-left: 0; }
  button.mobile-menu { display: inline-flex; padding: 8px; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgb(16 38 63 / 50%); border: 0; border-radius: 0; }
}
@media (max-width: 560px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .metric-grid { gap: 8px; }
  .metric-card { align-items: flex-start; gap: 8px; padding: 10px; }
  .metric-icon { width: 28px; height: 28px; }
  .metric-icon .icon { width: 16px; height: 16px; }
  .breadcrumb span, .breadcrumb .icon { display: none; }
  .card { padding: 14px; }
  .page-head { align-items: flex-start; flex-wrap: wrap; }
}
td.date { white-space: nowrap; }
.dialog-body form:is([data-action="income"], [data-action="expense"]) .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 480px) {
  .dialog-body form:is([data-action="income"], [data-action="expense"]) .form-grid {
    grid-template-columns: 1fr;
  }
}
