:root {
  --bg: #FCFAFA;
  --card: #ffffff;
  --text: #1F1A1C;
  --muted: #7F7378;
  --line: #E8E1E3;
  --primary: #74243B;
  --primary-2: #8C3049;
  --primary-soft: #F5E3E8;
  --primary-tint: #FBF4F6;
  --gold: #B8913F;
  --gold-soft: #F5ECD6;
  --danger: #dc2626;
  --ok: #15803d;
  --warn: #9C7A31;
  --shadow: 0 6px 20px rgba(69, 20, 35, .07);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
h1 { font-size: 22px; margin: 0; font-weight: 700; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 14px; margin: 18px 0 8px; font-weight: 700; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand.center { justify-content: center; color: var(--muted); font-size: 15px; }
.login-logo { width: 150px; height: 150px; justify-self: center; }
.side-logo { width: 38px; height: 38px; border-radius: 50%; background: #fff; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 50% 0, var(--primary-soft), var(--bg) 60%); }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 12px; }

/* Layout */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, #5E1C30, #2E0D18); color: #F5E3E8; padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { color: #EAC5CF; text-decoration: none; padding: 10px 12px; border-radius: 12px; display: flex; align-items: center; gap: 10px; transition: background .15s; }
.sidebar nav a .ico { width: 18px; text-align: center; opacity: .8; }
.sidebar nav a.active, .sidebar nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.count { margin-left: auto; background: var(--gold); color: #33280F; border-radius: 999px; padding: 1px 8px; font-size: 11px; }
.sidebar .me { margin-top: auto; display: grid; gap: 10px; font-size: 13px; }
.main { padding: 26px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .spacer { flex: 1; }

/* Cards & tiles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .card, .drawer { animation: none !important; transition: none !important; } }
.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.tile .label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.tile .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12px; color: var(--muted); }
.tile.hero { background: linear-gradient(135deg, var(--primary-2), #5E1C30); color: #fff; border: 0; }
.tile.hero .label, .tile.hero .sub { color: #F5E3E8; }
.tile.link { cursor: pointer; }
.tile.link:hover { border-color: var(--primary-soft); }

/* Chart */
.chart { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; align-items: end; height: 150px; padding-top: 8px; }
.chart .col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 4px; min-width: 0; }
.chart .bar { width: 100%; max-width: 26px; border-radius: 6px 6px 2px 2px; background: var(--primary); min-height: 2px; transition: height .4s ease; }
.chart .bar.gold { background: var(--gold); }
.chart .lbl { font-size: 10px; color: var(--muted); white-space: nowrap; }
.chart .val { font-size: 10px; color: var(--text); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 40px; gap: 10px; align-items: center; font-size: 13px; text-decoration: none; color: inherit; }
.track { height: 9px; background: var(--primary-tint); border-radius: 6px; overflow: hidden; }
.track > span { display: block; height: 100%; background: var(--primary); border-radius: 6px; }

/* Forms */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
input, select, textarea { font: inherit; border: 1.5px solid var(--line); border-radius: 12px; padding: 9px 11px; background: #fff; color: var(--text); width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px var(--primary-soft); }
.toolbar input, .toolbar select { width: auto; min-width: 140px; }
label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; font-weight: 500; }
.check input { width: auto; }
.form-section { grid-column: 1 / -1; font-size: 12px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 12px; }

/* Buttons */
.btn { border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 12px; padding: 9px 15px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .12s ease, box-shadow .2s ease, background .2s ease; white-space: nowrap; }
.btn:hover { box-shadow: 0 4px 14px rgba(116, 36, 59, .15); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--primary-2), var(--primary)); border-color: var(--primary); color: #fff; }
.btn.gold { background: linear-gradient(135deg, #D9BD7C, var(--gold)); border: 0; color: #33280F; }
.btn.call { background: #ecfdf3; border-color: #bbf7d0; color: var(--ok); }
.btn.wa { background: #f0fdf4; border-color: #bbf7d0; color: #128c7e; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(255, 255, 255, .25); }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: default; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; background: var(--primary-tint); text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--primary-tint); }
tbody tr.clickable { cursor: pointer; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.name-cell b { display: block; }
.name-cell span { font-size: 12px; color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #f1f0f0; color: #473F42; }
.badge.applied, .badge.contacted { background: #ede9fe; color: #5b21b6; }
.badge.under_review, .badge.follow_up { background: var(--gold-soft); color: #7E6227; }
.badge.shortlisted, .badge.interested { background: #e0f2fe; color: #075985; }
.badge.interview_scheduled { background: var(--primary-soft); color: var(--primary); }
.badge.selected, .badge.paid, .badge.open, .badge.registered { background: #dcfce7; color: #166534; }
.badge.rejected, .badge.failed, .badge.closed, .badge.not_interested { background: #fee2e2; color: #991b1b; }
.badge.withdrawn, .badge.created { background: #f1f0f0; color: #5F5559; }
.badge.new { background: var(--primary); color: #fff; }
.badge.premium { background: var(--gold-soft); color: #7E6227; }
.badge.hot { background: #ffedd5; color: #9a3412; }
.badge.reg { background: var(--primary-soft); color: var(--primary); }
.badge.overdue { background: #fee2e2; color: #991b1b; }
.badge.callback { background: #fff7ed; color: #c2410c; }

/* Follow-up cards */
.fu-list { display: grid; gap: 12px; }
.fu { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.fu.overdue { border-left: 4px solid var(--danger); }
.fu .who b { font-size: 15px; }
.fu .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.fu .note { margin-top: 6px; font-size: 13px; background: var(--primary-tint); border-radius: 10px; padding: 7px 10px; }

/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(31, 26, 28, .35); z-index: 20; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(640px, 100vw); background: var(--bg); z-index: 21; box-shadow: -10px 0 30px rgba(0, 0, 0, .15); transform: translateX(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); overflow-y: auto; }
.drawer.open { transform: none; }
.drawer:not(.open) { pointer-events: none; }
#drawer-body { padding: 22px; display: grid; gap: 14px; }
.d-head { display: flex; gap: 12px; align-items: flex-start; }
.d-head .avatar { width: 52px; height: 52px; border-radius: 16px; background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; display: grid; place-items: center; font-size: 20px; font-weight: 700; flex-shrink: 0; }
.d-head h2 { margin: 0; }
.d-head .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 16px; }
.badge.pending, .badge.answered { background: var(--gold-soft); color: #7E6227; }
.badge.approved { background: #dcfce7; color: #166534; }
.badge.blocked { background: #fee2e2; color: #991b1b; }
.ticket { display: grid; gap: 8px; }
.ticket .msg { background: var(--primary-tint); border-radius: 10px; padding: 8px 11px; white-space: pre-wrap; }
.ticket .reply { background: #ecfdf3; border-radius: 10px; padding: 8px 11px; white-space: pre-wrap; }
.tabs { display: flex; gap: 4px; background: var(--primary-tint); border: 1px solid var(--primary-soft); padding: 4px; border-radius: 14px; }
.tabs button { flex: 1; border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--muted); padding: 8px; border-radius: 10px; cursor: pointer; }
.tabs button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 7px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; border-left: 2px solid var(--line); padding-left: 14px; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline li.payment::before { background: var(--ok); }
.timeline li.callback_request::before { background: #ea580c; }
.timeline .when { color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.quick button:hover { border-color: var(--primary-2); color: var(--primary); }

/* Modal & toast */
dialog { border: 0; border-radius: 20px; padding: 0; width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog[open] { animation: pop .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
dialog::backdrop { background: rgba(31, 26, 28, .45); }
#modal-body { padding: 24px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.error { color: var(--danger); min-height: 1em; margin: 0; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #2E0D18; color: #fff; padding: 12px 18px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); z-index: 50; animation: rise .25s ease; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 12px 16px; gap: 10px; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .sidebar .me { margin: 0; display: flex; flex-wrap: wrap; align-items: center; }
  .main { padding: 16px; }
  .kv { grid-template-columns: 1fr; }
  .chart .lbl { display: none; }
  .fu { grid-template-columns: 1fr; }
}
