:root {
  --ink: #0b0b0b;
  --ink-2: #161616;
  --ink-3: #272727;
  --paper: #f5f3ed;
  --surface: #ffffff;
  --line: #dedbd2;
  --muted: #716f69;
  --yellow: #ffd21c;
  --yellow-dark: #d3a900;
  --red: #d83b3b;
  --red-bg: #ffebeb;
  --blue: #3269d7;
  --blue-bg: #eaf0ff;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(11, 11, 11, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 7px; color: var(--yellow-dark); font-size: .72rem; font-weight: 850; letter-spacing: .15em; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 82% 18%, rgba(255,210,28,.18), transparent 28%),
    linear-gradient(135deg, #080808 0 55%, #151515 55% 100%);
}
.login-card { width: min(470px, 100%); padding: 44px; border-radius: 28px; background: #fff; box-shadow: 0 28px 90px rgba(0,0,0,.36); }
.login-card h1 { margin: 20px 0 12px; font-size: clamp(2rem, 6vw, 3.2rem); line-height: .98; letter-spacing: -.06em; }
.login-card h1 span { background: linear-gradient(transparent 56%, var(--yellow) 56%); }
.login-card > .muted { margin: 0 0 30px; line-height: 1.6; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; color: var(--ink); background: var(--yellow); font-weight: 950; letter-spacing: -.07em; transform: skew(-5deg); }
.brand-mark span { transform: skew(5deg); }
.brand-mark.large { width: 62px; height: 62px; font-size: 1.25rem; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 258px; padding: 24px 18px; display: flex; flex-direction: column; background: var(--ink); color: white; }
.brand { display: flex; align-items: center; gap: 13px; padding: 4px 7px 28px; }
.brand strong { display: block; font-size: 1.08rem; }
.brand small { display: block; margin-top: 2px; color: #979797; }
.nav { display: grid; gap: 5px; }
.nav-item { border: 0; border-radius: 12px; padding: 13px 14px; display: flex; gap: 13px; align-items: center; color: #bcbcbc; background: transparent; text-align: left; font-weight: 700; transition: .18s ease; }
.nav-item span { color: #626262; font-size: .68rem; letter-spacing: .08em; }
.nav-item:hover { color: white; background: #1b1b1b; }
.nav-item.active { color: var(--ink); background: var(--yellow); }
.nav-item.active span { color: #725e00; }
.sidebar-footer { margin-top: auto; padding: 18px 10px 4px; border-top: 1px solid #2b2b2b; }
.sidebar-footer p { margin: 0 0 8px; color: #aaa; font-size: .77rem; overflow: hidden; text-overflow: ellipsis; }
.text-button { border: 0; padding: 0; color: var(--yellow); background: none; font-weight: 800; }

.workspace { min-height: 100vh; margin-left: 258px; }
.topbar { position: sticky; top: 0; z-index: 15; min-height: 104px; padding: 23px clamp(22px, 4vw, 54px); display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid rgba(222,219,210,.8); background: rgba(245,243,237,.92); backdrop-filter: blur(16px); }
.topbar h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.25rem); line-height: 1; letter-spacing: -.045em; }
.page-actions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; }
.content { padding: 30px clamp(22px, 4vw, 54px) 70px; }

.button { min-height: 42px; border: 1px solid transparent; border-radius: 11px; padding: 10px 16px; font-weight: 850; transition: transform .14s ease, box-shadow .14s ease, background .14s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .58; transform: none; }
.button.primary { color: var(--ink); background: var(--yellow); box-shadow: 0 8px 22px rgba(211,169,0,.2); }
.button.primary:hover { background: #ffdc4b; }
.button.dark { color: white; background: var(--ink); }
.button.ghost { color: var(--ink); border-color: var(--line); background: white; }
.button.danger { color: #fff; background: var(--red); }
.button.small { min-height: 32px; padding: 6px 10px; font-size: .76rem; border-radius: 8px; }
.button.full { width: 100%; }
.icon-button { width: 38px; height: 38px; padding: 0; border: 0; border-radius: 10px; color: var(--ink); background: #eeeae1; font-size: 1.65rem; line-height: 1; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; }
.stat-card { min-height: 150px; padding: 21px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 5px 20px rgba(0,0,0,.025); }
.stat-card.dark { color: white; border-color: var(--ink); background: var(--ink); }
.stat-card.alert { border-color: #f2b6b6; background: linear-gradient(145deg,#fff,var(--red-bg)); }
.stat-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.dark .stat-label { color: #aaa; }
.stat-value { display: block; margin-top: 26px; font-size: clamp(1.55rem, 3vw, 2.35rem); line-height: 1; letter-spacing: -.05em; }
.stat-note { margin: 8px 0 0; color: var(--muted); font-size: .78rem; }
.dark .stat-note { color: #aaa; }
.dot { width: 9px; height: 9px; border-radius: 999px; background: var(--yellow); box-shadow: 0 0 0 5px rgba(255,210,28,.16); }
.alert .dot { background: var(--red); box-shadow: 0 0 0 5px rgba(216,59,59,.13); }

.dashboard-grid { margin-top: 18px; display: grid; grid-template-columns: minmax(0,1.45fr) minmax(310px,.75fr); gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 25px rgba(0,0,0,.025); overflow: hidden; }
.panel-header { padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #ece9e1; }
.panel-header h3 { margin: 0; font-size: 1.02rem; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; }
.panel-body { padding: 20px 22px; }
.chart { height: 245px; display: flex; align-items: flex-end; gap: 9px; padding-top: 18px; }
.chart-column { flex: 1; height: 100%; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; }
.chart-bar-wrap { width: min(26px, 75%); height: calc(100% - 30px); display: flex; align-items: flex-end; border-radius: 8px; background: #f1eee6; overflow: hidden; }
.chart-bar { width: 100%; min-height: 3px; border-radius: 8px 8px 0 0; background: var(--yellow); transition: height .4s ease; }
.chart-column small { color: var(--muted); font-size: .63rem; text-transform: uppercase; }
.chart-column[title] { cursor: help; }
.summary-strip { margin-top: 18px; display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.summary-item { padding: 18px; border-radius: 14px; background: #efede7; }
.summary-item strong { display: block; margin-top: 6px; font-size: 1.15rem; }
.summary-item span { color: var(--muted); font-size: .74rem; font-weight: 800; text-transform: uppercase; }

.list { display: grid; }
.list-item { padding: 15px 0; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; border-bottom: 1px solid #eeeae3; }
.list-item:last-child { border: 0; }
.list-item strong, .list-item span { display: block; }
.list-item small { display: block; margin-top: 4px; color: var(--muted); }
.list-item .amount { text-align: right; }
.list-item .amount strong { font-size: .92rem; }
.list-item .amount small.overdue { color: var(--red); font-weight: 800; }

.toolbar { margin-bottom: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .search { min-width: min(320px,100%); flex: 1; }
.search, .filter { min-height: 42px; border: 1px solid var(--line); border-radius: 11px; padding: 9px 12px; background: white; color: var(--ink); outline: none; }
.search:focus, .filter:focus, input:focus, select:focus, textarea:focus { border-color: var(--yellow-dark); box-shadow: 0 0 0 3px rgba(255,210,28,.2); }

.table-card { border: 1px solid var(--line); border-radius: var(--radius); background: white; overflow: auto; box-shadow: 0 8px 25px rgba(0,0,0,.025); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 13px 16px; color: var(--muted); background: #f4f2ec; font-size: .7rem; text-align: left; text-transform: uppercase; letter-spacing: .07em; }
td { padding: 15px 16px; border-top: 1px solid #efede7; font-size: .86rem; vertical-align: middle; }
td strong { display: block; }
td small { display: block; margin-top: 4px; color: var(--muted); }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.table-empty { padding: 54px 20px; text-align: center; color: var(--muted); }
.table-empty strong { display: block; margin-bottom: 6px; color: var(--ink); }

.status { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 9px; background: #eeece6; color: #5f5d58; font-size: .7rem; font-weight: 850; text-transform: uppercase; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-overdue { color: var(--red); background: var(--red-bg); }
.status-paid, .status-completed { color: var(--blue); background: var(--blue-bg); }
.status-partial, .status-in_progress, .status-due_today { color: #806600; background: #fff4bd; }
.status-pending, .status-active { color: #3e3e3e; background: #eeeae1; }
.status-canceled, .status-waived, .status-inactive { color: #777; background: #ececec; }

.modal { width: min(720px, calc(100% - 26px)); max-height: min(88vh,900px); padding: 0; border: 0; border-radius: 22px; box-shadow: 0 30px 100px rgba(0,0,0,.34); overflow: hidden; }
.modal::backdrop { background: rgba(0,0,0,.67); backdrop-filter: blur(3px); }
.modal form { margin: 0; }
.modal-header { padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-header h3 { margin: 0; font-size: 1.35rem; letter-spacing: -.03em; }
.modal-body { max-height: calc(88vh - 160px); padding: 22px 24px; overflow-y: auto; }
.modal-footer { padding: 15px 24px; display: flex; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); background: #f8f6f1; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.form-grid .wide { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: #44423e; font-size: .76rem; font-weight: 800; }
input, select, textarea { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); background: white; outline: none; font-weight: 550; }
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.check-row { min-height: 46px; padding: 10px 12px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 10px; }
.check-row input { width: 18px; min-height: 18px; accent-color: var(--yellow-dark); }
.stack-lg { display: grid; gap: 17px; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--red); font-size: .82rem; font-weight: 700; }
.field-note { margin: -2px 0 0; color: var(--muted); font-size: .7rem; font-weight: 500; }

.report-layout { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(290px,.6fr); gap: 18px; }
.report-bars { display: grid; gap: 12px; }
.report-row { display: grid; grid-template-columns: 84px 1fr 105px; align-items: center; gap: 12px; font-size: .78rem; }
.report-track { height: 9px; border-radius: 999px; background: #edeae2; overflow: hidden; }
.report-fill { height: 100%; border-radius: inherit; background: var(--yellow); }
.activity { display: grid; gap: 0; }
.activity-item { padding: 13px 0; border-bottom: 1px solid #efede7; }
.activity-item:last-child { border: 0; }
.activity-item strong { font-size: .82rem; }
.activity-item small { display: block; margin-top: 4px; color: var(--muted); }

.loading { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; align-content: center; gap: 13px; color: white; background: rgba(11,11,11,.78); backdrop-filter: blur(4px); }
.loading span { width: 35px; height: 35px; border: 4px solid #555; border-top-color: var(--yellow); border-radius: 50%; animation: spin .8s linear infinite; }
.loading p { margin: 0; font-weight: 800; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-region { position: fixed; z-index: 200; top: 18px; right: 18px; width: min(380px,calc(100% - 36px)); display: grid; gap: 9px; }
.toast { padding: 14px 16px; border-radius: 12px; color: white; background: var(--ink); box-shadow: var(--shadow); font-size: .84rem; font-weight: 700; animation: toast-in .22s ease; }
.toast.error { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
.mobile-nav { display: none; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .dashboard-grid, .report-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .workspace { margin-left: 0; padding-bottom: 72px; }
  .topbar { min-height: 88px; padding: 18px 17px; align-items: flex-end; }
  .topbar .eyebrow { display: none; }
  .topbar h2 { font-size: 1.48rem; }
  .page-actions .button:not(.primary) { display: none; }
  .content { padding: 18px 14px 32px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { min-height: 126px; padding: 16px; }
  .stat-value { margin-top: 20px; font-size: 1.4rem; }
  .stat-label { font-size: .64rem; }
  .dashboard-grid { gap: 12px; }
  .panel-header, .panel-body { padding: 17px; }
  .summary-strip { grid-template-columns: 1fr; }
  .mobile-nav { position: fixed; inset: auto 0 0; z-index: 30; height: 67px; padding: 7px max(8px,env(safe-area-inset-right)) max(7px,env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5,1fr); border-top: 1px solid #303030; background: var(--ink); }
  .mobile-nav button { border: 0; border-radius: 8px; color: #929292; background: transparent; font-size: .62rem; font-weight: 750; }
  .mobile-nav button.active { color: var(--ink); background: var(--yellow); }
  .modal { width: calc(100% - 14px); max-height: 94vh; border-radius: 18px; }
  .modal-body { max-height: calc(94vh - 150px); padding: 18px; }
  .modal-header, .modal-footer { padding: 16px 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .chart { gap: 5px; }
  .chart-column small { transform: rotate(-45deg); margin-bottom: 3px; }
  .report-row { grid-template-columns: 70px 1fr 90px; }
  .login-card { padding: 30px 24px; }
}

@media (max-width: 390px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 115px; }
}
