:root {
  --green-950: #07211B;
  --green-900: #0B2E26;
  --green-800: #113B31;
  --green-700: #175448;
  --green-600: #1D6B58;
  --green-100: #E6F2ED;
  --accent: #F97316;
  --accent-600: #EA580C;
  --accent-100: #FFF1E6;
  --bg: #F3F6F4;
  --card: #FFFFFF;
  --line: #E3EAE5;
  --line-strong: #CFDAD3;
  --text: #132420;
  --muted: #64776F;
  --danger: #D62828;
  --danger-100: #FDECEC;
  --warn: #C2760A;
  --warn-100: #FDF3E2;
  --ok: #157F4B;
  --ok-100: #E7F6ED;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(16, 42, 34, .06), 0 8px 24px rgba(16, 42, 34, .05);
  --shadow-lg: 0 18px 50px rgba(9, 32, 26, .18);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: pan-y;
}

body { overflow-x: hidden; }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.num, .money, table td.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- layout */

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--green-900), var(--green-950));
  color: #EAF3EF;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #FB923C);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 6px 16px rgba(249, 115, 22, .35);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: #8FB4A6; text-transform: uppercase; letter-spacing: .12em; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 11px;
  color: #C7DBD2;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 18px; height: 18px; opacity: .9; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: rgba(249, 115, 22, .16); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 12px;
  color: #7FA294;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .05);
}
.sidebar-user .avatar { background: rgba(249, 115, 22, .25); color: #FFD9BC; }
.sidebar-user small { display: block; color: #8FB4A6; font-size: 11px; }
.sidebar-user strong { font-size: 13px; color: #F4FBF8; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--green-900);
  color: #F2FAF6;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .brand-mark { width: 30px; height: 30px; font-size: 15px; border-radius: 9px; }
.topbar-title { display: flex; align-items: center; gap: 9px; font-weight: 700; }

.content { padding: 26px 30px 60px; max-width: 1280px; width: 100%; }

.bottom-nav { display: none; }
.fab { display: none; }

/* ---------------------------------------------------------------- page */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.eyebrow {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .09em;
  margin-bottom: 6px;
  font-weight: 600;
}
.page-head h1 { font-size: 26px; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 5px; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid > *, .stack > *, .cols > * { min-width: 0; }
.grid.kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: 1.35fr 1fr; align-items: start; }
.grid.halves { grid-template-columns: 1fr 1fr; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
  max-width: 100%;
}
.card.tight { padding: 14px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.card-head h2 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.card-head .hint { font-size: 12px; color: var(--muted); }
.card-head a { font-size: 13px; color: var(--green-700); font-weight: 600; }

.kpi-card { display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden; }
.kpi-card .label { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.kpi-card .value { font-size: 23px; font-weight: 700; letter-spacing: -.02em; }
.kpi-card .foot { font-size: 12px; color: var(--muted); }
.kpi-card.accent { background: linear-gradient(135deg, var(--green-800), var(--green-600)); border-color: transparent; color: #F3FBF7; }
.kpi-card.accent .label, .kpi-card.accent .foot { color: #B7D8CA; }
.kpi-card.warn { background: linear-gradient(135deg, #FFF7ED, #FFEDD5); border-color: #FDD9AE; }
.kpi-card.warn .value { color: #9A3412; }
.kpi-icon {
  position: absolute; right: 14px; top: 14px;
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(19, 36, 32, .05);
  color: var(--green-700);
}
.kpi-card.accent .kpi-icon { background: rgba(255, 255, 255, .12); color: #FFE2CE; }
.kpi-card.warn .kpi-icon { background: rgba(249, 115, 22, .14); color: var(--accent-600); }

.progress { height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #FB923C); border-radius: inherit; }
.progress.green > span { background: linear-gradient(90deg, var(--green-600), #34A387); }

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: transform .04s ease, background .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:hover { background: #F8FAF9; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(249, 115, 22, .28); }
.btn.primary:hover { background: var(--accent-600); }
.btn.green { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.btn.green:hover { background: var(--green-800); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: #EEF3F0; color: var(--text); }
.btn.danger { background: var(--danger-100); border-color: #F6C6C6; color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.icon-btn:hover { color: var(--text); background: #F8FAF9; }

/* ---------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field label .req { color: var(--accent); }
.input, select.input, textarea.input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14.5px;
  outline: none;
  transition: border .15s ease, box-shadow .15s ease;
}
.input:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(29, 107, 88, .12); }
textarea.input { resize: vertical; min-height: 74px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search .input { padding-left: 36px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--muted);
  border-radius: 99px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
}
.chip.active { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.chip .count { opacity: .75; font-weight: 500; margin-left: 5px; }

/* --------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 650;
  padding: 0 10px 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }
td.actions { text-align: right; white-space: nowrap; }
tbody tr:hover { background: #FAFCFB; }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 650;
  background: #EEF3F0;
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-100); color: var(--ok); }
.badge.warn { background: var(--warn-100); color: var(--warn); }
.badge.danger { background: var(--danger-100); color: var(--danger); }
.badge.info { background: #E8F1FF; color: #1D4ED8; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------------------------------------------------------- lists */

.list { display: flex; flex-direction: column; min-width: 0; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { min-width: 0; flex: 1; }
.list-row .title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.list-row .meta { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.list-row .amount { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--green-100); color: var(--green-700);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex: none;
  text-transform: uppercase;
}

.hero {
  background: linear-gradient(135deg, var(--green-900), var(--green-700));
  color: #F2FAF6;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
}
.hero .label { font-size: 12.5px; color: #A9CDbd; text-transform: uppercase; letter-spacing: .09em; font-weight: 650; }
.hero .big { font-size: 32px; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; }
.hero .foot { font-size: 12.5px; color: #A9CDBD; margin-top: 6px; }

.empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--muted);
  font-size: 14px;
}
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* ---------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(7, 32, 26, .48);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fade .12s ease;
}
.modal {
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: min(560px, 100%);
  max-height: min(88vh, 760px);
  overflow: auto;
  animation: pop .14s ease;
}
.modal.wide { width: min(760px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 0;
  gap: 10px;
}
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 16px 20px 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 0 20px 20px;
}
.modal-foot.between { justify-content: space-between; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- toast */

#toast-root {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 120;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--green-900);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .16s ease;
}
.toast.error { background: #7F1D1D; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- login */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--bg);
}
.auth-brand {
  background:
    radial-gradient(circle at 18% 18%, rgba(249, 115, 22, .28), transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(34, 145, 118, .35), transparent 48%),
    linear-gradient(160deg, var(--green-900), var(--green-950));
  color: #F3FBF7;
  padding: 54px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 26px;
}
.auth-brand .brand-mark { width: 52px; height: 52px; font-size: 24px; border-radius: 15px; }
.auth-brand h1 { font-size: 40px; letter-spacing: -.03em; }
.auth-brand p { color: #B6D5C8; font-size: 15.5px; line-height: 1.6; max-width: 420px; }
.auth-points { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.auth-points li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: #CFE6DC; }
.auth-points svg { width: 18px; height: 18px; color: #6EE7B7; flex: none; margin-top: 1px; }
.auth-panel { display: grid; place-items: center; padding: 32px; }
.auth-card { width: min(400px, 100%); padding: 28px; }
.auth-card h2 { font-size: 22px; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.auth-card .field { margin-bottom: 14px; }
.auth-note { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* --------------------------------------------------------------- mobile */

@media (max-width: 1080px) {
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .grid.halves { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { display: flex; }
  .content { padding: 16px 14px 96px; }
  .page-head h1 { font-size: 22px; }
  .page-head { margin-bottom: 14px; }
  .grid { gap: 12px; }
  .card { padding: 15px; border-radius: 14px; }
  .hero { padding: 18px; }
  .hero .big { font-size: 27px; }
  .kpi-card .value { font-size: 20px; }
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--line);
    padding: 7px 4px calc(7px + env(safe-area-inset-bottom));
    z-index: 40;
  }
  .bottom-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10.5px; color: var(--muted); font-weight: 600;
    padding: 4px 0; border-radius: 9px;
  }
  .bottom-item svg { width: 20px; height: 20px; }
  .bottom-item.active { color: var(--green-700); }
  .fab {
    display: grid; place-items: center;
    position: fixed;
    right: 16px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: 0;
    box-shadow: 0 12px 26px rgba(249, 115, 22, .42);
    z-index: 41;
  }
  .fab svg { width: 24px; height: 24px; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .modal { width: 100%; max-height: 92vh; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .list-row .amount { font-size: 13.5px; }
  th, td { padding-left: 6px; padding-right: 6px; }
}

@media (max-width: 520px) {
  .grid.kpi { grid-template-columns: 1fr 1fr; }
  .kpi-card .value { font-size: 18px; }
  .head-actions .btn span { display: none; }
  .hero { flex-wrap: wrap; }
  .hero > * { min-width: 0; }
  .card-head { flex-wrap: wrap; }
  .list-row { flex-wrap: nowrap; gap: 8px; }
  .list-row .amount { flex: none; }
  .list-row .btn.small { flex: none; }
}
