:root {
  --navy-950: #06111d;
  --navy-900: #081828;
  --navy-800: #102a43;
  --blue-600: #0878d1;
  --blue-500: #1397ef;
  --blue-100: #e8f5ff;
  --orange-600: #d45a12;
  --orange-100: #fff1e8;
  --red-700: #b42318;
  --red-100: #feeceb;
  --green-700: #067647;
  --green-100: #e8f8ef;
  --amber-700: #a15c00;
  --amber-100: #fff5d6;
  --slate-900: #182230;
  --slate-700: #344054;
  --slate-600: #475467;
  --slate-500: #667085;
  --slate-300: #d0d5dd;
  --slate-200: #e4e7ec;
  --slate-100: #f2f4f7;
  --white: #ffffff;
  --surface: #f7f9fc;
  --shadow: 0 10px 30px rgba(8, 24, 40, .10);
  --radius-lg: 20px;
  --radius-md: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--slate-900); background: var(--surface); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--surface); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: var(--blue-600); }
[hidden] { display: none !important; }

.connection-bar { position: fixed; z-index: 1000; inset: 0 0 auto; padding: calc(8px + var(--safe-top)) 16px 8px; background: var(--red-700); color: white; text-align: center; font-size: .86rem; font-weight: 700; }

.login-screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 32px 18px; background: radial-gradient(circle at 80% 10%, #194c78 0, var(--navy-900) 40%, var(--navy-950) 100%); }
.login-card { width: min(100%, 440px); background: rgba(255,255,255,.98); border-radius: 26px; padding: 30px; box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.brand-mark { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: linear-gradient(145deg, var(--blue-500), var(--orange-600)); color: white; font-weight: 900; letter-spacing: -.05em; font-size: 1.25rem; margin-bottom: 20px; }
.login-card h1 { margin: 4px 0 10px; font-size: clamp(1.8rem, 7vw, 2.5rem); letter-spacing: -.04em; }

.app-shell { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(82px + var(--safe-bottom)); }
.topbar { position: sticky; z-index: 40; top: 0; min-height: calc(66px + var(--safe-top)); padding: calc(10px + var(--safe-top)) 14px 10px; background: rgba(8,24,40,.97); color: white; display: grid; grid-template-columns: 46px 1fr 46px; align-items: center; gap: 8px; backdrop-filter: blur(14px); }
.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.topbar-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.04rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .09em; font-size: .68rem; font-weight: 800; color: var(--blue-500); }
.topbar .eyebrow { color: #8fd4ff; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 13px; display: inline-grid; place-items: center; background: rgba(255,255,255,.10); color: inherit; font-size: 1.35rem; }
.notification-button { position: relative; }
.notification-badge { position: absolute; right: -2px; top: -3px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center; background: var(--orange-600); color: white; font-size: .68rem; font-weight: 900; border: 2px solid var(--navy-900); }

.main-content { width: min(100%, 1180px); margin: 0 auto; padding: 18px 14px 30px; outline: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin: 4px 0 18px; }
.page-head h1 { margin: 0; font-size: clamp(1.55rem, 5vw, 2.2rem); letter-spacing: -.035em; }
.page-head p { margin: 5px 0 0; color: var(--slate-600); }

.bottom-nav { position: fixed; z-index: 45; inset: auto 0 0; height: calc(66px + var(--safe-bottom)); padding: 5px 7px var(--safe-bottom); display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(255,255,255,.97); border-top: 1px solid var(--slate-200); box-shadow: 0 -12px 30px rgba(8,24,40,.08); backdrop-filter: blur(16px); }
.bottom-nav button { border: 0; background: transparent; color: var(--slate-600); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px; font-size: .67rem; font-weight: 750; border-radius: 12px; }
.bottom-nav button span { font-size: 1.25rem; line-height: 1; }
.bottom-nav button.active { color: var(--blue-600); background: var(--blue-100); }
.bottom-nav .nav-emphasis span { width: 36px; height: 36px; margin-top: -18px; border-radius: 13px; display: grid; place-items: center; background: var(--blue-600); color: white; box-shadow: 0 7px 18px rgba(8,120,209,.34); }

.side-menu { position: fixed; z-index: 90; inset: 0; }
.side-menu-backdrop { position: absolute; inset: 0; background: rgba(6,17,29,.58); }
.side-menu-panel { position: absolute; inset: 0 auto 0 0; width: min(86vw, 350px); padding: calc(20px + var(--safe-top)) 14px calc(18px + var(--safe-bottom)); background: white; display: flex; flex-direction: column; gap: 4px; box-shadow: 20px 0 60px rgba(0,0,0,.25); animation: slideIn .18s ease-out; }
.side-menu-panel > button { width: 100%; border: 0; background: transparent; padding: 13px 14px; text-align: left; border-radius: 12px; font-weight: 700; color: var(--slate-700); }
.side-menu-panel > button:hover, .side-menu-panel > button.active { background: var(--blue-100); color: var(--blue-600); }
.side-profile { display: flex; align-items: center; gap: 12px; padding: 8px 8px 18px; border-bottom: 1px solid var(--slate-200); margin-bottom: 8px; }
.side-profile div:last-child { display: flex; flex-direction: column; }
.side-profile span { color: var(--slate-500); font-size: .84rem; text-transform: capitalize; }
.avatar { width: 44px; height: 44px; border-radius: 14px; background: var(--navy-900); color: white; display: grid; place-items: center; font-weight: 900; }
.menu-spacer { flex: 1; }
.danger-text { color: var(--red-700) !important; }
@keyframes slideIn { from { transform: translateX(-100%); } to { transform: translateX(0); } }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-bottom: 18px; }
.metric { border-radius: var(--radius-md); background: white; border: 1px solid var(--slate-200); padding: 14px; min-height: 100px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 3px 10px rgba(8,24,40,.035); }
.metric .value { font-size: 1.65rem; font-weight: 900; letter-spacing: -.04em; }
.metric .label { color: var(--slate-600); font-size: .78rem; font-weight: 700; }
.metric.danger { background: var(--red-100); border-color: #f7b8b3; }
.metric.warning { background: var(--amber-100); border-color: #f4d58d; }
.metric.money { background: var(--green-100); border-color: #9ad9b9; }

.card { background: white; border: 1px solid var(--slate-200); border-radius: var(--radius-lg); box-shadow: 0 3px 14px rgba(8,24,40,.045); overflow: hidden; }
.card + .card { margin-top: 12px; }
.card-body { padding: 16px; }
.card-header { padding: 15px 16px 11px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--slate-100); }
.card-header h2, .card-header h3 { margin: 0; font-size: 1rem; }
.card-title { margin: 0 0 5px; font-size: 1rem; line-height: 1.35; }
.card-subtitle { color: var(--slate-600); font-size: .84rem; line-height: 1.4; }
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.clickable { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.clickable:active { transform: scale(.99); }

.section { margin: 22px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 1.08rem; }
.section-head .count { color: var(--slate-500); font-size: .8rem; }
.empty { text-align: center; padding: 30px 18px; color: var(--slate-500); background: white; border: 1px dashed var(--slate-300); border-radius: var(--radius-lg); }

.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.quick-action { min-height: 94px; border: 1px solid var(--slate-200); border-radius: var(--radius-md); background: white; text-align: left; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; font-weight: 800; color: var(--slate-900); }
.quick-action span { font-size: 1.35rem; }
.quick-action.primary { background: linear-gradient(145deg, var(--blue-600), #07579e); color: white; border-color: transparent; }
.quick-action.orange { background: linear-gradient(145deg, var(--orange-600), #a93c06); color: white; border-color: transparent; }

.button { border: 1px solid var(--slate-300); border-radius: 12px; padding: 10px 14px; background: white; color: var(--slate-700); font-weight: 800; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; text-decoration: none; }
.button.primary { background: var(--blue-600); border-color: var(--blue-600); color: white; }
.button.secondary { background: var(--navy-900); border-color: var(--navy-900); color: white; }
.button.orange { background: var(--orange-600); border-color: var(--orange-600); color: white; }
.button.danger { background: var(--red-700); border-color: var(--red-700); color: white; }
.button.success { background: var(--green-700); border-color: var(--green-700); color: white; }
.button.ghost { background: transparent; }
.button.small { min-height: 34px; padding: 7px 10px; font-size: .8rem; border-radius: 10px; }
.button.large { width: 100%; min-height: 52px; font-size: 1rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 9px; }

.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 4px 8px; background: var(--slate-100); color: var(--slate-700); font-size: .7rem; font-weight: 850; text-transform: uppercase; letter-spacing: .03em; }
.badge.red { background: var(--red-100); color: var(--red-700); }
.badge.green { background: var(--green-100); color: var(--green-700); }
.badge.amber { background: var(--amber-100); color: var(--amber-700); }
.badge.blue { background: var(--blue-100); color: var(--blue-600); }
.badge.orange { background: var(--orange-100); color: var(--orange-600); }

.task-card, .obligation-card, .project-card, .fee-card { padding: 15px; }
.task-card.overdue, .obligation-card.overdue, .fee-card.overdue { border-left: 5px solid var(--red-700); }
.task-meta, .project-meta, .money-meta { display: flex; flex-wrap: wrap; gap: 7px 12px; color: var(--slate-600); font-size: .8rem; margin-top: 8px; }
.task-footer, .project-footer, .fee-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 13px; }
.amount { font-weight: 900; font-variant-numeric: tabular-nums; }
.amount.large { font-size: 1.45rem; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; background: var(--slate-200); }
.timeline-item { position: relative; padding: 0 0 18px; }
.timeline-item::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue-500); border: 2px solid white; box-shadow: 0 0 0 2px var(--blue-500); }
.timeline-item p { margin: 4px 0; }
.timeline-item time { color: var(--slate-500); font-size: .75rem; }

.stack { display: grid; gap: 10px; }
.stack-lg { display: grid; gap: 16px; }
.form-grid { display: grid; gap: 13px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
label { display: grid; gap: 6px; color: var(--slate-700); font-size: .82rem; font-weight: 800; }
input, textarea, select { width: 100%; border: 1px solid var(--slate-300); border-radius: 12px; padding: 11px 12px; background: white; color: var(--slate-900); min-height: 45px; outline: none; }
textarea { min-height: 105px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(19,151,239,.14); }
input[type="file"] { padding: 9px; }
.field-with-action { position: relative; }
.field-with-action textarea, .field-with-action input { padding-right: 52px; }
.field-action { position: absolute; right: 7px; top: 7px; width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--blue-100); color: var(--blue-600); }
.help { color: var(--slate-500); font-size: .76rem; font-weight: 500; }
.error-text { color: var(--red-700); font-size: .8rem; }
.required::after { content: " *"; color: var(--red-700); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { display: grid; place-items: center; min-height: 54px; border: 1px solid var(--slate-300); border-radius: 12px; text-align: center; padding: 8px; background: white; }
.segmented input:checked + label { background: var(--blue-100); border-color: var(--blue-600); color: var(--blue-600); box-shadow: 0 0 0 2px rgba(8,120,209,.12); }

.item-block { border: 1px solid var(--slate-200); border-radius: 15px; padding: 13px; background: var(--slate-100); }
.item-block + .item-block { margin-top: 10px; }
.item-block-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.filter-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip { white-space: nowrap; border: 1px solid var(--slate-300); border-radius: 999px; padding: 8px 12px; background: white; color: var(--slate-700); font-weight: 750; font-size: .8rem; }
.filter-chip.active { background: var(--navy-900); color: white; border-color: var(--navy-900); }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 12px; }

.modal { position: fixed; z-index: 100; inset: 0; display: grid; align-items: end; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6,17,29,.65); backdrop-filter: blur(3px); }
.modal-panel { position: relative; width: min(100%, 680px); max-height: min(92vh, 900px); margin: 0 auto; background: white; border-radius: 24px 24px 0 0; box-shadow: var(--shadow); overflow: hidden; animation: modalUp .2s ease-out; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--slate-200); }
.modal-header h2 { margin: 0; font-size: 1.15rem; }
.modal-header .icon-button { color: var(--slate-700); background: var(--slate-100); }
.modal-body { padding: 17px 18px calc(24px + var(--safe-bottom)); overflow-y: auto; max-height: calc(92vh - 68px); }
@keyframes modalUp { from { transform: translateY(28px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.toast-region { position: fixed; z-index: 120; left: 12px; right: 12px; bottom: calc(82px + var(--safe-bottom)); display: grid; gap: 8px; pointer-events: none; }
.toast { max-width: 580px; margin: 0 auto; width: 100%; background: var(--navy-900); color: white; border-radius: 13px; padding: 12px 14px; box-shadow: var(--shadow); animation: toastIn .2s ease-out; }
.toast.error { background: var(--red-700); }
.toast.success { background: var(--green-700); }
@keyframes toastIn { from { transform: translateY(15px); opacity: 0; } }

.skeleton { min-height: 92px; border-radius: var(--radius-md); background: linear-gradient(90deg, #edf0f4 25%, #f7f8fa 45%, #edf0f4 65%); background-size: 400% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.muted { color: var(--slate-600); }
.small { font-size: .78rem; }
.tiny { font-size: .7rem; }
.text-right { text-align: right; }
.divider { height: 1px; background: var(--slate-200); margin: 16px 0; }
.note { border-radius: 13px; padding: 11px 13px; background: var(--blue-100); color: var(--navy-800); font-size: .84rem; }
.note.warning { background: var(--amber-100); color: #734000; }
.note.danger { background: var(--red-100); color: var(--red-700); }
.kv { display: grid; grid-template-columns: minmax(100px, .7fr) 1fr; gap: 8px 14px; font-size: .86rem; }
.kv dt { color: var(--slate-500); }
.kv dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

@media (min-width: 720px) {
  .main-content { padding: 26px 24px 46px; }
  .metrics { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .quick-actions { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .modal { align-items: center; padding: 20px; }
  .modal-panel { border-radius: 24px; }
  .grid.responsive-two { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (min-width: 1000px) {
  .app-shell { padding-left: 250px; padding-bottom: 0; }
  .topbar { margin-left: -250px; padding-left: 264px; }
  .bottom-nav { display: none; }
  #menuButton { visibility: hidden; }
  .side-menu { display: block !important; position: fixed; width: 250px; right: auto; }
  .side-menu-backdrop { display: none; }
  .side-menu-panel { width: 250px; box-shadow: none; border-right: 1px solid var(--slate-200); animation: none; padding-top: calc(84px + var(--safe-top)); }
  .modal-panel { max-height: 88vh; }
}
