:root {
  /* Brand */
  --brand: #5b4be6;
  --brand-2: #8b5cf6;
  --brand-dark: #4338ca;
  --brand-soft: #eef0fe;
  --brand-grad: linear-gradient(135deg, #5b4be6, #8b5cf6);
  --sidebar-grad: linear-gradient(180deg, #1f1b4d 0%, #2a2170 60%, #35298a 100%);

  /* Surfaces */
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1c2033;
  --muted: #7b809c;
  --line: #e9eaf3;

  /* Semantic */
  --active: #3b82f6;
  --prod: #10b981;
  --unprod: #f43f5e;
  --neutral: #f59e0b;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --off: #a6abc4;

  --shadow-sm: 0 1px 2px rgba(28,32,51,.06);
  --shadow: 0 2px 6px rgba(28,32,51,.06), 0 12px 28px rgba(45,40,110,.06);
  --shadow-lg: 0 10px 40px rgba(45,40,110,.14);
  --r: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 12.5px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 19px; font-weight: 700; margin: 0 0 2px; letter-spacing: -.02em; }
h2 { font-size: 14px; font-weight: 700; margin: 0 0 12px; letter-spacing: -.01em; }
.small { font-size: 11.5px; }
.tiny { font-size: 10.5px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.strong { font-weight: 600; }
.row { display: flex; gap: 12px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.grow { flex: 1; }
.hide { display: none !important; }

/* Logo */
.logo { width: 42px; height: 42px; border-radius: 12px; background: var(--brand-grad);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 20px; flex: none;
  box-shadow: 0 6px 16px rgba(91,75,230,.35); }
.logo.lg { width: 60px; height: 60px; font-size: 28px; border-radius: 16px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% -10%, #ece9ff 0%, transparent 55%), radial-gradient(1000px 500px at 100% 0%, #e6f0ff 0%, transparent 50%), var(--bg); }
.login-box { background: var(--card); border-radius: 22px; padding: 34px; width: 380px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.login-box .logo { margin: 0 auto 16px; }
form { display: flex; flex-direction: column; gap: 12px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field { margin-bottom: 12px; }
input, select {
  font: inherit; color: var(--text); padding: 11px 13px; width: 100%;
  border: 1px solid var(--line); border-radius: 11px; background: #fbfbfe; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: #fff; }
.error { color: var(--danger); font-size: 13px; }

/* ---------- Buttons ---------- */
button { font: inherit; cursor: pointer; border-radius: 11px; border: 0; padding: 10px 16px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand-dark); transition: transform .05s, background .15s, box-shadow .15s; }
button:hover { background: #e3e5fd; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 16px rgba(91,75,230,.3); }
button.primary:hover { filter: brightness(1.05); }
button.danger { background: var(--danger-soft); color: var(--danger); }
button.sm { padding: 6px 11px; font-size: 12px; border-radius: 9px; }
button.link { background: none; color: var(--brand); padding: 0; }
button.link:hover { background: none; text-decoration: underline; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: var(--sidebar-grad); color: #cdd0ef; padding: 20px 14px; display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh; flex: none; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 20px; }
.brand-name { font-weight: 800; font-size: 16px; color: #fff; line-height: 1.05; letter-spacing: -.01em; }
.brand .muted { color: #a9adde !important; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 13px; border-radius: 11px; color: #c7cbef; font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 #b9a7ff; }
.nav-heading { font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #8b90c9; padding: 16px 13px 6px; }
.sidebar .bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 14px; }
.sidebar .bottom .small { color: #c7cbef; }
.sidebar .bottom .muted { color: #9a9fd0 !important; }
.sidebar .bottom button.link { color: #cdb9ff; }
.main { flex: 1; padding: 20px 28px; max-width: 1180px; }
.topline { margin-bottom: 18px; }

/* Top app bar with user + sign out */
.appbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 30px; padding: 5px 6px 5px 12px; box-shadow: var(--shadow-sm); }
.user-chip .user-meta { line-height: 1.15; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-grad); color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; flex: none; box-shadow: 0 3px 8px rgba(91,75,230,.3); }
.signout-btn { background: var(--brand-soft); color: var(--brand-dark); border-radius: 20px; }
.signout-btn:hover { background: var(--danger-soft); color: var(--danger); }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .n { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.kpi .l { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; transition: background .12s; }
tr.clickable:hover td { background: var(--brand-soft); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--off); }
.dot.working { background: var(--prod); box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.dot.idle { background: var(--neutral); box-shadow: 0 0 0 3px rgba(245,158,11,.18); }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 20px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.badge.gray { background: #eef0f4; color: var(--muted); }
.badge.role { text-transform: capitalize; }
.bar { height: 8px; background: #eceef6; border-radius: 6px; overflow: hidden; min-width: 90px; }
.bar > span { display: block; height: 100%; background: var(--brand-grad); border-radius: 6px; }
.cat-prod { color: var(--prod); font-weight: 700; }
.cat-unprod { color: var(--unprod); font-weight: 700; }
.cat-neutral { color: var(--muted); }

/* Screenshots */
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.shot { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #0d1020; position: relative; box-shadow: var(--shadow-sm); }
.shot img { width: 100%; display: block; aspect-ratio: 16/10; object-fit: cover; cursor: pointer; }
.shot .cap { padding: 6px 9px; font-size: 11px; color: #fff; background: rgba(0,0,0,.55); position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; }
.shot .cap button { background: rgba(255,255,255,.16); color: #fff; padding: 2px 8px; font-size: 11px; }
.lightbox { position: fixed; inset: 0; background: rgba(8,10,24,.88); display: flex; align-items: center; justify-content: center; padding: 32px; z-index: 50; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: var(--shadow-lg); }
.lightbox .x { position: absolute; top: 18px; right: 26px; color: #fff; font-size: 30px; background: none; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(20,20,45,.5); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 40; }
.modal-box { background: var(--card); border-radius: 18px; padding: 24px; width: 440px; max-width: 100%; box-shadow: var(--shadow-lg); }

/* Toolbar */
.toolbar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .field { margin: 0; }
.toolbar input, .toolbar select { width: auto; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1c2033; color: #fff; padding: 11px 20px; border-radius: 12px; z-index: 60; box-shadow: var(--shadow-lg); }

/* View tabs */
.viewtabs { display: inline-flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 5px; box-shadow: var(--shadow-sm); }
.viewtab { background: none; color: var(--muted); font-weight: 600; padding: 9px 18px; border-radius: 9px; }
.viewtab.active { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 12px rgba(91,75,230,.3); }
.viewtab:hover:not(.active) { background: var(--brand-soft); color: var(--brand-dark); }

/* Dashboard layout */
.dash-top { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; margin-bottom: 18px; align-items: start; }
.dash-bottom { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.dash-top > .card { margin: 0; }
.conn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.conn-card { border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 18px; min-height: 150px; justify-content: space-between; background: linear-gradient(180deg, #fcfcff, #f7f8ff); }
.conn-ico { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 19px; color: #fff; }
.conn-ico.people { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.conn-ico.ok { background: linear-gradient(135deg, #10b981, #34d399); }
.conn-ico.off { background: linear-gradient(135deg, #94a3b8, #b8c0cf); }
.conn-n { font-size: 27px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.conn-l { color: var(--muted); font-size: 12px; margin-top: 5px; font-weight: 500; }

.statcol { display: flex; flex-direction: column; gap: 14px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 15px 17px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.stat-card.time::before { background: var(--active); } .stat-card.prod::before { background: var(--prod); }
.stat-card.unprod::before { background: var(--unprod); } .stat-card.neutral::before { background: var(--neutral); }
.stat-ico { width: 40px; height: 40px; border-radius: 11px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 17px; color: #fff; }
.stat-ico.time { background: rgba(59,130,246,.15); color: var(--active); }
.stat-ico.prod { background: rgba(16,185,129,.15); color: var(--prod); }
.stat-ico.unprod { background: rgba(244,63,94,.15); color: var(--unprod); }
.stat-ico.neutral { background: rgba(245,158,11,.15); color: var(--neutral); }
.stat-v { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-l { color: var(--muted); font-size: 11.5px; margin-top: 1px; }

/* Chart */
.chart { width: 100%; height: auto; margin-top: 10px; }
.chart .ax { font-size: 11px; fill: var(--muted); font-weight: 500; }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin: 6px 0; font-weight: 500; text-transform: capitalize; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }

/* Top productive */
.top-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 8px; border-bottom: 1px solid var(--line); border-radius: 9px; }
.top-row:last-child { border-bottom: 0; }
.top-row.clickable { cursor: pointer; transition: background .12s; }
.top-row.clickable:hover { background: var(--brand-soft); }
.rank { width: 26px; height: 26px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; flex: none; }
.rank.g1 { background: linear-gradient(135deg,#facc15,#f59e0b); color: #fff; }
.rank.g2 { background: linear-gradient(135deg,#cbd5e1,#94a3b8); color: #fff; }
.rank.g3 { background: linear-gradient(135deg,#fdba74,#fb923c); color: #fff; }

.menu-btn { display: none; }
@media (max-width: 900px) { .dash-top, .dash-bottom { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .sidebar { position: fixed; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .main { padding: 14px; }
  .menu-btn { display: inline-flex !important; }
  .user-chip .user-meta { display: none; }
}
