:root {
  --bg: #08111f;
  --panel: #0e1a2b;
  --panel-2: #132238;
  --text: #f5f7fb;
  --muted: #9fb0c8;
  --line: #21334d;
  --accent: #4da3ff;
  --accent-2: #7bc1ff;
  --success: #4fd18b;
  --warning: #f4c35c;
  --danger: #ff6b6b;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, #102a4d 0, var(--bg) 34%);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(460px, 100%);
  background: rgba(14,26,43,.95);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #1e6fe8);
  color: white;
  font-weight: 900;
  font-size: 25px;
  box-shadow: 0 10px 24px rgba(77,163,255,.28);
}
.brand-mark.small { width: 40px; height: 40px; font-size: 19px; border-radius: 11px; }
.eyebrow { margin: 20px 0 6px; color: var(--accent-2); font-size: 12px; letter-spacing: .16em; font-weight: 800; }
h1,h2,h3,p { margin-top: 0; }
h1 { font-size: 34px; margin-bottom: 10px; }
h2 { margin-bottom: 0; }
h3 { margin-bottom: 10px; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 14px; margin-top: 24px; }
label { display: grid; gap: 7px; color: #cbd7e7; font-size: 14px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  color: var(--text);
  background: #091524;
  border: 1px solid #2a3e5c;
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(77,163,255,.12); }
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  color: white;
  background: var(--panel-2);
  font-weight: 750;
}
.btn.primary { background: linear-gradient(135deg, var(--accent), #237de9); }
.btn.ghost { border-color: var(--line); background: transparent; }
.btn.small { padding: 7px 10px; font-size: 13px; }
.btn.danger { border-color: rgba(255,107,107,.3); color: #ffb0b0; background: rgba(255,107,107,.08); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 20px 0; font-size: 12px; }
.divider::before,.divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.connection-note { margin: 16px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(7,16,29,.94);
  padding: 22px 16px;
  display: flex; flex-direction: column;
}
.brand-row { display: flex; align-items: center; gap: 11px; margin: 0 7px 25px; }
.brand-row strong { display: block; }
.brand-row small { color: var(--muted); display: block; margin-top: 2px; }
#mainNav { display: grid; gap: 6px; }
.nav-btn {
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: #c6d2e2;
  padding: 11px 12px;
  border-radius: 9px;
  font-weight: 650;
}
.nav-btn:hover,.nav-btn.active { background: #11243d; border-color: #1f3a5e; color: white; }
.sidebar-bottom { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.badge {
  display: inline-flex; align-items: center;
  border-radius: 999px; padding: 5px 9px;
  background: rgba(77,163,255,.12); color: var(--accent-2);
  border: 1px solid rgba(77,163,255,.25);
  font-size: 12px; font-weight: 800;
}

.workspace { min-width: 0; }
.topbar {
  padding: 24px 30px 18px;
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(8,17,31,.72);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 3;
}
.topbar .eyebrow { margin: 0 0 5px; }
.top-actions { display: flex; gap: 9px; }
#pageRoot { padding: 28px 30px 50px; }

.grid { display: grid; gap: 16px; }
.metrics { grid-template-columns: repeat(4, minmax(0,1fr)); margin-bottom: 20px; }
.card {
  background: linear-gradient(180deg, rgba(19,34,56,.92), rgba(13,25,42,.92));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { font-size: 30px; font-weight: 900; margin-top: 7px; }
.metric-note { margin-top: 6px; color: var(--muted); font-size: 12px; }
.two-col { grid-template-columns: 1.2fr .8fr; align-items: start; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-head h3 { margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th,td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
td a { color: var(--accent-2); text-decoration: none; }
.status {
  display: inline-flex; padding: 4px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 800; border: 1px solid var(--line);
}
.status.ready,.status.booked,.status.completed,.status.active { color: #84e3af; border-color: rgba(79,209,139,.3); background: rgba(79,209,139,.08); }
.status.due,.status.new,.status.draft { color: #ffd980; border-color: rgba(244,195,92,.3); background: rgba(244,195,92,.08); }
.status.paused,.status.lost { color: #ffabab; border-color: rgba(255,107,107,.3); background: rgba(255,107,107,.08); }

.task {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.task:last-child { border-bottom: 0; }
.task input { width: auto; margin-top: 3px; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-title { font-weight: 700; }
.task-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.empty { text-align: center; padding: 32px 18px; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input,.toolbar select { width: auto; min-width: 180px; }
.toolbar .grow { flex: 1; min-width: 220px; }

.lead-board { display: grid; grid-template-columns: repeat(5, minmax(190px,1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.lead-col { min-height: 300px; background: rgba(8,17,31,.48); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.lead-col h4 { margin: 0 0 10px; font-size: 13px; color: #ced9e8; }
.lead-card { background: var(--panel-2); border: 1px solid #26405f; border-radius: 10px; padding: 11px; margin-bottom: 9px; }
.lead-card strong { display: block; margin-bottom: 4px; }
.lead-card small { color: var(--muted); }
.lead-card .mini-actions { margin-top: 9px; display: flex; gap: 6px; }
.mini-btn { padding: 4px 7px; border-radius: 7px; border: 1px solid var(--line); background: transparent; color: #c9d6e6; font-size: 11px; }

.bar-list { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 45px; align-items: center; gap: 10px; font-size: 13px; }
.bar-track { height: 10px; border-radius: 999px; background: #081421; overflow: hidden; border: 1px solid #1e3149; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #77bfff); border-radius: inherit; }

.note {
  border-left: 3px solid var(--accent);
  background: rgba(77,163,255,.07);
  padding: 12px 14px;
  color: #cbd9ea;
  border-radius: 0 9px 9px 0;
  font-size: 13px; line-height: 1.5;
}
.settings-list { display: grid; gap: 14px; }
.setting-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

dialog {
  border: 0;
  padding: 0;
  border-radius: 16px;
  width: min(620px, calc(100vw - 28px));
  background: var(--panel);
  color: white;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(2,7,13,.74); backdrop-filter: blur(3px); }
.modal-card { padding: 0; margin: 0; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-head .icon-btn { border: 0; background: transparent; color: white; font-size: 25px; }
#modalBody { padding: 18px 20px; display: grid; gap: 13px; max-height: 65vh; overflow: auto; }
.modal-actions { padding: 15px 20px 20px; display: flex; justify-content: flex-end; gap: 9px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }

.toast {
  position: fixed; z-index: 20; right: 20px; bottom: 20px;
  background: #172b46; border: 1px solid #315178; color: white;
  padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  #mainNav { grid-template-columns: repeat(3, 1fr); }
  .sidebar-bottom { margin-top: 18px; }
  .topbar { position: relative; padding: 20px; align-items: flex-start; }
  #pageRoot { padding: 20px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .nav-btn { text-align: center; font-size: 12px; padding: 9px 6px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
}
@media (max-width: 480px) {
  .metrics { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1; }
}
