:root {
  --navy: #081426;
  --navy-2: #0f2038;
  --navy-3: #18304d;
  --green: #14975b;
  --green-soft: #e9f8f0;
  --red: #d94a4a;
  --red-soft: #fff0f0;
  --orange: #e48422;
  --orange-soft: #fff4e9;
  --yellow: #f0b429;
  --yellow-soft: #fff8df;
  --white: #ffffff;
  --gray-25: #fbfcfe;
  --gray-50: #f6f8fb;
  --gray-100: #eef2f6;
  --gray-200: #dde4ec;
  --gray-300: #c9d3df;
  --gray-500: #718096;
  --gray-700: #364152;
  --text: #172033;
  --shadow: 0 18px 50px rgba(9, 24, 45, .10);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--gray-50); }
body { margin: 0; min-height: 100vh; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--gray-50); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 20% 10%, rgba(33, 92, 150, .28), transparent 34%), linear-gradient(150deg, #06101e 0%, #0b1d34 60%, #102843 100%); }
.login-card { width: min(100%, 460px); padding: 42px; border: 1px solid rgba(255,255,255,.10); background: rgba(255,255,255,.98); border-radius: 28px; box-shadow: 0 40px 100px rgba(0,0,0,.30); position: relative; overflow: hidden; }
.login-card::before { content: ""; position: absolute; inset: 0 auto auto 0; width: 100%; height: 6px; background: linear-gradient(90deg, var(--green), #55c58f, var(--yellow)); }
.login-brand { display: inline-flex; margin-bottom: 24px; }
.login-brand img, .sidebar-brand img { width: 150px; height: auto; object-fit: contain; }
.login-mark { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; background: var(--navy); color: white; font-weight: 900; font-size: 22px; margin-bottom: 22px; }
.login-kicker, .top-kicker, .modal-kicker { margin: 0 0 7px; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--green); }
.login-card h1 { margin: 0; color: var(--navy); font-size: clamp(26px, 5vw, 36px); line-height: 1.05; }
.login-subtitle { margin: 8px 0 28px; color: var(--gray-500); font-weight: 800; letter-spacing: .08em; }
.stack-form { display: grid; gap: 16px; }
.stack-form label, .field { display: grid; gap: 7px; color: var(--gray-700); font-weight: 700; font-size: 13px; }
input, select, textarea { width: 100%; border: 1px solid var(--gray-200); background: white; color: var(--text); border-radius: 12px; padding: 12px 13px; outline: none; transition: border .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { border-color: #6aa7d8; box-shadow: 0 0 0 4px rgba(65, 139, 194, .12); }
textarea { min-height: 96px; resize: vertical; }
.form-error { margin: 0; padding: 11px 12px; border-radius: 10px; background: var(--red-soft); color: #9f2626; font-weight: 700; }
.login-footer { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--gray-100); color: var(--gray-500); font-size: 12px; display: flex; align-items: center; gap: 8px; }

.button { border: 0; border-radius: 12px; padding: 11px 15px; font-weight: 800; transition: transform .16s, opacity .16s, box-shadow .16s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.button-primary { background: var(--green); color: white; box-shadow: 0 10px 24px rgba(20, 151, 91, .20); }
.button-dark { background: var(--navy); color: white; }
.button-danger { background: var(--red); color: white; }
.button-outline { background: white; color: var(--navy); border: 1px solid var(--gray-200); }
.button-soft { background: var(--gray-100); color: var(--navy); }
.button-wide { width: 100%; }
.icon-button { width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--gray-200); background: white; color: var(--navy); display: inline-grid; place-items: center; font-size: 20px; }
.text-button { border: 0; background: transparent; color: #cbd6e4; padding: 8px 0; font-weight: 700; text-align: left; }

.app { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 262px; padding: 22px 16px; background: var(--navy); color: white; z-index: 30; display: flex; flex-direction: column; box-shadow: 8px 0 30px rgba(5, 18, 33, .10); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 20px; }
.sidebar-brand { display: flex; filter: brightness(0) invert(1); }
.sidebar-close { display: none; }
.main-nav { display: grid; gap: 4px; overflow-y: auto; padding-right: 3px; }
.nav-item { border: 0; background: transparent; color: #c8d3e0; padding: 11px 12px; border-radius: 11px; text-align: left; display: flex; gap: 11px; align-items: center; font-weight: 700; font-size: 13px; }
.nav-item span { width: 19px; text-align: center; color: #8ea7c2; }
.nav-item:hover { background: rgba(255,255,255,.06); color: white; }
.nav-item.active { background: white; color: var(--navy); }
.nav-item.active span { color: var(--green); }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.09); padding: 18px 8px 0; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--green); display: grid; place-items: center; font-weight: 900; }
.user-chip small, .user-chip strong { display: block; }
.user-chip small { font-size: 10px; color: #91a5bb; text-transform: uppercase; letter-spacing: .08em; }
.user-chip strong { font-size: 12px; margin-top: 2px; }

.workspace { min-height: 100vh; margin-left: 262px; }
.topbar { min-height: 86px; position: sticky; top: 0; z-index: 20; background: rgba(246,248,251,.93); backdrop-filter: blur(16px); border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 28px; }
.topbar-left { display: flex; align-items: center; gap: 13px; }
.topbar-left h1 { margin: 0; font-size: 24px; color: var(--navy); }
.top-kicker { color: var(--gray-500); font-size: 9px; margin-bottom: 3px; }
.topbar-actions { display: flex; align-items: end; gap: 10px; }
.global-search { width: 260px; padding: 9px 11px; background: white; align-self: flex-end; }
.month-select-wrap { display: grid; gap: 4px; font-size: 10px; font-weight: 800; color: var(--gray-500); text-transform: uppercase; letter-spacing: .06em; }
.month-select-wrap input { width: 164px; padding: 9px 10px; background: white; }
.menu-button { display: none; }
.content-wrap { padding: 26px 28px 80px; max-width: 1500px; margin: 0 auto; }
.loading-state { position: fixed; z-index: 60; left: 50%; top: 22px; transform: translateX(-50%); background: var(--navy); color: white; border-radius: 999px; padding: 10px 16px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 12px; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 20px; }
.page-head h2 { margin: 0 0 4px; color: var(--navy); font-size: 24px; }
.page-head p { margin: 0; color: var(--gray-500); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.metrics-grid { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.metric-card { background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 17px; min-width: 0; position: relative; overflow: hidden; }
.metric-card::after { content: ""; width: 70px; height: 70px; border-radius: 50%; position: absolute; right: -25px; bottom: -31px; background: var(--gray-100); opacity: .8; }
.metric-card small { color: var(--gray-500); font-size: 10px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; display: block; margin-bottom: 8px; }
.metric-card strong { display: block; color: var(--navy); font-size: clamp(18px, 2vw, 25px); line-height: 1.1; white-space: nowrap; }
.metric-card.green { border-top: 4px solid var(--green); }
.metric-card.red { border-top: 4px solid var(--red); }
.metric-card.orange { border-top: 4px solid var(--orange); }
.metric-card.yellow { border-top: 4px solid var(--yellow); }
.metric-card.free { border-top: 4px solid var(--green); background: linear-gradient(135deg, #fff, #f1fcf6); }
.metric-card.free.warning { border-top-color: var(--yellow); background: linear-gradient(135deg, #fff, #fff9e8); }
.metric-card.free.danger { border-top-color: var(--red); background: linear-gradient(135deg, #fff, #fff2f2); }
.metric-note { margin-top: 7px; color: var(--gray-500); font-size: 10px; position: relative; z-index: 1; }

.dashboard-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; margin-bottom: 16px; }
.panel { background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 18px; box-shadow: 0 4px 18px rgba(20, 31, 46, .03); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-head h3 { margin: 0; color: var(--navy); font-size: 16px; }
.panel-head span, .panel-head small { color: var(--gray-500); font-size: 11px; }
.finance-breakdown { display: grid; gap: 9px; }
.breakdown-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--gray-200); font-size: 12px; }
.breakdown-row:last-child { border-bottom: 0; }
.breakdown-row strong { color: var(--navy); }
.breakdown-row.total { margin-top: 2px; padding: 12px; border: 0; border-radius: 12px; background: var(--gray-50); font-weight: 900; }
.breakdown-row.total strong { font-size: 18px; }

.alerts { display: grid; gap: 9px; }
.alert { display: flex; align-items: flex-start; gap: 10px; border-radius: 12px; padding: 11px 12px; background: var(--yellow-soft); border: 1px solid #f7e3a4; color: #7a5a00; font-size: 12px; font-weight: 700; }
.alert.danger { background: var(--red-soft); border-color: #f2cccc; color: #9f2929; }
.alert.info { background: #edf6ff; border-color: #cfe5fa; color: #265f8d; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-top: 4px; flex: 0 0 auto; }
.empty-state { color: var(--gray-500); text-align: center; padding: 26px 12px; font-size: 12px; }

.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.quick-card { border: 1px solid var(--gray-200); border-radius: 15px; background: white; padding: 15px; text-align: left; }
.quick-card strong { display: block; margin-bottom: 5px; color: var(--navy); }
.quick-card small { color: var(--gray-500); }
.quick-card:hover { border-color: #a7b6c7; box-shadow: 0 8px 24px rgba(10,30,50,.06); }

.chart-bars { height: 170px; display: flex; align-items: end; justify-content: center; gap: 28px; padding: 10px 14px 0; border-bottom: 1px solid var(--gray-200); }
.bar-group { display: flex; align-items: end; gap: 8px; height: 100%; position: relative; padding-bottom: 26px; }
.bar { width: 28px; min-height: 3px; border-radius: 7px 7px 2px 2px; background: var(--green); position: relative; transition: height .3s; }
.bar.expense { background: var(--red); }
.bar-label { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); font-size: 9px; color: var(--gray-500); white-space: nowrap; }
.chart-legend { display: flex; gap: 14px; margin-top: 10px; font-size: 10px; color: var(--gray-500); }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 5px; }
.legend-dot.red { background: var(--red); }
.category-bars { display: grid; gap: 10px; }
.category-line { display: grid; grid-template-columns: 115px 1fr 85px; gap: 9px; align-items: center; font-size: 11px; }
.category-track { height: 8px; background: var(--gray-100); border-radius: 999px; overflow: hidden; }
.category-fill { height: 100%; border-radius: inherit; background: var(--navy-3); }
.category-value { text-align: right; font-weight: 800; color: var(--navy); }

.movement-list { display: grid; }
.movement-row { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.movement-row:last-child { border-bottom: 0; }
.movement-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); font-weight: 900; }
.movement-icon.expense { background: var(--red-soft); color: var(--red); }
.movement-copy strong, .movement-copy small { display: block; }
.movement-copy strong { font-size: 12px; color: var(--navy); }
.movement-copy small { margin-top: 2px; font-size: 10px; color: var(--gray-500); }
.movement-value { font-size: 12px; font-weight: 900; color: var(--green); }
.movement-value.expense { color: var(--red); }

.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 1 1 250px; }
.toolbar select { width: auto; min-width: 150px; }
.table-card { background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 840px; }
th { background: var(--navy); color: white; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; text-align: left; padding: 12px 13px; white-space: nowrap; }
td { padding: 12px 13px; border-bottom: 1px solid var(--gray-100); font-size: 12px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fcfdff; }
.money-positive { color: var(--green); font-weight: 900; }
.money-negative { color: var(--red); font-weight: 900; }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; background: var(--gray-100); color: var(--gray-700); white-space: nowrap; }
.status.received, .status.paid, .status.active { background: var(--green-soft); color: #087244; }
.status.pending, .status.paused { background: var(--yellow-soft); color: #876100; }
.status.overdue, .status.ended { background: var(--red-soft); color: #a12929; }
.actions { display: flex; gap: 5px; flex-wrap: wrap; }
.mini-button { border: 1px solid var(--gray-200); background: white; color: var(--navy); border-radius: 8px; padding: 6px 8px; font-size: 10px; font-weight: 800; }
.mini-button.primary { background: var(--green); color: white; border-color: var(--green); }
.mini-button.danger { color: var(--red); }
.table-total { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 16px; background: var(--gray-25); border-top: 1px solid var(--gray-200); font-size: 12px; }
.table-total strong { font-size: 17px; color: var(--navy); }

.installment-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.installment-card { background: white; border: 1px solid var(--gray-200); border-top: 4px solid var(--orange); border-radius: var(--radius); padding: 17px; }
.installment-card h3 { margin: 0 0 4px; color: var(--navy); font-size: 15px; }
.installment-card p { margin: 0; color: var(--gray-500); font-size: 11px; }
.progress { height: 10px; background: var(--gray-100); border-radius: 999px; overflow: hidden; margin: 15px 0 7px; }
.progress > span { display: block; height: 100%; background: var(--orange); border-radius: inherit; }
.installment-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 15px 0; }
.stat-box { background: var(--orange-soft); border-radius: 10px; padding: 9px; }
.stat-box small { display: block; color: #9a642c; font-size: 9px; text-transform: uppercase; font-weight: 900; }
.stat-box strong { display: block; color: #6f4216; margin-top: 3px; font-size: 12px; }

.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.summary-item { background: white; border: 1px solid var(--gray-200); border-radius: 14px; padding: 14px; }
.summary-item small { display: block; font-size: 9px; color: var(--gray-500); text-transform: uppercase; font-weight: 900; margin-bottom: 6px; }
.summary-item strong { color: var(--navy); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.field.full { grid-column: 1 / -1; }
.checkbox-field { display: flex; align-items: center; gap: 9px; padding: 11px 12px; border: 1px solid var(--gray-200); border-radius: 11px; background: var(--gray-25); }
.checkbox-field input { width: 18px; height: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--gray-100); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-section { background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 18px; }
.settings-section h3 { margin: 0 0 14px; color: var(--navy); font-size: 16px; }
.tags-editor { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.tag { display: inline-flex; gap: 6px; align-items: center; background: var(--gray-100); color: var(--navy); border-radius: 999px; padding: 6px 9px; font-size: 10px; font-weight: 800; }
.tag button { border: 0; background: transparent; color: var(--red); font-weight: 900; padding: 0; }
.add-tag { display: flex; gap: 6px; margin-top: 10px; }
.add-tag input { min-width: 0; }

.report-sheet { background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 24px; }
.report-title { display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid var(--navy); padding-bottom: 14px; margin-bottom: 18px; }
.report-title h2 { margin: 0; color: var(--navy); }
.report-title p { margin: 4px 0 0; color: var(--gray-500); font-size: 11px; }
.report-logo { width: 120px; }
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.report-box { background: var(--gray-50); border-radius: 10px; padding: 12px; }
.report-box small { display: block; color: var(--gray-500); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.report-box strong { display: block; margin-top: 5px; color: var(--navy); }

.modal { border: 0; padding: 0; background: transparent; max-width: none; max-height: none; width: 100vw; height: 100vh; }
.modal::backdrop { background: rgba(5, 14, 27, .66); backdrop-filter: blur(3px); }
.modal-card { width: min(760px, calc(100vw - 26px)); max-height: calc(100vh - 34px); margin: 17px auto; background: white; border-radius: 22px; box-shadow: 0 35px 90px rgba(0,0,0,.30); display: flex; flex-direction: column; overflow: hidden; }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.modal-head h2 { margin: 0; color: var(--navy); font-size: 20px; }
.modal-kicker { margin-bottom: 3px; }
.modal-body { padding: 20px; overflow-y: auto; }

.toast { position: fixed; z-index: 100; right: 20px; top: 20px; max-width: 380px; border-radius: 12px; background: var(--navy); color: white; padding: 12px 15px; box-shadow: var(--shadow); font-size: 12px; font-weight: 800; }
.toast.success { background: #087244; }
.toast.error { background: #a82929; }

.fab { display: none; position: fixed; z-index: 24; right: 18px; bottom: 18px; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--green); color: white; font-size: 30px; box-shadow: 0 14px 35px rgba(20,151,91,.35); }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(6, 16, 30, .55); z-index: 29; }

@media (max-width: 1220px) {
  .metrics-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .installment-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 980px) {
  .sidebar { transform: translateX(-105%); transition: transform .22s ease; width: 278px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-button { display: inline-grid; }
  .workspace { margin-left: 0; }
  .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 700px) {
  .login-card { padding: 30px 22px; border-radius: 22px; }
  .topbar { padding: 11px 14px; min-height: 72px; }
  .topbar-left h1 { font-size: 18px; }
  .top-kicker { display: none; }
  .topbar-actions .button { display: none; }
  .global-search { display: none; }
  .month-select-wrap span { display: none; }
  .month-select-wrap input { width: 132px; padding: 8px 9px; font-size: 11px; }
  .content-wrap { padding: 16px 12px 90px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
  .metric-card { padding: 13px; border-radius: 14px; }
  .metric-card strong { font-size: 18px; }
  .metric-card:nth-child(1), .metric-card:nth-child(2) { display: none; }
  .quick-grid { display: none; }
  .page-head { display: grid; }
  .page-actions { width: 100%; }
  .page-actions .button { flex: 1 1 auto; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .installment-grid { grid-template-columns: 1fr; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .report-grid { grid-template-columns: 1fr 1fr; }
  .category-line { grid-template-columns: 88px 1fr 75px; }
  .fab { display: block; }
  .modal-card { width: calc(100vw - 14px); max-height: calc(100vh - 14px); margin: 7px auto; border-radius: 18px; }
  .modal-body { padding: 16px; }
  .toast { left: 12px; right: 12px; top: 12px; max-width: none; }
}

@media print {
  body { background: white; }
  .sidebar, .topbar, .fab, .page-head, .toolbar, .page-actions, .button, .mini-button, .toast { display: none !important; }
  .workspace { margin: 0; }
  .content-wrap { padding: 0; }
  .report-sheet { border: 0; padding: 0; }
  .panel, .table-card { break-inside: avoid; box-shadow: none; }
}
