/* ============================================================
   MSP RESOURCE PLANNER — STYLESHEET
   ============================================================ */

:root {
  --brand: #5b6cff;
  --brand-color: #5b6cff;
  --brand-primary: #5b6cff;
  --brand-strong: #3a4fd6;
  --brand-soft: #eef0ff;
  --brand-tint: #d4d9ff;
  --brand-border: #b3bcff;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1b1f2a;
  --muted: #667085;
  --line: #e5e7eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #5b6cff;
  --shadow: 0 2px 12px rgba(15,23,42,.08);
  --shadow-md: 0 8px 24px rgba(15,23,42,.12);
  --radius: 14px;
  --sidebar-w: 240px;
  --topbar-h: 60px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

input, select, textarea, button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ── UTILITIES ── */
.hidden {
  display: none !important;
}

/* ── APP SHELL GRID ── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #1b1f2a 0%, #232840 100%);
  color: #fff;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 100;
}

.brand-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  line-height: 1.2;
}

.brand-role {
  font-size: 11px;
  color: rgba(255,255,255,.5);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,.65);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
  cursor: pointer;
  position: relative;
}

.nav-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.nav-link.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  font-weight: 700;
}

.nav-link svg {
  flex-shrink: 0;
  opacity: .8;
}

.mini-stat {
  margin-left: auto;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}

.mini-stat-danger {
  background: rgba(239,68,68,.35);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
  color: rgba(255,255,255,.6);
}

/* ── CONTENT SHELL ── */
.content-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.demo-badge {
  background: rgba(245,158,11,.15);
  color: #b45309;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(245,158,11,.3);
  cursor: pointer;
}

/* ── PAGE CONTENT ── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── VIEWS ── */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* ── BUTTONS ── */
.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
}

.button:hover {
  background: var(--bg);
  border-color: var(--brand-border);
}

.button-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.button-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.button-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* ── FORM ELEMENTS ── */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="color"],
select,
textarea {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(91,108,255,.15);
}

input[type="color"] {
  padding: 4px 8px;
  height: 40px;
  cursor: pointer;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--brand);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

select {
  cursor: pointer;
}

/* ── CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.subcard {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

/* ── KPI GRID ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 0;
}

/* ── LAYOUT GRIDS ── */
.two-up {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.three-up {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 1100px) {
  .three-up {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .two-up,
  .three-up {
    grid-template-columns: 1fr;
  }

  .topbar-right {
    gap: 6px;
  }
}

/* ── FORM GRID ── */
.form-grid {
  display: grid;
  gap: 16px;
}

/* ── TABLE STYLES ── */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 2px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(91,108,255,.03);
}

/* ── MODAL BACKDROP ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal-dialog {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-dialog-wide {
  width: min(980px, 100%);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ── PILLS / BADGES ── */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill-success  { background: rgba(34,197,94,.15);  color: #15803d; }
.pill-warning  { background: rgba(245,158,11,.16); color: #92400e; }
.pill-danger   { background: rgba(239,68,68,.14);  color: #b91c1c; }
.pill-info     { background: rgba(91,108,255,.12); color: #3730a3; }
.pill-muted    { background: rgba(100,116,139,.14);color: var(--muted); }

/* ── AVATAR ── */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

/* ── SETUP WIZARD ── */
#setupWizard {
  background: var(--bg);
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.15);
  border-radius: 999px;
}

/* ── PROGRESS BAR ── */
.progress-bar-wrap {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  transition: width .4s;
}

/* ── SEPARATOR ── */
hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

/* ── TOAST ── */
#appToast {
  pointer-events: none;
}

/* ── AVAILABILITY GRID ── */
.avail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.avail-cell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

/* ── RISK ROW ── */
.risk-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
}
