/* TeslaVolts CSMS — design tokens follow the Teslavolts Figma (Superadmin / CPO) */
:root {
  --primary: #2c69c2;
  --primary-2: #1f56a8;
  --primary-soft: #eef3fb;
  --bg: #f7f8fa;
  --card: #ffffff;
  --border: #eceef2;
  --border-strong: #dfe3ea;
  --text: #111418;
  --text-2: #3d4350;
  --muted: #7b8190;
  --green: #12a150;
  --green-soft: #e7f6ee;
  --red: #ef4444;
  --red-soft: #fdecec;
  --amber: #d97706;
  --amber-soft: #fef3e2;
  --blue-soft: #e8f0fd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --sidebar: 232px;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body { margin: 0; background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------------- layout ---------------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100%; }
.sidebar { background: #fff; border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 22px 0; display: flex; flex-direction: column; }
.sidebar .brand { padding: 0 24px 26px; display: flex; align-items: center; }
.sidebar .brand img { height: 46px; max-width: 100%; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 24px; color: var(--muted); font-weight: 500; border-left: 3px solid transparent; transition: background .15s, color .15s; }
.nav a svg { font-size: 18px; flex: none; }
.nav a:hover { color: var(--text-2); background: #fafbfc; }
.nav a.active { color: var(--primary); background: var(--primary-soft); border-left-color: var(--primary); }
.nav .sub a { padding-left: 54px; font-size: 13px; }
.sidebar .foot { margin-top: auto; padding: 16px 24px 0; font-size: 12px; color: var(--muted); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 74px; display: flex; align-items: center; gap: 14px; padding: 0 28px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .search { flex: 0 1 330px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border-strong); border-radius: 12px; padding: 10px 14px; color: var(--muted); }
.topbar .search input { border: 0; outline: 0; flex: 1; background: transparent; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: var(--text-2); position: relative; }
.icon-btn:hover { background: #fafbfc; }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; background: #7c5cff; border-radius: 50%; border: 2px solid #fff; }
.avatar { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #ffd34d, #ffb800); display: grid; place-items: center; font-weight: 700; color: #4a3500; overflow: hidden; border: 0; }
.content { padding: 24px 28px 40px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 10px; }
.back button { border: 0; background: none; padding: 4px; display: grid; place-items: center; color: var(--text); }
.menu-toggle { display: none; }

/* ---------------- cards ---------------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card.flush { padding: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 32px; font-weight: 700; margin-top: 8px; letter-spacing: -0.02em; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.trend { font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.trend.up { color: var(--green); }
.trend.down { color: var(--red); }

/* ---------------- forms ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: 10px; padding: 11px 13px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(44, 105, 194, .12); }
.input.error { border-color: var(--red); background: #fff7f7; }
.input[readonly] { background: #f6f7f9; color: var(--muted); }
.textarea { min-height: 120px; resize: vertical; }
.field .err { color: var(--red); font-size: 12px; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 40px; }
.input-wrap .adorn { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); background: none; border: 0; display: grid; place-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 20px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.check { display: inline-flex; gap: 8px; align-items: center; color: var(--text-2); }

/* ---------------- buttons ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; padding: 10px 18px; font-weight: 500; border: 1px solid transparent; transition: filter .15s, background .15s; white-space: nowrap; }
.btn-primary { color: #fff; background: linear-gradient(180deg, #3577d2, var(--primary-2)); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { background: #b8bcc5; cursor: not-allowed; filter: none; }
.btn-outline { border-color: var(--primary); color: var(--primary); background: #fff; }
.btn-ghost { background: #fff; border-color: var(--border-strong); color: var(--text-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-outline { border-color: var(--red); color: var(--red); background: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; padding: 13px; }
.link-btn { border: 0; background: none; color: var(--primary); padding: 0; font-weight: 500; }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 12px 16px; background: #f6f7f9; white-space: nowrap; }
.table th:first-child { border-radius: 10px 0 0 10px; }
.table th:last-child { border-radius: 0 10px 10px 0; }
.table td { padding: 13px 16px; border-bottom: 1px solid #f1f2f5; color: var(--text-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #fafbfd; }
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 12px; flex: 0 1 360px; color: var(--muted); background: #fff; }
.toolbar .search input { border: 0; outline: 0; flex: 1; min-width: 0; }
.pager { display: flex; align-items: center; justify-content: space-between; padding-top: 16px; color: var(--muted); font-size: 13px; flex-wrap: wrap; gap: 10px; }
.pager .pages { display: flex; gap: 6px; align-items: center; }
.pager button { border: 0; background: none; min-width: 30px; height: 30px; border-radius: 8px; color: var(--text-2); }
.pager button.on { background: var(--primary); color: #fff; }
.pager button:disabled { opacity: .4; cursor: default; }

/* ---------------- pills, tabs, toggles ---------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.blue { background: var(--blue-soft); color: var(--primary); }
.pill.gray { background: #f1f2f4; color: var(--muted); }
.pill .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs button { border: 0; background: none; padding: 10px 2px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 8px 12px; color: var(--muted); display: grid; place-items: center; }
.seg button.on { background: var(--primary-soft); color: var(--primary); }
.toggle { width: 40px; height: 22px; border-radius: 999px; background: #d4d8df; border: 0; position: relative; transition: background .15s; flex: none; padding: 0; }
.toggle::after { content: ''; position: absolute; width: 16px; height: 16px; top: 3px; left: 3px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle.on { background: var(--primary); }
.toggle.on::after { transform: translateX(18px); }
.select-sm { border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 12px; background: #fff; }

/* ---------------- menus / modals / toast ---------------- */
.kebab { position: relative; display: inline-block; }
.kebab > button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border-strong); background: #fff; display: grid; place-items: center; color: var(--text-2); }
.menu { position: absolute; right: 0; top: 36px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 24, 40, .12); min-width: 170px; padding: 6px; z-index: 40; }
.menu button { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px; color: var(--text-2); }
.menu button:hover { background: #f5f7fa; }
.menu button.danger { color: var(--red); }
.overlay { position: fixed; inset: 0; background: rgba(17, 20, 24, .45); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 18px; width: min(420px, 100%); padding: 28px; text-align: center; animation: pop .18s; max-height: 90vh; overflow: auto; }
.modal.wide { width: min(720px, 100%); text-align: left; }
.modal .badge { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 16px; color: #fff; font-size: 28px; }
.modal .badge.red { background: var(--red); box-shadow: 0 0 0 10px var(--red-soft); }
.modal .badge.green { background: var(--green); box-shadow: 0 0 0 10px var(--green-soft); }
.modal h3 { margin-bottom: 8px; font-size: 20px; }
.modal p { color: var(--muted); margin: 0 0 22px; }
.modal .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toast-host { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: #111418; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: 380px; animation: pop .2s; }
.toast.error { background: #b42318; }
.drawer { position: fixed; top: 80px; right: 24px; width: min(400px, calc(100vw - 32px)); background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 20px 48px rgba(16, 24, 40, .16); z-index: 60; max-height: 70vh; overflow: auto; }
.drawer .item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #f2f3f5; }
.drawer .item .ic { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { transform: scale(.96); opacity: 0 } }

/* ---------------- charts ---------------- */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: #f0f1f4; }
.legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-tip { position: absolute; pointer-events: none; background: #111418; color: #fff; padding: 8px 10px; border-radius: 10px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); }

/* ---------------- auth ---------------- */
.auth { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; background: #fff; }
.auth .hero { background-size: cover; background-position: center; }
.auth .panel { display: grid; place-items: center; padding: 32px; background: #fafbfc; }
.auth .box { width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 36px 32px; box-shadow: 0 10px 40px rgba(16, 24, 40, .06); border: 1px solid var(--border); }
.auth .logo { display: block; margin: 0 auto 10px; height: 64px; max-width: 100%; }
.auth .tag { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 26px; }
.auth h1 { text-align: center; margin-bottom: 4px; }
.auth .sub { text-align: center; color: var(--muted); margin-bottom: 24px; }
.portal-switch { display: flex; justify-content: center; gap: 6px; margin-bottom: 18px; }

/* ---------------- misc ---------------- */
.map { height: 420px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #e9edf2; }
.map.tall { height: calc(100vh - 230px); min-height: 420px; }
.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 20px; }
.kv .k { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.kv .v { font-weight: 500; color: var(--text); word-break: break-word; }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #dfe5ef; border-top-color: var(--primary); animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg) } }
.conn { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.conn .num { width: 32px; height: 32px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 600; }
.station-card { border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: #fff; display: flex; flex-direction: column; gap: 10px; }
.log { font-family: ui-monospace, Menlo, monospace; font-size: 12px; max-height: 460px; overflow: auto; background: #0f1720; color: #d6e2f0; border-radius: 12px; padding: 12px; }
.log .in { color: #7dd3a8; }
.log .out { color: #93c5fd; }
.log .err { color: #fca5a5; }
.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.check-list li::before { content: '✓'; color: var(--green); margin-right: 8px; font-weight: 700; }
.template { border: 2px solid var(--border); border-radius: 14px; padding: 14px; cursor: pointer; }
.template.on { border-color: var(--primary); }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid #f1f2f5; }
.accordion { border-bottom: 1px solid #f1f2f5; }
.accordion summary { padding: 14px 0; cursor: pointer; font-weight: 500; list-style: none; display: flex; justify-content: space-between; }
.accordion p { margin: 0 0 14px; color: var(--muted); line-height: 1.6; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; box-shadow: 0 0 0 4px var(--green-soft); }

@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 90; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth .hero { display: none; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px 32px; }
  .topbar .search { display: none; }
}
@media (max-width: 560px) {
  .g4, .form-grid, .kv { grid-template-columns: 1fr; }
  .kpi .value { font-size: 26px; }
}
.toolbar .select { width: auto; min-width: 170px; padding: 9px 12px; }

.spin{animation:tvspin 1s linear infinite}
@keyframes tvspin{to{transform:rotate(360deg)}}
