/* CD CONNECT extranet — design system (mockups) */

:root {
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --border: #E8E5DD;
  --border-strong: #D4D0C5;
  --text: #1A1A1A;
  --text-2: #6B6862;
  --text-3: #94918A;
  --primary: #1E3A8A;
  --primary-soft: #E8EDF7;
  --teal: #0F766E;
  --teal-soft: #E0F2EF;
  --amber: #B45309;
  --amber-soft: #FCEFD9;
  --red: #B91C1C;
  --red-soft: #FCE4E4;
  --green: #15803D;
  --green-soft: #DDF2E2;
  --brand-orange: #f5a93b;
  --shadow-sm: 0 1px 2px rgba(20, 18, 14, 0.04);
  --shadow-md: 0 4px 16px rgba(20, 18, 14, 0.06);
  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 14px; line-height: 1.5; }
h1, h2, h3, h4 { font-family: 'Manrope', sans-serif; font-weight: 700; letter-spacing: -0.01em; }
.mono { font-family: 'JetBrains Mono', monospace; }
a { color: inherit; text-decoration: none; }

/* ---------- LAYOUT ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; flex-direction: column; gap: 6px;
  padding: 4px 8px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.brand-logo-img { height: 34px; width: auto; max-width: 100%; display: block; }
.brand-sub {
  font-size: 11px; color: var(--text-3);
  letter-spacing: 0.08em; text-transform: uppercase;
  font-family: 'Manrope', sans-serif; font-weight: 600;
  padding-left: 2px;
}
.brand-sub.admin { color: var(--primary); }

.nav-label {
  font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em;
  padding: 16px 8px 8px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin: 1px 0;
  border-radius: 8px; color: var(--text-2); font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto; font-size: 10px; font-weight: 700;
  background: var(--red); color: white; padding: 1px 6px; border-radius: 8px;
}
.nav-item .badge.muted { background: var(--bg); color: var(--text-3); border: 1px solid var(--border); }

.sidebar-footer {
  margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #C2A36A, #8E703E);
  color: white; display: grid; place-items: center;
  font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 13px;
}
.avatar.admin { background: linear-gradient(135deg, var(--primary), #2456C7); }
.user-info { line-height: 1.2; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--text-3); }

/* ---------- TOPBAR ---------- */
.main { padding: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 32px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.site-selector {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-weight: 600; cursor: pointer; transition: border-color 0.15s;
  min-width: 280px;
}
.site-selector:hover { border-color: var(--border-strong); }
.site-selector .label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.site-selector .name { font-size: 14px; }
.site-selector .count { color: var(--text-3); font-weight: 500; }
.site-selector .chevron { margin-left: auto; color: var(--text-3); }

.search-box {
  flex: 1; max-width: 480px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.search-box input {
  flex: 1; border: 0; background: transparent; outline: none;
  font: 400 14px 'DM Sans'; color: var(--text);
}
.search-box .kbd {
  font: 600 11px 'JetBrains Mono'; color: var(--text-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; position: relative;
  color: var(--text-2);
}
.icon-btn:hover { background: var(--bg); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; background: var(--red); border-radius: 50%; border: 2px solid var(--surface); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font: 600 13px 'DM Sans'; cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #16306E; }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--border-strong); }

/* ---------- CONTENT ---------- */
.content { padding: 32px 32px 48px; max-width: 1400px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-2); margin-top: 4px; font-size: 14px; }

.period-tabs { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.period-tabs button {
  padding: 6px 14px; background: transparent; border: 0;
  font-family: 'DM Sans'; font-size: 13px; color: var(--text-2);
  font-weight: 500; cursor: pointer; border-radius: 6px;
}
.period-tabs button.active { background: var(--bg); color: var(--text); font-weight: 600; }

/* ---------- KPI GRID ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: border-color 0.15s, transform 0.15s;
  cursor: pointer; position: relative; overflow: hidden;
}
.kpi:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.kpi-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi-label { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.kpi-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; }
.kpi-icon.blue { background: var(--primary-soft); color: var(--primary); }
.kpi-icon.teal { background: var(--teal-soft); color: var(--teal); }
.kpi-icon.green { background: var(--green-soft); color: var(--green); }
.kpi-icon.amber { background: var(--amber-soft); color: var(--amber); }
.kpi-icon.red { background: var(--red-soft); color: var(--red); }
.kpi-value { font-family: 'Manrope'; font-size: 32px; font-weight: 800; letter-spacing: -0.025em; line-height: 1; }
.kpi-value .unit { font-size: 14px; color: var(--text-3); font-weight: 500; margin-left: 4px; }
.kpi-trend { font-size: 12px; margin-top: 8px; display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.kpi-trend .pct.up { color: var(--green); font-weight: 600; }
.kpi-trend .pct.down { color: var(--red); font-weight: 600; }
.kpi-trend .pct.warn { color: var(--amber); font-weight: 600; }

/* progress (data conso) */
.progress { height: 6px; background: var(--bg); border-radius: 99px; margin-top: 12px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; }
.progress-fill.amber { background: var(--amber); }
.progress-fill.teal { background: var(--teal); }
.progress-fill.red { background: var(--red); }
.progress-fill.green { background: var(--green); }
.progress-info { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 6px; font-weight: 500; }

/* ---------- CARDS / TWO COL ---------- */
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  margin-bottom: 24px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 700; }
.card-link { font-size: 12px; color: var(--primary); font-weight: 600; cursor: pointer; }

/* ---------- TABLE ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  text-align: left;
  font: 600 11px 'DM Sans'; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3); padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.tbl tbody td { padding: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--bg); cursor: pointer; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl-num { font-family: 'JetBrains Mono'; font-weight: 600; }

/* ---------- PILLS / DOTS ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 99px;
  font: 600 11px 'DM Sans';
}
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.gray { background: var(--bg); color: var(--text-2); border: 1px solid var(--border); }
.pill.blue { background: var(--primary-soft); color: var(--primary); }

.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 6px; }
.status-dot.up { background: var(--green); }
.status-dot.warn { background: var(--amber); }
.status-dot.down { background: var(--red); }

/* ---------- ALERTS ---------- */
.alert { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.alert:last-child { border-bottom: 0; padding-bottom: 0; }
.alert:first-child { padding-top: 0; }
.alert-icon { width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0; display: grid; place-items: center; }
.alert-icon.red { background: var(--red-soft); color: var(--red); }
.alert-icon.amber { background: var(--amber-soft); color: var(--amber); }
.alert-icon.blue { background: var(--primary-soft); color: var(--primary); }
.alert-content { flex: 1; }
.alert-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.alert-desc { color: var(--text-2); font-size: 13px; line-height: 1.4; }
.alert-time { color: var(--text-3); font-size: 11px; margin-top: 4px; font-family: 'JetBrains Mono'; font-weight: 500; }

/* ---------- ACTIVITY ---------- */
.activity-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: 0; padding-bottom: 0; }
.activity-row:first-child { padding-top: 0; }
.activity-arrow {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  flex-shrink: 0; background: var(--bg);
}
.activity-arrow.in { color: var(--green); }
.activity-arrow.out { color: var(--primary); }
.activity-arrow.miss { color: var(--red); }
.activity-info { flex: 1; min-width: 0; }
.activity-num { font-family: 'JetBrains Mono'; font-weight: 600; font-size: 13px; }
.activity-from { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.activity-meta { text-align: right; font-size: 11px; color: var(--text-3); font-family: 'JetBrains Mono'; font-weight: 500; line-height: 1.5; }

/* ---------- SITES ---------- */
.sites-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.site {
  border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  transition: all 0.15s; cursor: pointer; background: var(--bg);
}
.site:hover { border-color: var(--primary); background: var(--surface); }
.site-name { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.site-addr { font-size: 12px; color: var(--text-2); margin-bottom: 12px; }
.site-stats { display: flex; gap: 14px; }
.site-stat { display: flex; flex-direction: column; gap: 2px; }
.site-stat .num { font-family: 'JetBrains Mono'; font-weight: 700; font-size: 16px; }
.site-stat .lbl { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.site-status { display: flex; align-items: center; font-size: 11px; color: var(--text-2); margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); font-weight: 500; }

/* ---------- CHART ---------- */
.chart-area { height: 180px; margin-top: 8px; position: relative; }
.chart-svg { width: 100%; height: 100%; overflow: visible; }
.chart-grid line { stroke: var(--border); stroke-dasharray: 2 4; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-fill { fill: var(--primary-soft); opacity: 0.5; }
.chart-dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2.5; }
.chart-label { font-size: 10px; fill: var(--text-3); font-family: 'JetBrains Mono'; font-weight: 500; }

/* ---------- MOCK BANNER ---------- */
.mock-banner {
  background: #FEF8E0; border: 1px dashed #D4A82C;
  color: #6B5414; padding: 10px 16px; font-size: 12px;
  text-align: center; font-weight: 500;
}
.mock-banner a { color: #6B5414; border-bottom: 1px solid #D4A82C; padding-bottom: 1px; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .sites-grid { grid-template-columns: 1fr; }
}
