:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e4e7ee;
  --border-strong: #d3d8e2;
  --text: #121826;
  --text-2: #4a5468;
  --muted: #7b8497;
  --accent: #4338ca;
  --accent-600: #3730a3;
  --accent-50: #eef0ff;
  --accent-100: #e0e3ff;
  --sidebar: #0f1424;
  --sidebar-2: #1a2036;
  --sidebar-text: #aab2c8;
  --green: #0f9d63; --green-50: #e6f6ee;
  --amber: #b7791f; --amber-50: #fdf4e3;
  --red: #d64545;   --red-50: #fdecec;
  --blue: #2563eb;  --blue-50: #e8f0fe;
  --violet: #7c3aed; --violet-50: #f1eafe;
  --slate-50: #eef0f4;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .18);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 4px; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #6366f1, #4338ca); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 17px; box-shadow: 0 4px 14px rgba(99, 102, 241, .4); }
.brand-name { color: #fff; font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5e6782; padding: 14px 10px 6px; }
.nav button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; color: var(--sidebar-text); padding: 9px 10px; border-radius: 8px; cursor: pointer; text-align: left; font-weight: 500; }
.nav button:hover { background: var(--sidebar-2); color: #fff; }
.nav button.active { background: rgba(99, 102, 241, .18); color: #fff; }
.nav button.active svg { color: #a5b4fc; }
.nav .count { margin-left: auto; background: #6366f1; color: #fff; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 12px 6px 0; border-top: 1px solid #222a42; }
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.me-name { color: #fff; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-mail { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { overflow-y: auto; min-width: 0; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 26px 32px 18px; }
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; font-weight: 680; }
.topbar p { margin: 4px 0 0; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.view { padding: 0 32px 40px; }

/* ---------- Buttons & Inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border-strong); background: var(--surface); padding: 8px 13px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 550; box-shadow: var(--shadow-sm); white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); border-color: #c3c9d6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-600); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.success:hover { filter: brightness(.95); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; border: 1px solid transparent; background: none; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--slate-50); }
.icon-btn.ghost-dark { color: var(--sidebar-text); }
.icon-btn.ghost-dark:hover { background: var(--sidebar-2); color: #fff; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field > span em { font-style: normal; color: var(--muted); font-weight: 400; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius-sm); padding: 8px 11px; outline: none; transition: border-color .12s, box-shadow .12s; }
textarea.input { resize: vertical; min-height: 78px; line-height: 1.45; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-100); }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 32px; min-width: 260px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }

.segmented { display: inline-flex; background: var(--slate-50); padding: 3px; border-radius: 9px; gap: 2px; flex-wrap: wrap; }
.segmented button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 550; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented button .n { font-size: 11px; color: var(--muted); font-weight: 600; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card-body { padding: 16px 18px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 550; display: flex; align-items: center; gap: 7px; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.03em; margin-top: 8px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-icon { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; }
.kpi-icon svg { width: 14px; height: 14px; }

.dash-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.dash-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.pipeline { display: flex; flex-direction: column; gap: 12px; }
.pipe-row { display: grid; grid-template-columns: 110px 1fr 90px; gap: 12px; align-items: center; }
.pipe-bar { height: 10px; border-radius: 999px; background: var(--slate-50); overflow: hidden; }
.pipe-bar > div { height: 100%; border-radius: 999px; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.list-item:last-child { border-bottom: 0; }
.list-item.click { cursor: pointer; }
.list-item.click:hover { background: var(--surface-2); }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); }
.empty svg { width: 28px; height: 28px; color: #b8bfcd; margin-bottom: 8px; }
.empty strong { display: block; color: var(--text-2); margin-bottom: 4px; }

/* ---------- Table ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table th:first-child { border-top-left-radius: var(--radius); }
.table th:last-child { border-top-right-radius: var(--radius); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr:hover td { background: #fafbfd; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }

/* ---------- Badges & Avatare ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge svg.i { width: 12px; height: 12px; }
.b-slate { background: var(--slate-50); color: var(--text-2); }
.b-blue { background: var(--blue-50); color: var(--blue); }
.b-violet { background: var(--violet-50); color: var(--violet); }
.b-amber { background: var(--amber-50); color: var(--amber); }
.b-green { background: var(--green-50); color: var(--green); }
.b-red { background: var(--red-50); color: var(--red); }
.b-accent { background: var(--accent-50); color: var(--accent); }

.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; flex: none; letter-spacing: .02em; }
.avatar.lg { width: 36px; height: 36px; font-size: 13px; }
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.who { display: inline-flex; align-items: center; gap: 8px; }

.due-over { color: var(--red); font-weight: 600; }
.due-today { color: var(--amber); font-weight: 600; }

/* ---------- Kanban ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #eef0f5; border-radius: var(--radius); padding: 10px; min-height: 300px; display: flex; flex-direction: column; gap: 8px; transition: background .12s; }
.col.over { background: var(--accent-100); }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 6px; font-weight: 650; font-size: 13px; }
.col-head .muted { font-weight: 500; font-size: 12px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px; box-shadow: var(--shadow-sm); cursor: grab; }
.kcard:hover { border-color: #c7cde0; }
.kcard.dragging { opacity: .5; }
.kcard-title { font-weight: 600; margin-bottom: 3px; }
.kcard-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 12px; }

/* ---------- Drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 20, 36, .28); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(620px, 100vw); background: var(--surface); z-index: 41; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.drawer-body { overflow-y: auto; padding: 20px 24px 40px; flex: 1; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; margin: 22px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.section-title:first-child { margin-top: 0; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.info-grid .k { font-size: 12px; color: var(--muted); }
.info-grid .v { margin-top: 2px; word-break: break-word; }
.next-box { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--accent-50); border: 1px solid var(--accent-100); border-radius: var(--radius-sm); }
.next-box svg { color: var(--accent); margin-top: 2px; }
.quick { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 12px; }

.timeline { position: relative; display: flex; flex-direction: column; gap: 4px; }
.tl-item { display: grid; grid-template-columns: 34px 1fr; gap: 12px; position: relative; padding-bottom: 16px; }
.tl-item::before { content: ""; position: absolute; left: 16px; top: 34px; bottom: 0; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.tl-head strong { font-weight: 650; }
.tl-text { margin-top: 6px; line-height: 1.5; white-space: pre-wrap; color: var(--text-2); }
.tl-agree { margin-top: 8px; padding: 9px 12px; border-left: 3px solid var(--green); background: var(--green-50); border-radius: 0 7px 7px 0; white-space: pre-wrap; line-height: 1.45; }
.tl-agree b { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--green); margin-bottom: 2px; }
.tl-del { opacity: 0; }
.tl-item:hover .tl-del { opacity: 1; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 20, 36, .45); z-index: 60; display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: min(640px, 100%); box-shadow: var(--shadow-lg); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .16s ease; }
.modal.wide { width: min(820px, 100%); }
.modal > form { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 40px); }
.modal { overflow: hidden; }
@keyframes pop { from { transform: translateY(6px) scale(.985); opacity: 0; } }
.modal-head { padding: 20px 24px 6px; }
.modal-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.modal-head p { margin: 6px 0 0; color: var(--muted); line-height: 1.45; }
.modal-body { padding: 16px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 24px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); }
.callout { display: flex; gap: 10px; padding: 11px 13px; border-radius: var(--radius-sm); background: var(--accent-50); color: var(--accent-600); line-height: 1.45; font-size: 13px; }
.callout svg { margin-top: 2px; }
.divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #e3e6ff 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #e9ecf7 0, transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); padding: 32px; }
.auth-card .brand { padding: 0 0 22px; }
.auth-card .brand-name { color: var(--text); }
.auth-card .brand-sub { color: var(--muted); }
.auth-card h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.02em; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; }
.auth-card.wide { width: min(520px, 100%); }
.mfa-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-50); color: var(--accent); margin-bottom: 14px; }
.mfa-icon svg { width: 22px; height: 22px; }
.mfa-icon.ok { background: var(--green-50); color: var(--green); }
.code-input { font-size: 22px; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; padding: 12px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
.mfa-steps { margin: 18px 0 4px; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; line-height: 1.5; color: var(--text-2); }
.qr-box { display: grid; place-items: center; margin: 12px 0 6px; }
.qr-box svg { width: 190px; height: 190px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.secret { display: inline-block; padding: 8px 10px; background: var(--slate-50); border-radius: 7px; font-size: 13px; letter-spacing: .06em; word-break: break-all; user-select: all; }
details summary { cursor: pointer; color: var(--accent); }
.codes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.codes-grid code { padding: 8px 10px; background: var(--slate-50); border-radius: 7px; text-align: center; font-size: 14px; letter-spacing: .08em; user-select: all; }
.callout.warn { background: var(--amber-50); color: #8a5a12; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #141a2e; color: #fff; padding: 11px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; animation: pop .18s ease; max-width: 420px; }
.toast.error { background: var(--red); }
.toast svg { color: #6ee7b7; }
.toast.error svg { color: #fff; }

.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-50); }

.import-preview { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.import-preview table { font-size: 12.5px; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-50); color: var(--accent); }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { flex-direction: row; align-items: center; padding: 8px 12px; gap: 8px; overflow-x: auto; }
  .brand { padding: 0; }
  .brand > div:last-child, .nav-label, .me > div, .nav .count { display: none; }
  .nav { flex-direction: row; }
  .nav button span { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .topbar, .view { padding-left: 16px; padding-right: 16px; }
  .grid-2, .grid-3, .info-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .search .input { min-width: 0; }
}
