:root {
    color-scheme: dark;
    --bg: #08111f;
    --bg-soft: #0e1a2c;
    --panel: rgba(18, 33, 54, .92);
    --panel-strong: #13243b;
    --text: #f4f7fb;
    --muted: #9dafc5;
    --line: rgba(177, 202, 231, .16);
    --accent: #63e6be;
    --accent-strong: #2fca98;
    --warning: #f6c85f;
    --danger: #ff8c8c;
    --shadow: 0 24px 80px rgba(0, 0, 0, .32);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { color: var(--text); background: var(--bg); }
button, input { font: inherit; }
button { cursor: pointer; }

.portal-body {
    min-height: 100vh;
    background: radial-gradient(circle at top right, rgba(47, 202, 152, .16), transparent 34rem), var(--bg);
}

.auth-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.auth-card {
    width: min(100%, 430px);
    padding: clamp(28px, 6vw, 52px);
    border: 1px solid var(--line);
    border-radius: 28px;
    background: linear-gradient(145deg, rgba(24, 45, 72, .95), var(--panel));
    box-shadow: var(--shadow);
}
.brand-mark {
    display: grid; width: 48px; height: 48px; place-items: center;
    margin-bottom: 28px; border-radius: 15px; color: #062119;
    background: var(--accent); font-size: 22px; font-weight: 800;
}
.brand-mark-admin { color: #201704; background: var(--warning); }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(28px, 4vw, 38px); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 22px; letter-spacing: -.02em; }
.muted { color: var(--muted); line-height: 1.65; }
.auth-form, .user-form { display: grid; gap: 11px; margin-top: 28px; }
label { color: #d8e3f1; font-size: 13px; font-weight: 700; }
input {
    width: 100%; margin-top: 7px; padding: 13px 14px; border: 1px solid var(--line);
    border-radius: 12px; outline: none; color: var(--text); background: rgba(4, 12, 24, .48);
    transition: border-color .18s ease, box-shadow .18s ease;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 230, 190, .15); }
.primary-button, .secondary-button, .button-link {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
    padding: 0 18px; border: 0; border-radius: 12px; font-weight: 800; text-decoration: none;
    transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.primary-button { color: #052018; background: var(--accent); }
.primary-button:hover { background: #82f1ca; transform: translateY(-1px); }
.secondary-button { color: var(--text); border: 1px solid var(--line); background: rgba(255,255,255,.04); }
.secondary-button:hover { border-color: rgba(99,230,190,.6); background: rgba(99,230,190,.08); }
.text-link { display: inline-block; margin-top: 24px; color: var(--muted); font-size: 13px; text-decoration: none; }
.text-link:hover { color: var(--accent); }
.form-message { min-height: 19px; margin: 4px 0 0; color: var(--danger); font-size: 13px; }
.error-card h1 { font-size: 28px; }

.workspace-body, .admin-body { min-height: 100vh; background: var(--bg); }
.workspace-header, .admin-header {
    display: flex; align-items: center; justify-content: space-between; gap: 18px;
    min-height: 82px; padding: 18px clamp(18px, 4vw, 48px); border-bottom: 1px solid var(--line); background: rgba(8,17,31,.88);
}
.workspace-header h1, .admin-header h1 { margin: 0; font-size: 23px; }
.workspace-actions { display: flex; align-items: center; gap: 10px; }
.account-chip, .status-hint {
    display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px;
    border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px;
}
.workspace-main { height: calc(100vh - 82px); padding: 12px; }
.workspace-frame { display: block; width: 100%; height: 100%; border: 1px solid var(--line); border-radius: 16px; background: #fff; }

.admin-main { display: grid; gap: 20px; width: min(1180px, 100%); margin: 0 auto; padding: 28px clamp(18px, 4vw, 48px) 52px; }
.panel { padding: clamp(20px, 3vw, 30px); border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: 0 18px 50px rgba(0,0,0,.16); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.status-hint { color: var(--accent); border-color: rgba(99,230,190,.24); }
.user-form { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.user-form .primary-button { min-height: 48px; }
.user-form .form-message { grid-column: 1 / -1; }
.users-list { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; }
.user-row { display: grid; grid-template-columns: 1.1fr 1.3fr .7fr 1.1fr auto; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row.header { color: var(--muted); background: rgba(255,255,255,.035); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.user-meta { min-width: 0; }
.user-name { overflow: hidden; color: var(--text); font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.user-sub { margin-top: 4px; color: var(--muted); font-size: 12px; }
.status-badge { display: inline-flex; width: fit-content; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status-enabled { color: #062119; background: var(--accent); }
.status-disabled { color: #2c1010; background: var(--danger); }
.empty-state { padding: 34px 18px; color: var(--muted); text-align: center; }
.panel[hidden] { display: none; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.small-button { min-height: 34px; padding: 0 11px; border-radius: 9px; font-size: 12px; }
.danger-button { color: var(--danger); border-color: rgba(255,140,140,.32); }

@media (max-width: 760px) {
    .workspace-header, .admin-header { align-items: flex-start; flex-direction: column; }
    .workspace-actions { width: 100%; justify-content: space-between; }
    .workspace-main { height: calc(100vh - 142px); padding: 8px; }
    .user-form { grid-template-columns: 1fr; }
    .user-row.header { display: none; }
    .user-row { grid-template-columns: 1fr auto; gap: 12px; }
    .user-row > :nth-child(2), .user-row > :nth-child(3) { grid-column: 1; }
    .user-row > :nth-child(4), .user-row > :nth-child(5) { grid-column: 2; grid-row: 1 / span 2; }
    .user-row > :nth-child(5) { grid-row: 3; grid-column: 1 / -1; }
    .row-actions { justify-content: flex-start; }
    .panel-heading { flex-direction: column; }
}

@media (max-width: 380px) {
    .auth-shell { padding: 12px; }
    .auth-card { padding: 25px 20px; border-radius: 22px; }
}

