/* Solar Lab — premium energy-tech UI. Zero-dependency. Inter + a refined solar/emerald system. */
:root {
  /* surfaces */
  --bg: #06080d;
  --bg-glow: #0c1a2e;
  --surface-1: #0c111b;
  --surface-2: #111826;
  --surface-3: #161f30;
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .12);
  /* text */
  --text: #eef2f8;
  --muted: #93a1b5;
  --faint: #5f6d82;
  /* brand */
  --solar: #16d196;       /* emerald */
  --solar-2: #0fb98a;
  --solar-deep: #064e3b;
  --amber: #f5b748;
  --blue: #4cc4f5;
  --red: #f4607a;
  --violet: #8b7cf6;
  /* effects */
  --grad-brand: linear-gradient(135deg, #16d196 0%, #2bd4b5 50%, #38bdf8 100%);
  --grad-bar: linear-gradient(90deg, #0fb98a, #16d196 60%, #5eead4);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 12px 32px -8px rgba(0, 0, 0, .55), 0 0 0 1px var(--border);
  --shadow-glow: 0 0 0 1px rgba(22, 209, 150, .35), 0 8px 30px -6px rgba(22, 209, 150, .25);
  --ring: 0 0 0 3px rgba(22, 209, 150, .25);
  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font: 14px/1.55 'Inter', system-ui, 'Segoe UI', Roboto, Arial, sans-serif;
  letter-spacing: -.01em;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 88% -8%, rgba(22, 209, 150, .10), transparent 60%),
    radial-gradient(800px 500px at 10% 0%, rgba(56, 189, 248, .07), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: rgba(22, 209, 150, .3); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #1e2839; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #2a3850; background-clip: padding-box; }
a { color: var(--solar); text-decoration: none; }

/* ---------- controls ---------- */
button {
  font: inherit; font-weight: 550; cursor: pointer; color: var(--text);
  border: 1px solid var(--border-strong); background: var(--surface-3);
  padding: 8px 14px; border-radius: var(--radius-sm); transition: all .16s var(--ease);
  display: inline-flex; align-items: center; gap: 7px;
}
button:hover { border-color: rgba(22, 209, 150, .5); background: #1b2740; transform: translateY(-1px); }
button:active { transform: translateY(0); }
button.primary {
  background: var(--grad-brand); border: none; color: #042b20; font-weight: 700;
  box-shadow: 0 6px 18px -6px rgba(22, 209, 150, .6);
}
button.primary:hover { filter: brightness(1.07); box-shadow: 0 10px 26px -6px rgba(22, 209, 150, .7); }
button.ghost { background: transparent; border-color: var(--border); }
button.ghost:hover { background: var(--surface-2); }
input, select {
  font: inherit; color: var(--text); width: 100%;
  background: var(--surface-1); border: 1px solid var(--border-strong);
  padding: 10px 12px; border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--solar-2); box-shadow: var(--ring); }
input::placeholder { color: var(--faint); }
label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- brand mark ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; }
.logo svg { width: 28px; height: 28px; flex: none; filter: drop-shadow(0 2px 8px rgba(22, 209, 150, .45)); }
.logo .word { font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.logo .word b { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 380px; background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border); border-radius: 22px; padding: 32px 30px;
  box-shadow: var(--shadow); animation: rise .5s var(--ease) both;
  position: relative; overflow: hidden;
}
.login-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad-brand); }
.login-card .logo { margin-bottom: 4px; }
.tagline { color: var(--muted); font-size: 12.5px; margin: 6px 0 18px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }
.hint { color: var(--faint); font-size: 11.5px; margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; line-height: 1.7; }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }

/* ---------- app shell ---------- */
.app { display: none; grid-template-columns: 244px 1fr; min-height: 100vh; }
.app.active { display: grid; }
.sidebar {
  background: linear-gradient(180deg, rgba(17, 24, 38, .8), rgba(12, 17, 27, .9));
  border-right: 1px solid var(--border); padding: 22px 14px; backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
}
.sidebar .logo { padding: 4px 8px 20px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; gap: 11px; align-items: center; padding: 10px 13px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 550; position: relative; transition: all .14s var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: linear-gradient(90deg, rgba(22, 209, 150, .14), rgba(22, 209, 150, .03)); color: #b9f5e1; }
.nav a.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--grad-brand); }
.sidebar-foot { margin-top: auto; padding: 12px 8px 2px; color: var(--faint); font-size: 11px; }

.main { padding: 26px 32px 40px; overflow: auto; max-height: 100vh; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 16px; }
.topbar h1 { font-size: 22px; font-weight: 750; margin: 0; letter-spacing: -.02em; }
.userbox { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap; justify-content: flex-end; }
#userName { font-weight: 600; color: var(--text); }
.badge { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-strong); white-space: nowrap; }
.badge.gate-closed { color: var(--amber); border-color: rgba(245, 183, 72, .35); background: rgba(245, 183, 72, .08); }
.badge.provider { color: var(--blue); border-color: rgba(76, 196, 245, .35); background: rgba(76, 196, 245, .08); }

/* ---------- cards / KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm); transition: border-color .16s, transform .16s;
}
.kpi { position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--grad-brand); opacity: .8; }
.kpi:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.kpi .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.kpi .value { font-size: 28px; font-weight: 800; margin-top: 8px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi .value.green { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }

.grid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; }
@media (max-width: 880px) { .grid-2 { grid-template-columns: 1fr; } .app { grid-template-columns: 1fr; } .sidebar { display: none; } }
.panel-title { font-size: 13px; font-weight: 700; margin: 0 0 14px; color: var(--text); letter-spacing: -.01em; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--faint); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255, 255, 255, .025); }
tbody tr:last-child td { border-bottom: none; }

.pill { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; display: inline-block; line-height: 1.5; }
.pill.available, .pill.completed, .pill.active, .pill.paid { background: rgba(22, 209, 150, .14); color: #5eead4; }
.pill.occupied { background: rgba(76, 196, 245, .14); color: var(--blue); }
.pill.maintenance, .pill.draft, .pill.warning { background: rgba(245, 183, 72, .14); color: var(--amber); }
.pill.unavailable, .pill.faulted, .pill.critical, .pill.aborted, .pill.blocked { background: rgba(244, 96, 122, .14); color: var(--red); }
.pill.unknown { background: rgba(255, 255, 255, .06); color: var(--muted); }

/* ---------- bar chart ---------- */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 132px 1fr 76px; gap: 10px; align-items: center; font-size: 12px; }
.bar-track { background: var(--surface-3); border-radius: 8px; height: 16px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .3); }
.bar-fill { height: 100%; background: var(--grad-bar); border-radius: 8px; box-shadow: 0 0 12px rgba(22, 209, 150, .4); animation: grow .7s var(--ease) both; }
@keyframes grow { from { width: 0 !important; } }

/* ---------- misc ---------- */
.toolbar { display: flex; gap: 12px; align-items: end; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar > div { min-width: 140px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.notice {
  background: linear-gradient(90deg, rgba(76, 196, 245, .09), rgba(76, 196, 245, .02));
  border: 1px solid rgba(76, 196, 245, .2); color: #aee2fb; padding: 12px 16px; border-radius: 12px;
  font-size: 13px; margin-bottom: 16px; line-height: 1.6;
}
.danger-note { background: linear-gradient(90deg, rgba(245, 183, 72, .1), rgba(245, 183, 72, .02)); border-color: rgba(245, 183, 72, .25); color: #f6d79a; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions button { padding: 5px 11px; font-size: 12px; }
.hidden { display: none !important; }

/* schedule booking grid */
.sch-table { table-layout: fixed; }
.sch-table th, .sch-table td { text-align: center; padding: 8px 6px; }
.sch-time { color: var(--muted); font-size: 11px; white-space: nowrap; font-weight: 600; }
.sch-cell { font-size: 12px; font-weight: 600; border-radius: 7px; transition: all .12s var(--ease); }
.sch-cell.free { color: var(--faint); cursor: pointer; }
.sch-cell.free:hover { background: rgba(22, 209, 150, .14); color: var(--solar); box-shadow: inset 0 0 0 1px rgba(22, 209, 150, .4); }
.sch-cell.busy { background: rgba(245, 183, 72, .12); color: var(--amber); }
td.sch-cell.busy[data-cancel] { cursor: pointer; }
.sch-cell.mine { background: var(--grad-brand); color: #042b20; cursor: pointer; box-shadow: 0 2px 8px -2px rgba(22, 209, 150, .5); }
.sch-cell.mine:hover { filter: brightness(1.08); }

/* month calendar */
.mo-table td { height: 74px; vertical-align: top; border: 1px solid var(--border); text-align: left; }
.mo-cell { cursor: pointer; transition: background .12s; }
.mo-cell:hover { background: rgba(22, 209, 150, .08); }
.mo-cell.mo-today { outline: 2px solid var(--solar); outline-offset: -2px; }
.mo-date { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.mo-empty { background: rgba(255, 255, 255, .015); }

/* view transition */
#view { animation: fade .25s var(--ease) both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- toasts ---------- */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast {
  min-width: 240px; max-width: 380px; padding: 13px 16px; border-radius: 12px; font-size: 13px; font-weight: 500;
  background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  display: flex; gap: 10px; align-items: flex-start; animation: toastIn .3s var(--ease) both;
  border-left: 3px solid var(--muted);
}
.toast.success { border-left-color: var(--solar); }
.toast.error { border-left-color: var(--red); }
.toast.info { border-left-color: var(--blue); }
.toast .ico { font-size: 15px; line-height: 1.3; }
.toast.hide { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }
