/* =====================================================================
   OCPP Portal — Operator Console
   Aesthetic: dense, technical, dark-by-default.
   Palette: charcoal canvas, electric-green accent, status colors.
   ===================================================================== */

:root {
    --bg-0:        #0b0d10;
    --bg-1:        #11151a;
    --bg-2:        #161b22;
    --bg-3:        #1c232c;
    --line:        #232a33;
    --line-soft:   #1a2028;
    --text-1:      #e6edf3;
    --text-2:      #9aa5b1;
    --text-3:      #6b7480;

    --accent:      #4ade80;   /* electric green for charging/active */
    --accent-dim:  #16331f;
    --warn:        #f4b740;
    --warn-dim:    #3a2c10;
    --err:         #ef5350;
    --err-dim:     #3a1717;
    --info:        #5ea8ff;
    --info-dim:    #142239;

    --radius:      6px;
    --mono:        'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --sans:        'IBM Plex Sans', system-ui, -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg-0);
    color: var(--text-1);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Subtle grid backdrop, like an oscilloscope */
body::before {
    content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background-image:
        linear-gradient(var(--line-soft) 1px, transparent 1px),
        linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.5;
}

a       { color: var(--text-1); text-decoration: none; }
a:hover { color: var(--accent); }

/* --- Shell layout -------------------------------------------------- */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--bg-1);
    border-right: 1px solid var(--line);
    padding: 18px 16px;
    display: flex; flex-direction: column; gap: 18px;
    position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 6px 8px; }
.brand-mark { font-size: 22px; color: var(--accent); }
.brand-name { font-weight: 600; letter-spacing: 0.2px; }
.brand-sub  { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.nav-link {
    padding: 9px 12px; border-radius: var(--radius);
    color: var(--text-2); font-size: 13.5px;
    border-left: 2px solid transparent;
}
.nav-link:hover { background: var(--bg-2); color: var(--text-1); }
.nav-link.is-active {
    background: var(--bg-2); color: var(--text-1);
    border-left-color: var(--accent);
}

.sidebar-foot {
    margin-top: auto; display: flex; align-items: center; gap: 10px;
    padding: 12px; background: var(--bg-2); border-radius: var(--radius);
    border: 1px solid var(--line);
}
.me { flex: 1; min-width: 0; }
.me-name { font-size: 13px; }
.me-group { font-family: var(--mono); font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; }
.me-out { font-size: 16px; padding: 6px 10px; border-radius: var(--radius); border: 1px solid var(--line); }

.main { padding: 28px 32px 60px; min-width: 0; }

/* --- Page header --------------------------------------------------- */
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.page-title h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.2px; }
.page-title p  { margin: 4px 0 0; font-size: 13px; color: var(--text-3); }
.page-head-actions { display: flex; gap: 8px; }

/* --- Buttons ------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--bg-2); color: var(--text-1);
    border: 1px solid var(--line); padding: 8px 14px;
    border-radius: var(--radius); font-family: var(--sans); font-size: 13px;
    cursor: pointer; transition: all 0.12s ease;
}
.btn:hover { background: var(--bg-3); border-color: #2d3742; }
.btn-primary {
    background: var(--accent); color: #0a1a10;
    border-color: var(--accent); font-weight: 600;
}
.btn-primary:hover { background: #5ce98c; color: #0a1a10; }
.btn-danger  { color: var(--err); border-color: var(--err-dim); }
.btn-danger:hover  { background: var(--err-dim); }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; }

/* --- Cards / stats ------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat {
    background: var(--bg-1); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px 18px;
    position: relative; overflow: hidden;
}
.stat::after { content:''; position:absolute; left:0; top:0; bottom:0; width:2px; background: var(--accent); opacity:0.55; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-3); }
.stat-value { font-family: var(--mono); font-size: 26px; font-weight: 500; margin-top: 4px; }
.stat-sub   { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.card {
    background: var(--bg-1); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin: -2px 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-2); }

/* --- Tables -------------------------------------------------------- */
.table-wrap { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); }
table.data th {
    background: var(--bg-2); color: var(--text-3);
    font-weight: 500; text-transform: uppercase; font-size: 11px; letter-spacing: 0.7px;
    position: sticky; top: 0; z-index: 1;
}
table.data tr:hover td { background: var(--bg-2); }
table.data tr:last-child td { border-bottom: none; }
table.data .mono { font-family: var(--mono); color: var(--text-2); font-size: 12.5px; }
table.data .num  { font-family: var(--mono); text-align: right; }
table.data .actions { text-align: right; white-space: nowrap; }

/* --- Status pills -------------------------------------------------- */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-family: var(--mono); font-size: 11px; padding: 3px 8px;
    border-radius: 999px; text-transform: uppercase; letter-spacing: 0.5px;
    border: 1px solid transparent;
}
.pill::before { content:''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok      { color: var(--accent); background: var(--accent-dim); border-color: #1e4a2c; }
.pill-warn    { color: var(--warn);   background: var(--warn-dim);   border-color: #4a3814; }
.pill-err     { color: var(--err);    background: var(--err-dim);    border-color: #4a1f1f; }
.pill-info    { color: var(--info);   background: var(--info-dim);   border-color: #1c3050; }
.pill-mute    { color: var(--text-3); background: var(--bg-3);       border-color: var(--line); }

/* --- Forms --------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: 200px 1fr; gap: 14px 24px; align-items: center; }
.form-grid label  { color: var(--text-2); font-size: 13px; }
.form-grid input[type=text],
.form-grid input[type=email],
.form-grid input[type=password],
.form-grid input[type=number],
.form-grid input[type=datetime-local],
.form-grid select,
.form-grid textarea {
    background: var(--bg-2); border: 1px solid var(--line); color: var(--text-1);
    font-family: var(--sans); font-size: 14px;
    padding: 9px 12px; border-radius: var(--radius); width: 100%;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18);
}
.form-grid textarea { min-height: 90px; font-family: var(--mono); font-size: 12.5px; }
.form-actions { margin-top: 22px; display: flex; gap: 8px; }
.form-hint { grid-column: 2; font-size: 12px; color: var(--text-3); margin-top: -8px; }

.checkbox-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 6px 0; }
.checkbox-grid label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-1); }
.checkbox-grid input { accent-color: var(--accent); }

/* --- Login --------------------------------------------------------- */
.login-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(ellipse at 70% 20%, rgba(74,222,128,0.07), transparent 50%),
        radial-gradient(ellipse at 20% 80%, rgba(94,168,255,0.06), transparent 50%);
}
.login-card {
    width: 100%; max-width: 380px;
    background: var(--bg-1); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 32px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.login-card .login-sub { font-size: 13px; color: var(--text-3); margin-bottom: 22px; font-family: var(--mono); }
.login-card .field { margin-bottom: 14px; }
.login-card label { display:block; font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.login-card input {
    background: var(--bg-0); border: 1px solid var(--line);
    color: var(--text-1); width: 100%; padding: 10px 12px;
    border-radius: var(--radius); font-size: 14px;
}
.login-card input:focus { outline:none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74,222,128,0.18); }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }

/* --- Flash --------------------------------------------------------- */
.flash-stack { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.flash {
    padding: 10px 14px; border-radius: var(--radius); font-size: 13.5px;
    border: 1px solid; background: var(--bg-2);
}
.flash-success { color: var(--accent); border-color: #1e4a2c; background: var(--accent-dim); }
.flash-error   { color: var(--err);    border-color: #4a1f1f; background: var(--err-dim);    }
.flash-info    { color: var(--info);   border-color: #1c3050; background: var(--info-dim);   }

/* --- Detail view layout ------------------------------------------- */
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; }

.connectors { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.conn {
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 14px; background: var(--bg-2);
}
.conn-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.conn-num  { font-family: var(--mono); color: var(--text-3); font-size: 12px; }

/* --- Misc ---------------------------------------------------------- */
.muted { color: var(--text-3); }
.right { text-align: right; }
.tiny  { font-size: 11.5px; }
.hl-mono { font-family: var(--mono); color: var(--accent); }
.empty-state { padding: 40px; text-align: center; color: var(--text-3); }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search], .toolbar select {
    background: var(--bg-2); border: 1px solid var(--line); color: var(--text-1);
    padding: 7px 10px; border-radius: var(--radius); font-size: 13px;
}

/* Responsive: collapse sidebar on narrow screens */
@media (max-width: 880px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; }
    .nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
    .sidebar-foot { width: 100%; }
    .two-col { grid-template-columns: 1fr; }
}

/* --- additional components --- */
.form-inline { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.form-inline label { color: var(--text-3); font-size:12px; }
.form-inline input, .form-inline select {
  background: var(--bg-3); border:1px solid var(--line); color: var(--text-1);
  padding: 8px 10px; border-radius:6px; font: inherit;
}

.perm-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px 18px;
  padding: 6px 0;
}
.perm-grid .check { display:flex; gap:8px; align-items:flex-start; padding:6px 8px; border:1px solid var(--line); border-radius:6px; background:var(--bg-2); }
.perm-grid .check small { display:block; color: var(--text-3); font-size:11px; margin-top:2px; }

.connector {
  background: var(--bg-2); border:1px solid var(--line); border-radius:8px;
  padding: 14px; margin-bottom: 10px;
}
.connector .conn-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }

.meter-chart, .bar-chart { width: 100%; height: auto; display:block; margin-top:8px; }

textarea {
  background: var(--bg-3); border:1px solid var(--line); color: var(--text-1);
  padding: 8px 10px; border-radius:6px; font: inherit; width: 100%;
  resize: vertical; min-height: 60px;
}
