:root {
    --bg: #040a14;
    --bg-2: #071426;
    --panel: #0a1f3d;
    --panel-2: #0e2a52;
    --line: #173a66;
    --line-2: #245083;
    --text: #ffffff;
    --muted: #a8bdd9;
    --primary: #1d4f91;
    --primary-2: #f58220;
    --primary-3: #ff9d3f;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --radius: 18px;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 20% 0%, #0f2f5c 0%, var(--bg) 45%, #02060d 100%);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary-2);
    text-decoration: none;
}

a:hover {
    color: #ffb15c;
}

code {
    font-family: "Cascadia Code", Consolas, "Courier New", monospace;
    font-size: 0.85em;
    color: #ffd7a8;
    background: rgba(245, 130, 32, 0.12);
    border: 1px solid rgba(245, 130, 32, 0.22);
    border-radius: 8px;
    padding: 2px 7px;
    word-break: break-all;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(1.6rem, 2.4vw, 2.2rem);
}

h2 {
    font-size: 1.2rem;
}

h3 {
    font-size: 1rem;
}

p {
    line-height: 1.6;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.82rem;
}

.nowrap {
    white-space: nowrap;
}

.eyebrow {
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--primary-2);
}

/* Guest */
.guest {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 32px 18px;
    position: relative;
}

.guest-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    overflow: hidden;
    background:
        radial-gradient(circle at 15% 15%, rgba(245, 130, 32, 0.22), transparent 38%),
        radial-gradient(circle at 85% 25%, rgba(29, 79, 145, 0.16), transparent 42%),
        radial-gradient(circle at 50% 90%, rgba(245, 130, 32, 0.1), transparent 45%),
        #040a14;
}

.guest-bg::before {
    content: "";
    position: absolute;
    inset: -10%;
    background-image:
        linear-gradient(rgba(29, 79, 145, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(29, 79, 145, 0.06) 1px, transparent 1px);
    background-size: 54px 54px;
    transform: perspective(900px) rotateX(58deg) translateY(12%);
    transform-origin: center bottom;
    -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 0%, transparent 72%);
    mask-image: radial-gradient(ellipse at 50% 40%, #000 0%, transparent 72%);
    opacity: 0.75;
}

.guest-bg::after {
    content: "";
    position: absolute;
    inset: -40%;
    background: conic-gradient(from 90deg, transparent 0deg, rgba(29, 79, 145, 0.16) 90deg, transparent 180deg, rgba(245, 130, 32, 0.14) 270deg, transparent 360deg);
    animation: guestSpin 50s linear infinite;
    opacity: 0.35;
}

@keyframes guestSpin {
    to {
        transform: rotate(360deg);
    }
}

.guest-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(2, 6, 13, 0.2) 0%, rgba(2, 6, 13, 0.78) 70%, rgba(2, 6, 13, 0.95) 100%);
}

.guest-main {
    width: 100%;
    max-width: 960px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    margin: auto 0;
}

.guest-brand,
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    color: var(--text);
}

.brand strong {
    color: var(--primary-2);
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    font-weight: 800;
    color: #071426;
    background: linear-gradient(135deg, var(--primary-2), var(--primary-3));
    box-shadow: 0 8px 24px rgba(245, 130, 32, 0.35);
}

.guest-footer {
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
}

/* Cards */
.card {
    width: 100%;
    max-width: 470px;
    background: linear-gradient(180deg, rgba(10, 31, 61, 0.96), rgba(10, 16, 30, 0.96));
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 30px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.card-wide {
    max-width: 940px;
}

.card h1 {
    margin-bottom: 8px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.card-head h2 {
    font-size: 1.15rem;
}

.card .card {
    max-width: none;
    background: rgba(5, 15, 30, 0.6);
    box-shadow: none;
}

.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    background: rgba(5, 15, 30, 0.55);
}

/* Forms */
.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 18px;
}

.form label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 0.84rem;
    font-weight: 600;
    color: #dbe8f8;
}

.form input[type="text"],
.form input[type="password"],
.form input[type="email"],
.form input[type="url"],
.form input[type="search"],
.form input[type="number"],
.form select,
.form textarea,
.filters input,
.filters select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line-2);
    background: rgba(3, 10, 22, 0.75);
    color: var(--text);
    font: inherit;
    font-weight: 400;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.form input:focus,
.form select:focus,
.form textarea:focus,
.filters input:focus,
.filters select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(245, 130, 32, 0.18);
}

.form input::placeholder,
.filters input::placeholder {
    color: #7f96b5;
}

.input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.input-row input {
    flex: 1 1 auto;
    min-width: 0;
}

.input-row .btn {
    flex: 0 0 auto;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-label {
    font-size: 0.84rem;
    font-weight: 600;
}

.static-field {
    display: block;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(3, 10, 22, 0.5);
    color: var(--muted);
    font-family: "Cascadia Code", Consolas, "Courier New", monospace;
    font-size: 0.85rem;
    word-break: break-all;
}

.card-head-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.doc h2 {
    margin-top: 26px;
}

.doc h3 {
    margin-top: 18px;
}

.doc p,
.doc li {
    color: var(--muted);
    line-height: 1.7;
}

.doc ul,
.doc ol {
    padding-left: 20px;
}

.doc pre {
    margin: 12px 0;
    padding: 14px;
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(3, 10, 22, 0.7);
}

.doc pre code {
    background: none;
    border: 0;
    padding: 0;
    color: #ffd7a8;
    font-size: 0.82rem;
}

.doc table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.doc th,
.doc td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    font-size: 0.84rem;
}

.doc th {
    color: var(--text);
}

.doc td {
    color: var(--muted);
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.checkbox {
    flex-direction: row !important;
    align-items: center;
    gap: 9px !important;
    font-weight: 500 !important;
    color: var(--muted) !important;
}

.checkbox input {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: 12px;
    border: 1px solid var(--line-2);
    background: rgba(14, 42, 82, 0.9);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.btn:hover {
    border-color: var(--primary);
    background: rgba(29, 79, 145, 0.95);
    color: #fff;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    border: none;
    color: #071426;
    background: linear-gradient(135deg, var(--primary-2), var(--primary-3));
    box-shadow: 0 10px 30px rgba(245, 130, 32, 0.28);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-3), #ffc285);
    color: #040a14;
}

.btn-danger {
    border-color: rgba(239, 68, 68, 0.5);
    color: #ffd5d5;
    background: rgba(127, 29, 29, 0.35);
}

.btn-danger:hover {
    border-color: var(--danger);
    background: rgba(153, 27, 27, 0.6);
}

.btn-ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--muted);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--line-2);
    background: rgba(14, 42, 82, 0.7);
}

.btn-small {
    padding: 7px 11px;
    font-size: 0.78rem;
    border-radius: 9px;
}

.btn-block {
    width: 100%;
}

/* Alerts */
.alert {
    width: 100%;
    max-width: 940px;
    padding: 13px 16px;
    border-radius: 14px;
    border: 1px solid var(--line-2);
    background: rgba(14, 42, 82, 0.9);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 16px;
}

.guest-main > .alert {
    max-width: 470px;
}

.alert a {
    color: var(--primary-2);
    font-weight: 600;
}

.alert-error {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(127, 29, 29, 0.28);
}

.alert-success {
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(6, 78, 59, 0.3);
}

.alert-warning {
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(120, 53, 15, 0.28);
}

.alert-info {
    border-color: rgba(56, 189, 248, 0.45);
    background: rgba(8, 47, 73, 0.32);
}

/* System list */
.system-list {
    list-style: none;
    padding: 0;
    margin: 20px 0 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.system-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(3, 10, 22, 0.5);
    color: var(--text);
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.system-link:hover {
    border-color: var(--primary);
    background: rgba(14, 42, 82, 0.85);
    transform: translateY(-1px);
    color: var(--text);
}

.system-link span {
    color: var(--muted);
    font-size: 0.78rem;
}

/* App shell */
.app {
    min-height: 100vh;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: 26px 20px;
    border-right: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(8, 24, 48, 0.98), rgba(5, 9, 17, 0.98));
    position: sticky;
    top: 0;
    height: 100vh;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    padding: 11px 14px;
    border-radius: 11px;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.nav-item:hover {
    color: var(--text);
    background: rgba(14, 42, 82, 0.7);
}

.nav-item.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(245, 130, 32, 0.28), rgba(29, 79, 145, 0.14));
    border-color: rgba(245, 130, 32, 0.35);
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px;
    border-radius: 13px;
    border: 1px solid var(--line);
    background: rgba(3, 10, 22, 0.5);
}

.user-avatar {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-weight: 800;
    color: #071426;
    background: linear-gradient(135deg, var(--primary-2), var(--primary-3));
    flex: 0 0 auto;
}

.user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-meta strong {
    font-size: 0.86rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-meta small {
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: capitalize;
}

.logout-form {
    margin: 0;
}

.content {
    padding: 30px clamp(18px, 3vw, 44px) 60px;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.topbar h1 {
    font-size: clamp(1.5rem, 2.2vw, 2rem);
}

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

.content > .card,
.content > .alert,
.content > .grid-cards {
    max-width: 1180px;
}

.content > .card {
    margin-bottom: 20px;
}

/* Dashboard */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: linear-gradient(160deg, rgba(14, 42, 82, 0.9), rgba(5, 15, 30, 0.9));
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-card span {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-card strong {
    font-size: 1.45rem;
}

.stat-card small {
    color: var(--muted);
    font-size: 0.78rem;
}

.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.quick-link {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(3, 10, 22, 0.45);
    color: var(--text);
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.quick-link:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    color: var(--text);
}

.quick-link span {
    color: var(--muted);
    font-size: 0.8rem;
}

/* Tables */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid var(--line);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.table th {
    text-align: left;
    padding: 12px 14px;
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: rgba(3, 10, 22, 0.7);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(23, 58, 102, 0.65);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: rgba(14, 42, 82, 0.45);
}

.table .actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.table .actions form {
    margin: 0;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid var(--line-2);
    background: rgba(14, 42, 82, 0.8);
    color: var(--muted);
}

.badge-success {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(6, 78, 59, 0.35);
    color: #86efac;
}

.badge-warning {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(120, 53, 15, 0.32);
    color: #fcd34d;
}

.badge-info {
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(8, 47, 73, 0.35);
    color: #93c5fd;
}

.badge-danger {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(127, 29, 29, 0.35);
    color: #fca5a5;
}

.badge-muted {
    color: var(--muted);
}

/* Info list */
.info-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 0;
}

.info-list div {
    padding: 13px 15px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(3, 10, 22, 0.42);
}

.info-list dt {
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 5px;
}

.info-list dd {
    margin: 0;
    font-size: 0.9rem;
    word-break: break-word;
}

/* 2FA */
.twofa-setup {
    display: grid;
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
    gap: 26px;
    align-items: start;
}

.qr-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.qr {
    display: grid;
    place-items: center;
    width: 220px;
    height: 220px;
    padding: 10px;
    border-radius: 16px;
    background: #fff;
    color: #0b1220;
    font-size: 0.78rem;
    text-align: center;
}

.qr img,
.qr canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.twofa-details {
    min-width: 0;
}

.copy-row {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
    margin: 8px 0 14px;
}

.code-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
}

.code-list li {
    padding: 8px 10px;
    border-radius: 9px;
    border: 1px solid var(--line-2);
    background: rgba(3, 10, 22, 0.6);
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 0.84rem;
    letter-spacing: 0.04em;
    text-align: center;
}

.recovery {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.recovery summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 600;
}

.recovery summary:hover {
    color: var(--text);
}

/* Filters */
.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}

.filters input[type="search"] {
    flex: 1 1 260px;
    min-width: 200px;
}

.filters select {
    width: auto;
    min-width: 150px;
}

/* Responsive */
@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--line);
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 14px;
        padding: 16px 18px;
    }

    .nav {
        flex-direction: row;
        flex-wrap: wrap;
        order: 3;
        width: 100%;
    }

    .sidebar-footer {
        margin: 0 0 0 auto;
        flex-direction: row;
        align-items: center;
    }

    .user-chip {
        padding: 8px;
    }

    .logout-form .btn {
        padding: 8px 12px;
    }

    .content {
        padding-top: 22px;
    }
}

@media (max-width: 700px) {
    .grid-2,
    .twofa-setup {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 22px;
    }

    .filters select,
    .filters input[type="search"],
    .filters .btn {
        width: 100%;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
    }

    .topbar-actions .btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}
