:root {
  --navy: #1f2a44;
  --navy-2: #2b3a5c;
  --bg: #f1f3f7;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #ffb000;
  --link: #2c3ea8;
  --green: #16a34a;  --green-d: #0f6b31;
  --purple: #7c3aed; --purple-d: #5b21b6;
  --orange: #f59e0b; --orange-d: #a16207;
  --blue: #2563eb;   --blue-d: #1d4ed8;
  --red: #dc2626;
  --radius: 8px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
.boot { padding: 60px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.neg { color: var(--red); }
.pos { color: var(--green); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: 62px; background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
}
.brand { display: flex; align-items: baseline; gap: 4px; color: #fff; font-weight: 800; font-size: 22px; letter-spacing: .3px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--brand); }
.brand sup { font-size: 12px; font-weight: 600; margin-left: 2px; }
.burger { display: none; background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }
.topbar .spacer { flex: 1; }
.btn-wa { background: #25d366; color: #fff; border-radius: 6px; padding: 7px 14px; font-weight: 600; }
.btn-wa:hover { text-decoration: none; filter: brightness(.95); }
.search { display: flex; background: #fff; border-radius: 4px; overflow: hidden; width: min(420px, 32vw); }
.search input { border: 0; padding: 8px 12px; flex: 1; outline: none; min-width: 0; }
.search button { border: 0; background: #fff; padding: 0 12px; cursor: pointer; }
.user-menu { position: relative; }
.user-btn { background: none; border: 0; color: #fff; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #fff; color: var(--navy); display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.dropdown { position: absolute; right: 0; top: 46px; background: #fff; color: var(--text); border-radius: 6px; box-shadow: 0 8px 30px rgba(0,0,0,.18); min-width: 200px; padding: 6px 0; }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: 9px 16px; color: var(--text); background: none; border: 0; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--bg); text-decoration: none; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: calc(100vh - 62px); }
.sidebar { width: 270px; flex-shrink: 0; background: #fff; padding: 14px 0 30px; position: sticky; top: 62px; height: calc(100vh - 62px); overflow-y: auto; }
.side-title { font-size: 13px; font-weight: 600; letter-spacing: .4px; color: #374151; padding: 16px 22px 6px; display: flex; align-items: center; gap: 8px; text-transform: uppercase; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; color: #fff; background: var(--green); border-radius: 4px; padding: 2px 7px; text-transform: uppercase; }
.badge.red { background: var(--red); }
.nav-group > button, .nav-link {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 22px 9px 26px; background: none; border: 0;
  color: var(--text); cursor: pointer; text-align: left; font-size: 15px;
}
.nav-group > button:hover, .nav-link:hover { background: #f6f7fb; text-decoration: none; }
.nav-link.active { background: #eef1ff; color: var(--link); font-weight: 600; box-shadow: inset 3px 0 0 var(--link); }
.nav-ico { width: 24px; text-align: center; font-weight: 800; }
.nav-group .chev { margin-left: auto; color: var(--muted); transition: transform .15s; }
.nav-group.open .chev { transform: rotate(90deg); }
.nav-sub { display: none; padding: 2px 0 6px; }
.nav-group.open .nav-sub { display: block; }
.nav-sub a { display: block; padding: 7px 22px 7px 62px; color: #374151; font-size: 14px; }
.nav-sub a:hover { background: #f6f7fb; text-decoration: none; }
.nav-sub a.active { color: var(--link); font-weight: 600; }
.main { flex: 1; min-width: 0; padding: 24px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0 0 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; margin-bottom: 24px; }
.card.teal { background: #0d9488; } .card.teal .card-foot { background: #0f766e; }
.pts { color: var(--green); font-weight: 700; font-size: 13px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.doc-card { border: 1px solid var(--line); border-radius: 6px; padding: 14px; border-top: 4px solid #d1d5db; }
.doc-card.st-approved { border-top-color: var(--green); }
.doc-card.st-pending { border-top-color: var(--orange); }
.doc-card.st-rejected { border-top-color: var(--red); }
.doc-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.doc-file { display: flex; gap: 12px; margin-top: 10px; align-items: flex-start; word-break: break-all; }
.doc-file img, .pdf-ico { width: 72px; height: 54px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); flex-shrink: 0; }
.pdf-ico { display: grid; place-items: center; background: #fee2e2; color: var(--red); font-weight: 800; font-size: 13px; }
label.btn.disabled { opacity: .55; pointer-events: none; }
.doc-preview { width: 100%; height: 60vh; border: 1px solid var(--line); border-radius: 6px; background: #f8fafc; }
img.doc-preview { object-fit: contain; height: auto; max-height: 60vh; }
.attach-box { border: 1px dashed #c7d2fe; background: #f5f7ff; border-radius: 6px; padding: 12px 14px; }
.field-title { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: #374151; }
.att-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.att-list li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 6px 10px; }
.att-list li button { margin-left: auto; }
.redeem-box { border: 1px dashed #86efac; background: #f0fdf4; border-radius: 6px; padding: 12px 14px; }
.card { border-radius: 4px; color: #fff; overflow: hidden; display: flex; flex-direction: column; min-height: 186px; }
.card-body { padding: 22px 24px 16px; position: relative; flex: 1; }
.card h4 { margin: 0 0 10px; font-size: 15px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; opacity: .95; }
.card .big { font-size: 26px; font-weight: 700; margin: 4px 0 6px; }
.card .line { font-weight: 600; font-size: 15px; line-height: 1.6; }
.card .sub { font-size: 13px; font-weight: 600; }
.card .ico { position: absolute; right: 22px; top: 22px; font-size: 44px; opacity: .45; }
.card-foot { display: block; text-align: right; padding: 11px 20px; color: #fff; font-size: 15px; }
.card-foot:hover { text-decoration: none; filter: brightness(1.1); }
.card.green { background: var(--green); } .card.green .card-foot { background: var(--green-d); }
.card.purple { background: var(--purple); } .card.purple .card-foot { background: var(--purple-d); }
.card.orange { background: var(--orange); } .card.orange .card-foot { background: var(--orange-d); }
.card.blue { background: var(--blue); } .card.blue .card-foot { background: var(--blue-d); }

.panel { background: var(--panel); border-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,.05); margin-bottom: 24px; }
.panel-head { padding: 14px 20px; border-bottom: 1px solid var(--line); font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-body { padding: 18px 20px; }
.dash-grid { display: grid; grid-template-columns: 1fr 366px; gap: 24px; align-items: start; }

/* tabs */
.tabs { display: flex; background: #000; overflow-x: auto; }
.tabs button { flex: 1; background: none; border: 0; color: #fff; padding: 15px 18px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tabs button.active { background: #fff; color: #111; }
.tabs.light { background: #fff; border-bottom: 1px solid var(--line); }
.tabs.light button { color: var(--muted); flex: 0 0 auto; }
.tabs.light button.active { color: var(--link); box-shadow: inset 0 -3px 0 var(--link); }

/* news */
.news-item { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.news-item:last-child { border-bottom: 0; }
.news-date { color: var(--red); font-style: italic; font-size: 14px; margin-bottom: 6px; }
.news-title { color: var(--link); font-size: 17px; font-weight: 500; cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.news-cat { font-size: 11px; background: #eef1ff; color: var(--link); border-radius: 3px; padding: 2px 6px; margin-left: 6px; vertical-align: middle; }
.news-body { margin-top: 12px; line-height: 1.6; }
.news-body ul { margin: 6px 0; padding-left: 22px; }

/* product showcase */
.showcase { padding: 18px; }
.showcase-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.chip { background: var(--blue); color: #fff; font-weight: 700; padding: 6px 10px; border-radius: 3px; font-size: 18px; text-transform: uppercase; }
.chip.sale { background: var(--red); } .chip.popular { background: var(--orange); }
.prod-card { border: 1px solid var(--line); border-radius: 4px; padding: 16px; text-align: center; position: relative; }
.prod-card .tag { position: absolute; left: 10px; top: 10px; font-size: 11px; }
.prod-ico { font-size: 72px; line-height: 1.2; margin: 14px 0 8px; }
.prod-name { color: var(--link); font-weight: 600; margin-bottom: 8px; }
.strike { text-decoration: line-through; color: var(--muted); }
.price { color: var(--red); font-size: 22px; font-weight: 700; }
.carousel-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

.grid-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.grid-products .prod-card { background: #fff; display: flex; flex-direction: column; }
.grid-products .prod-card .desc { font-size: 13px; color: var(--muted); flex: 1; margin-bottom: 10px; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; background: var(--link); color: #fff; padding: 8px 16px; border-radius: 5px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.light { background: #fff; color: var(--text); border-color: #d1d5db; }
.btn.green { background: var(--green); } .btn.red { background: var(--red); } .btn.orange { background: var(--orange); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #374151; }
.field input, .field select, .field textarea, .inline-input {
  width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 5px; background: #fff; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus, .inline-input:focus { border-color: var(--link); box-shadow: 0 0 0 3px rgba(44,62,168,.12); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field.full { grid-column: 1 / -1; }
.inline-input { width: auto; padding: 6px 9px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* tables */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; background: #f8fafc; color: #374151; font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:hover td { background: #fafbff; }
.tbl tfoot td { font-weight: 700; background: #f8fafc; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px !important; font-style: italic; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 20px; padding: 2px 10px; text-transform: capitalize; background: #e5e7eb; color: #374151; white-space: nowrap; }
.pill.pending { background: #fef3c7; color: #92400e; }
.pill.approved, .pill.active, .pill.paid { background: #dcfce7; color: #166534; }
.pill.rejected, .pill.cancelled, .pill.suspended, .pill.void { background: #fee2e2; color: #991b1b; }
.pill.unpaid { background: #dbeafe; color: #1e40af; }
.pill.t-sale { background: #e0e7ff; color: #3730a3; }
.pill.t-subscription { background: #dcfce7; color: #166534; }
.pill.t-recurring { background: #cffafe; color: #155e75; }
.pill.t-recruitment { background: #f3e8ff; color: #6b21a8; }
.pill.t-clawback { background: #fee2e2; color: #991b1b; }
.pill.t-adjustment { background: #fef3c7; color: #92400e; }

/* misc blocks */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: #fff; border-radius: 6px; padding: 16px 18px; border-left: 4px solid var(--link); }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.stat .v { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat.g { border-color: var(--green); } .stat.o { border-color: var(--orange); } .stat.p { border-color: var(--purple); } .stat.r { border-color: var(--red); }
.note { background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 12px 16px; font-size: 14px; line-height: 1.6; }
.note.info { background: #eff6ff; border-color: #bfdbfe; }
.note ul { margin: 4px 0 0; padding-left: 20px; }
.level-head { font-weight: 700; padding: 12px 20px; background: #f8fafc; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.copy-box { display: flex; gap: 8px; }
.copy-box input { flex: 1; }
.plan-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.plan-strip .lv { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.plan-strip .lv b { display: block; margin-bottom: 6px; }

/* network tree */
.tree, .tree ul { list-style: none; margin: 0; padding-left: 22px; }
.tree { padding-left: 0; }
.tree li { position: relative; padding: 4px 0 4px 16px; }
.tree li::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; border-left: 1px dashed #cbd5e1; }
.tree li::after { content: ""; position: absolute; left: 0; top: 19px; width: 12px; border-top: 1px dashed #cbd5e1; }
.tree li:last-child::before { height: 19px; }
.node { display: inline-flex; gap: 8px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; flex-wrap: wrap; }
.node .lvl { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 3px; color: #fff; }
.lvl-1 { background: #64748b; } .lvl-2 { background: #b8860b; } .lvl-3 { background: #9ca3af; } .lvl-x { background: #cbd5e1; color: #334155 !important; }
.node .toggle { cursor: pointer; border: 0; background: none; color: var(--link); font-weight: 700; padding: 0 4px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 8px; width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 17px; display: flex; align-items: center; }
.modal-head button { margin-left: auto; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: linear-gradient(135deg, var(--navy), #3b4f86); color: #fff; padding: 60px; display: flex; flex-direction: column; justify-content: center; }
.auth-hero h1 { font-size: 40px; margin: 0 0 14px; }
.auth-hero h1 b { color: var(--brand); }
.auth-hero p { font-size: 17px; line-height: 1.6; opacity: .92; max-width: 520px; }
.auth-hero ul { line-height: 2; font-size: 16px; padding-left: 20px; }
.auth-box { display: grid; place-items: center; padding: 30px 16px; }
.auth-card { background: #fff; border-radius: 10px; padding: 32px; width: min(420px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.auth-card h2 { margin: 0 0 6px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 12px 20px; border-radius: 6px; z-index: 200; box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: calc(100vw - 32px); }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

/* responsive */
@media (max-width: 1150px) { .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .burger { display: block; }
  .search, .btn-wa { display: none; }
  .sidebar { position: fixed; left: 0; top: 62px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  body.nav-open .sidebar { transform: none; }
  .main { padding: 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 36px 20px; }
  .auth-hero h1 { font-size: 30px; }
  .user-btn .uid { display: none; }
}
@media (max-width: 600px) {
  .cards { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .brand { font-size: 18px; }
  .topbar { padding: 0 12px; gap: 10px; }
}
