/* Portal layout. Relies on tokens defined in report.css. */
.shell {
        display: flex;
        min-height: 100vh;
}

/* Sidebar */
.sidebar {
        position: sticky;
        top: 0;
        display: flex;
        flex-direction: column;
        width: 248px;
        height: 100vh;
        flex-shrink: 0;
        padding: 16px 12px;
        background: var(--navy);
        color: #c4cad8;
}

.brand {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 4px 8px 20px;
        color: #fff;
        text-decoration: none !important;
}

.brand-text {
        display: flex;
        flex-direction: column;
        font-weight: 700;
        font-size: 15px;
        line-height: 1.2;
}

.brand-text small {
        font-weight: 400;
        font-size: 12px;
        color: #8891aa;
}

.nav-section {
        padding: 16px 12px 6px;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: #8891aa;
}

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

.nav a {
        display: flex;
        align-items: center;
        gap: 10px;
        height: 36px;
        padding: 0 12px;
        border-radius: 6px;
        color: #c4cad8;
        font-weight: 500;
        text-decoration: none;
        transition: background 0.15s, color 0.15s;
}

.nav a:hover {
        background: var(--navy-2);
        color: #fff;
}

.nav a.active {
        background: var(--navy-3);
        color: #fff;
        box-shadow: inset 3px 0 0 var(--brand);
}

.nav svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
        flex-shrink: 0;
}

.sidebar-footer {
        margin-top: auto;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 12px 4px 0;
        border-top: 1px solid var(--navy-2);
}

.user-chip {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        padding: 4px 8px;
        border-radius: 6px;
        color: #fff;
        text-decoration: none !important;
}

.user-chip:hover,
.user-chip.active {
        background: var(--navy-2);
}

.user-avatar {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: var(--blue);
        color: #fff;
        font-weight: 700;
        font-size: 12px;
        flex-shrink: 0;
}

.user-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-weight: 500;
}

.btn-link {
        border: 0;
        background: none;
        color: #8891aa;
        font: 500 13px var(--font);
        cursor: pointer;
        padding: 4px 8px;
        border-radius: 6px;
}

.btn-link:hover {
        color: #fff;
        background: var(--navy-2);
}

/* Main */
.main {
        flex: 1 1 auto;
        min-width: 0;
}

.topbar {
        display: flex;
        align-items: center;
        height: 64px;
        padding: 0 32px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
}

.topbar h1 {
        font-size: 20px;
        font-weight: 700;
}

.content {
        max-width: 1180px;
        padding: 28px 32px 48px;
}

/* Cards */
.card {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        padding: 24px;
}

.card-flush {
        padding: 0;
        overflow: hidden;
}

.card-narrow {
        max-width: 520px;
}

.card-head {
        margin-bottom: 20px;
}

.card-head h2 {
        font-size: 16px;
        font-weight: 700;
        margin-bottom: 4px;
}

.card-head p {
        margin: 0;
}

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

.grid {
        display: grid;
        gap: 16px;
}

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

.grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.input > span {
        font-weight: 600;
        font-size: 13px;
}

.input em {
        color: var(--red);
        font-style: normal;
}

input[type="text"],
input[type="tel"],
input[type="password"],
input[type="search"],
input:not([type]),
select {
        height: 38px;
        padding: 0 12px;
        border: 1px solid var(--border-strong);
        border-radius: 6px;
        background: var(--surface);
        font: 14px var(--font);
        color: var(--text);
        transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
        outline: none;
        border-color: var(--blue);
        box-shadow: 0 0 0 3px rgba(2, 99, 224, 0.18);
}

.sources {
        margin: 0;
        padding: 0;
        border: 0;
}

.sources legend {
        padding: 0;
        margin-bottom: 8px;
        font-weight: 600;
        font-size: 13px;
}

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

.source-option {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 180px;
        padding: 10px 14px;
        border: 1px solid var(--border-strong);
        border-radius: var(--radius);
        cursor: pointer;
        transition: border-color 0.15s, background 0.15s;
}

.source-option:hover {
        border-color: var(--blue);
}

.source-option:has(input:checked) {
        border-color: var(--blue);
        background: var(--blue-soft);
}

.source-option.disabled {
        cursor: not-allowed;
        opacity: 0.55;
        border-style: dashed;
}

.source-option input {
        width: 16px;
        height: 16px;
        accent-color: var(--blue);
}

.source-text {
        display: flex;
        flex-direction: column;
        line-height: 1.3;
}

.source-name {
        font-weight: 600;
}

.source-hint {
        font-size: 12px;
        color: var(--muted);
}

.form-actions {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        flex-wrap: wrap;
        padding-top: 18px;
        border-top: 1px solid var(--border);
}

.check-inline {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        color: var(--muted);
        cursor: pointer;
}

.check-inline input {
        accent-color: var(--blue);
}

.btn-loading::before {
        content: "";
        width: 14px;
        height: 14px;
        border: 2px solid rgba(255, 255, 255, 0.4);
        border-top-color: #fff;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
}

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

/* Alerts */
.alert {
        padding: 12px 14px;
        border-radius: 6px;
        border: 1px solid transparent;
        margin-bottom: 16px;
        font-weight: 500;
}

.form .alert {
        margin-bottom: 0;
}

.alert-error {
        background: var(--red-soft);
        border-color: #f9c7c7;
        color: var(--red);
}

.alert-success {
        background: var(--green-soft);
        border-color: #b8e4c8;
        color: var(--green);
}

/* Table */
.toolbar {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
        padding: 14px 16px;
        border-bottom: 1px solid var(--border);
}

.search-input {
        flex: 1 1 260px;
        max-width: 380px;
}

.toolbar-count {
        margin-left: auto;
        color: var(--muted);
}

.table-wrap {
        overflow-x: auto;
}

.table {
        width: 100%;
        border-collapse: collapse;
}

.table th {
        padding: 10px 16px;
        background: #fafafb;
        border-bottom: 1px solid var(--border);
        font-size: 12px;
        font-weight: 600;
        text-align: left;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--muted);
}

.table td {
        padding: 12px 16px;
        border-bottom: 1px solid var(--border);
        vertical-align: middle;
}

.table tbody tr:hover {
        background: #fafbfd;
}

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

.table .num {
        text-align: right;
}

.table .actions {
        text-align: right;
}

.strong {
        font-weight: 600;
}

.nowrap {
        white-space: nowrap;
}

.pager {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 14px;
        border-top: 1px solid var(--border);
}

/* Users */
.section-gap {
        margin-top: 24px;
}

.check-box {
        height: 38px;
        color: var(--text);
}

.row-actions {
        display: inline-flex;
        gap: 4px;
        justify-content: flex-end;
}

.row-actions form {
        margin: 0;
}

.btn-danger {
        background: transparent;
        color: var(--red);
}

.btn-danger:hover {
        background: var(--red-soft);
}

.credential {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px 32px;
        flex-wrap: wrap;
        padding: 16px 20px;
        margin-bottom: 20px;
        background: var(--green-soft);
        border: 1px solid #b8e4c8;
        border-left: 4px solid var(--green);
        border-radius: var(--radius);
}

.credential p {
        margin: 2px 0 0;
}

.credential dl {
        display: flex;
        gap: 32px;
        margin: 0;
}

.credential dt {
        font-size: 12px;
        color: var(--muted);
}

.credential dd {
        margin: 0;
        display: flex;
        align-items: center;
        gap: 6px;
}

code {
        font: 600 14px var(--mono);
        padding: 2px 6px;
        border-radius: 4px;
        background: var(--surface);
}

/* Auth */
.auth-body {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        padding: 24px;
        background: linear-gradient(180deg, var(--navy) 0, var(--navy) 42%, var(--bg) 42%);
}

.auth-card {
        width: 100%;
        max-width: 400px;
        padding: 32px;
        background: var(--surface);
        border-radius: 12px;
        box-shadow: 0 12px 32px rgba(18, 28, 45, 0.18);
}

.auth-card h1 {
        font-size: 22px;
        margin-bottom: 20px;
}

.auth-card .alert {
        margin-bottom: 16px;
}

.auth-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 28px;
}

.auth-brand div {
        display: flex;
        flex-direction: column;
        line-height: 1.25;
}

.auth-brand .muted {
        font-size: 12px;
}

/* Responsive */
@media (max-width: 900px) {
        .shell {
                flex-direction: column;
        }

        .sidebar {
                position: static;
                width: 100%;
                height: auto;
                flex-direction: row;
                flex-wrap: wrap;
                align-items: center;
                gap: 4px;
                padding: 10px 12px;
        }

        .brand {
                padding: 0 8px 0 0;
        }

        .brand-text small,
        .nav-section {
                display: none;
        }

        .nav {
                flex-direction: row;
        }

        .sidebar-footer {
                margin: 0 0 0 auto;
                padding: 0;
                border: 0;
        }

        .topbar,
        .content {
                padding-left: 16px;
                padding-right: 16px;
        }

        .grid-2,
        .grid-3 {
                grid-template-columns: 1fr;
        }
}
