:root {
    /* Terminal UI: black shell, neutral grey/white text (like actual terminal foreground),
       orange reserved for interactive/accent elements only - active nav, links, primary
       actions, focus rings. Everything else stays monochrome so the accent still reads as
       an accent instead of tinting the whole app. */
    --brand: #ff8c3c;
    --brand-bright: #ffab63;
    --brand-soft: rgba(255, 140, 60, 0.14);
    --ink: #d6d6d6;
    --ink-bright: #f2f2f2;
    --ink-soft: #7a7a7a;
    --bg: #0c0c0c;
    --surface: #141414;
    --sidebar-bg: #0a0a0a;
    --sidebar-fg: #9a9a9a;
    --border: #2a2a2a;
    --radius: 2px;
    --mono: ui-monospace, "Cascadia Code", "Courier New", Consolas, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--mono); background: var(--bg); color: var(--ink); }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    padding: 1rem;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
}
.sidebar .brand {
    font-weight: 700; color: var(--ink-bright); margin-bottom: 1.5rem;
    letter-spacing: 0.04em; font-size: 0.95rem;
}
.sidebar .brand::before { content: "> "; color: var(--brand); }
.nav-flex-column { display: flex; flex-direction: column; gap: 0.5rem; }
.sidebar a {
    color: var(--sidebar-fg); text-decoration: none; padding: 0.4rem 0.5rem;
    border-radius: var(--radius); border: 1px solid transparent;
}
.sidebar a::before { content: "  "; }
.sidebar a.active, .sidebar a:hover {
    background: rgba(255, 140, 60, 0.06); color: var(--brand-bright);
    border-color: var(--border);
}
.sidebar a.active::before { content: "> "; color: var(--brand); }
.nav-disabled { color: #4a4a4a; padding: 0.4rem 0.5rem; cursor: not-allowed; }
.nav-disabled::before { content: "  "; }

main { flex: 1; display: flex; flex-direction: column; }
.top-row {
    display: flex; align-items: center; justify-content: flex-end; gap: 1rem;
    padding: 0.75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.top-row .app-title { margin-right: auto; font-weight: 700; color: var(--ink-bright); }
.btn-link { background: none; border: none; padding: 0.2rem 0.25rem; color: var(--brand); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; color: var(--brand-bright); }

.content { padding: 1.5rem 2rem; }

.stat-cards { display: flex; gap: 1rem; margin: 1rem 0 2rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.5rem; min-width: 120px; }
.stat-card--stub { opacity: 0.5; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--ink-bright); }
.stat-label { color: var(--ink-soft); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.5rem; margin-bottom: 1rem; }
.panel--stub { opacity: 0.6; }

/* Dashboard panel rows as clickable cards, not plain <a> text - a default link colour barely
   reads against this theme's near-black surfaces, but a bordered card with a hover state
   works regardless of link colour. */
.entry-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.entry-card {
    display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0.6rem 0.9rem; text-decoration: none; color: var(--ink);
}
.entry-card:hover { border-color: var(--brand); color: var(--brand-bright); }
.entry-card__name { font-weight: 600; }
.entry-card__client { color: var(--ink-soft); font-size: 0.85rem; }
.entry-card__date { margin-left: auto; color: var(--ink-soft); font-size: 0.85rem; font-family: var(--mono); }

/* .table-card is the rounded/bordered frame; .data-table is the table itself, so a table
   can still be dropped in somewhere without the wrapper if a page ever needs that. This
   also upgrades the Customers list table for free, since both pages share .data-table. */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.data-table th {
    text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border);
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700;
    color: var(--ink-soft); background: #101010;
}
.data-table td { text-align: left; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--border); color: var(--ink); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #191919; }

/* A small toolbar sitting inside .table-card, above the table itself. */
.table-toolbar { display: flex; gap: 0.5rem; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--border); background: #101010; }

/* Client group header row - a full-width <button> so it's keyboard operable (a <tr onclick>
   is not natively focusable) while still looking like a row in the table. */
.group-header-row td { padding: 0; }
.group-toggle {
    display: flex; align-items: center; gap: 0.6rem; width: 100%;
    background: #101010; border: none; padding: 0.65rem 0.9rem; font: inherit; color: var(--ink);
    cursor: pointer; text-align: left;
}
.group-toggle:hover { background: #1a1a1a; }
.group-toggle__chevron { color: var(--brand); width: 0.9rem; display: inline-block; flex-shrink: 0; }
.group-toggle__name { font-weight: 700; color: var(--ink-bright); }
.group-toggle__count { margin-left: auto; color: var(--ink-soft); font-size: 0.85rem; font-weight: 500; white-space: nowrap; }

/* Nudges an asset row under its group header rightward, so it reads as a child rather than
   a sibling of the group row above it. */
.device-row-indent { padding-left: 2rem; }

/* The one primary-action colour across the app is --brand - kept consistent everywhere
   rather than mixing accent and action colours. */
.btn-primary {
    background: var(--brand); color: #0c0c0c; border: 1px solid var(--brand);
    padding: 0.55rem 1.1rem; border-radius: var(--radius); font-weight: 700; cursor: pointer;
    margin-bottom: 1rem; font-size: 0.85rem;
}
.btn-primary:hover { background: var(--brand-bright); border-color: var(--brand-bright); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-danger {
    background: transparent; color: #ff5c5c; border: 1px solid #ff5c5c;
    padding: 0.55rem 1.1rem; border-radius: var(--radius); font-weight: 700; cursor: pointer;
    margin-bottom: 1rem; margin-left: 0.6rem; font-size: 0.85rem;
}
.btn-danger:hover { background: #ff5c5c; color: #0c0c0c; }

.btn-ghost {
    display: inline-flex; align-items: center; gap: 0.35rem;
    background: transparent; border: 1px solid var(--border); color: var(--ink);
    padding: 0.4rem 0.8rem; border-radius: var(--radius); font-size: 0.85rem;
    text-decoration: none; cursor: pointer; font-family: var(--mono);
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-bright); }

.btn-back {
    display: inline-flex; align-items: center; gap: 0.3rem;
    background: none; border: none; color: var(--ink-soft); font-size: 0.9rem;
    padding: 0; margin-bottom: 0.6rem; cursor: pointer; text-decoration: none; font-family: var(--mono);
}
.btn-back:hover { color: var(--brand-bright); text-decoration: underline; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header h1 { margin: 0; color: var(--ink-bright); }
.page-subtitle { margin: 0.25rem 0 0; color: var(--ink-soft); font-size: 0.9rem; }

/* Filters */
.filter-bar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.25rem; margin-bottom: 1.5rem;
}
.filter-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 170px; }
.filter-field label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); font-weight: 700; }
.filter-field select {
    border: 1px solid var(--border); border-radius: var(--radius); padding: 0.45rem 0.6rem;
    font-size: 0.9rem; background: var(--bg); color: var(--ink); font-family: var(--mono);
}
.filter-field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.filter-bar .btn-ghost { margin-left: auto; }

/* A small pill for a device/record type, used in table cells - "FIREWALL", "NAS", etc. */
.type-chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
    color: var(--brand-bright); background: var(--brand-soft); padding: 0.2rem 0.55rem; border-radius: 999px;
    white-space: nowrap; border: 1px solid var(--border);
}

.badge {
    display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; font-weight: 700;
    padding: 0.2rem 0.6rem; border-radius: var(--radius); text-transform: uppercase; letter-spacing: 0.03em;
    border: 1px solid currentColor;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--active { color: #7ed67e; background: rgba(126, 214, 126, 0.08); }
.badge--inactive { color: var(--ink-soft); background: rgba(122, 122, 122, 0.1); }
/* Licences only: expiry is a separate axis from active/inactive - a licence can be Active
   but past its ExpiresOn (needs renewal) or coming up on it soon. */
.badge--expired { color: #ff5c5c; background: rgba(255, 92, 92, 0.1); }
.badge--expiring { color: var(--brand-bright); background: var(--brand-soft); }

.empty-state { color: var(--ink-soft); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; }

/* Edit-page cards */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem 1.6rem; max-width: 780px; margin-bottom: 1.5rem; }
.form-card h2 { margin-top: 0; color: var(--ink-bright); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 1.25rem; }
.form-grid .form-field { max-width: none; }
.form-field--full { grid-column: 1 / -1; }
.form-section-title {
    grid-column: 1 / -1; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--ink-soft); font-weight: 700; margin: 1.25rem 0 0.25rem;
    border-bottom: 1px solid var(--border); padding-bottom: 0.25rem;
}
.form-section-title:first-child { margin-top: 0; }

/* Sits inside a .filter-field on the Customers list, next to a "Status" label - same
   filter-bar chrome as the Assets page, just a checkbox instead of a dropdown since there's
   only the one active/inactive axis to filter on here. */
.toggle-inactive { display: flex; align-items: center; gap: 0.4rem; color: var(--ink); font-size: 0.9rem; padding-top: 0.3rem; }

.notice { background: var(--brand-soft); border: 1px solid var(--brand); border-radius: var(--radius); padding: 0.6rem 0.9rem; margin-bottom: 1rem; color: var(--ink); }

.form-field { margin-bottom: 0.75rem; display: flex; flex-direction: column; max-width: 420px; }
.form-field label { font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 0.3rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.form-field--checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }

/* Base input styling was previously undefined - fields rendered with only the browser
   default 1px inset border, which is what made the form look unstyled next to the rest of
   the app. */
.form-field input:not([type="checkbox"]), .form-field select, .form-field textarea {
    border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.65rem;
    font: inherit; color: var(--ink); background: var(--bg); font-family: var(--mono);
}
.form-field input:disabled, .form-field select:disabled, .form-field textarea:disabled {
    background: #101010; color: var(--ink-soft); cursor: not-allowed;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.form-field textarea { resize: vertical; min-height: 4.5rem; }

.error { color: #ff5c5c; }
.hint { color: var(--ink-soft); font-size: 0.85rem; }
/* Three columns: who the credential is for, the secret or its placeholder, then the action.
   The li needs to be a flex row - as plain inline content the name ran straight into the
   secret with no separator ("sinet" + "0t1nv1.ADSL" reading as one string). */
.credential-list { list-style: none; margin: 0 0 1.25rem; padding: 0; max-width: 640px; }
.credential-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
}
.credential-name { flex: 0 0 13rem; min-width: 0; overflow-wrap: anywhere; }

/* Monospace so a revealed secret can be read character by character - l/1/I and O/0 have to
   be distinguishable. user-select: all makes one click select the whole thing, since the
   next step is always copying it somewhere. */
.credential-secret {
    font-family: var(--mono);
    background: #101010;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.15rem 0.45rem;
    user-select: all;
    overflow-wrap: anywhere;
    color: var(--ink-bright);
}
.credential-placeholder { color: var(--ink-soft); font-size: 0.85rem; }

/* Actions align on the right edge regardless of how long the secret is. */
.credential-list .btn-link { margin-left: auto; flex-shrink: 0; }
