:root {
    --bg: #080b0e;
    --panel: #11161a;
    --panel-strong: #151b20;
    --line: #59636d;
    --line-soft: rgba(89, 99, 109, .42);
    --muted: #9aa4ad;
    --text: #e8ecef;
    --blue: #62a7ff;
    --amber: #ffb84d;
    --red: #ff3434;
    --green: #48d597;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at 50% 0, #151b20 0, var(--bg) 42rem);
    color: var(--text);
    font: 15px/1.45 "Segoe UI", Arial, sans-serif;
    letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }

code {
    color: var(--blue);
    font-family: Consolas, "Courier New", monospace;
    overflow-wrap: anywhere;
}

.scanlines {
    pointer-events: none;
    position: fixed;
    inset: 0;
    opacity: .08;
    background: repeating-linear-gradient(0deg, transparent 0 3px, #e6e6e6 4px);
    z-index: 10;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 24px;
    background: rgba(8, 11, 14, .96);
    border-bottom: 2px solid var(--line);
}

.brand,
.nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand { font-weight: 800; text-transform: uppercase; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 28px;
    border: 1px solid var(--text);
}
.brand-text { color: var(--text); }
.module-title,
.nav {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.shell {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 56px;
}

.auth-panel,
.panel {
    background: linear-gradient(180deg, var(--panel-strong), var(--panel));
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: inset 0 0 0 1px rgba(232, 236, 239, .04), 0 18px 48px rgba(0, 0, 0, .24);
}

.auth-panel {
    width: min(460px, 100%);
    margin: 12vh auto 0;
    padding: 30px;
}

.panel { padding: 22px; }

.section-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line-soft);
}

.section-title.compact { margin-bottom: 14px; }
.section-title.top-spaced { margin-top: 24px; }
.section-heading { margin-bottom: 22px; }

h1,
h2,
p { margin-top: 0; }

h1 {
    margin-bottom: 0;
    font-size: clamp(26px, 4vw, 42px);
    line-height: 1.02;
    text-transform: uppercase;
}

h2 {
    margin-bottom: 0;
    font-size: 20px;
    text-transform: uppercase;
}

.kicker {
    margin-bottom: 5px;
    color: var(--blue);
    font: 700 12px/1.2 Consolas, "Courier New", monospace;
    text-transform: uppercase;
}

.muted,
.empty-state { color: var(--muted); }
.empty-state { margin-bottom: 0; }
.no-margin { margin-bottom: 0; }

.message {
    margin-bottom: 16px;
    padding: 10px 12px;
    border-left: 3px solid var(--amber);
    background: rgba(255, 184, 77, .08);
}
.message.error {
    border-color: var(--red);
    background: rgba(255, 52, 52, .08);
}
.message.success {
    border-color: var(--green);
    background: rgba(72, 213, 151, .08);
}

.grid-form {
    display: grid;
    gap: 16px;
}
.cylinder-form {
    display: grid;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line-soft);
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}
.label-heading {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #080b0e;
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
}
textarea { resize: vertical; }
.code-textarea {
    min-height: 210px;
    color: var(--blue);
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    text-transform: uppercase;
}
button:disabled,
.button.disabled {
    cursor: not-allowed;
    opacity: .45;
}

.primary {
    border-color: var(--blue);
    box-shadow: inset 0 0 0 1px rgba(98, 167, 255, .18), 0 0 14px rgba(98, 167, 255, .12);
}
.danger { border-color: var(--red); }

.small {
    min-height: 30px;
    padding: 0 9px;
    font-size: 11px;
}

.icon-button {
    min-width: 40px;
    padding: 0;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.credential-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line-soft);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 10px rgba(255, 184, 77, .45);
}
.status-dot.idle { background: var(--line); box-shadow: none; }

.status-pill,
.count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0 9px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}
.status-pill.online {
    border-color: var(--green);
    color: var(--green);
}

.command-grid,
.ops-grid {
    display: grid;
    gap: 18px;
}

.command-grid {
    grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr);
    margin-bottom: 18px;
}

.ops-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.users-layout {
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, .7fr);
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
}
.data-grid.compact { grid-template-columns: 1fr; }
.data-grid div {
    min-width: 0;
    padding: 12px;
    background: rgba(8, 11, 14, .5);
    border: 1px solid var(--line-soft);
    border-radius: 4px;
}
dt {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}
dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
}

table {
    width: 100%;
    border-collapse: collapse;
}
strong { font-weight: 800; }
th,
td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--line-soft);
    text-align: left;
}
th {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}
td form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
td form + form {
    margin-top: 6px;
}
.subrow td {
    padding-top: 8px;
    background: rgba(8, 11, 14, .32);
}
.subrow p { margin-bottom: 8px; }
.subrow form + form {
    margin-top: 10px;
}
.inline-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: end;
    gap: 10px;
}
.inline-check {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
    min-height: 30px;
}
.inline-check input {
    width: 16px;
    min-height: 16px;
    accent-color: var(--blue);
}
.role-examples {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}
.role-examples div {
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 4px;
    background: rgba(8, 11, 14, .42);
}
.role-examples p {
    margin: 4px 0 0;
    color: var(--muted);
}
.capability-list {
    display: grid;
    gap: 10px;
}
.capability-item {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 4px;
    background: rgba(8, 11, 14, .42);
}
.capability-item input {
    width: 16px;
    min-height: 16px;
    margin-top: 2px;
    accent-color: var(--blue);
}
.capability-item small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    text-transform: none;
}
.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.chip-list span {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border: 1px solid var(--line-soft);
    border-radius: 4px;
    color: var(--blue);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

@media (max-width: 820px) {
    .topbar { padding: 0 16px; }
    .module-title { display: none; }
    .command-grid,
    .ops-grid,
    .users-layout,
    .data-grid {
        grid-template-columns: 1fr;
    }
    .inline-form {
        grid-template-columns: 1fr;
    }
}
