:root {
    --bg: #f3f6fb;
    --panel: rgba(255, 255, 255, 0.92);
    --panel-strong: #ffffff;
    --line: rgba(23, 38, 58, 0.12);
    --text: #1e2c3a;
    --muted: #677789;
    --accent: #4496f3;
    --accent-dark: #2e78cd;
    --danger: #c54848;
    --shadow: 0 18px 48px rgba(36, 61, 91, 0.12);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(68, 150, 243, 0.14), transparent 24%),
        radial-gradient(circle at top right, rgba(68, 150, 243, 0.08), transparent 20%),
        linear-gradient(180deg, #f9fbfe 0%, #eef3f8 100%);
}

body {
    line-height: 1.45;
}

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

code, textarea, input, select {
    font-family: "SFMono-Regular", Consolas, monospace;
}

.shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    padding: 16px 14px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid rgba(23, 38, 58, 0.08);
    backdrop-filter: blur(16px);
}

.sidebar h1 {
    margin: 8px 0 2px;
    font-size: 1.2rem;
    line-height: 1.2;
}

.brand-mark {
    display: grid;
    gap: 8px;
}

.sidebar .brand-mark {
    justify-items: center;
}

.brand-home {
    display: inline-flex;
    justify-content: center;
}

.brand-logo {
    display: block;
    width: min(138px, 100%);
    height: auto;
}

.sidebar .brand-logo {
    margin-inline: auto;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: start;
    width: fit-content;
    min-width: 56px;
    padding: 7px 11px;
    border-radius: 999px;
    background: linear-gradient(135deg, #4496f3, #2f6fca);
    color: #f8fbff;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
}

.sidebar-nav a {
    padding: 9px 11px;
    border-radius: 10px;
    color: rgba(30, 44, 58, 0.72);
    transition: background 0.2s ease, color 0.2s ease;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-icon {
    width: 18px;
    height: 18px;
    color: currentColor;
    flex: 0 0 18px;
}

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

.sidebar-nav a:hover,
.sidebar-nav a.is-active {
    background: rgba(68, 150, 243, 0.12);
    color: var(--text);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid rgba(23, 38, 58, 0.08);
}

.sidebar-legal {
    margin-bottom: 8px;
    color: rgba(30, 44, 58, 0.46);
    font-size: 0.68rem;
    line-height: 1.35;
}

.nav-link-logout {
    color: rgba(30, 44, 58, 0.56);
}

.content {
    padding: 16px;
    display: grid;
    gap: 8px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: 16px;
    padding: 11px 12px;
    backdrop-filter: blur(18px);
}

.panel-danger {
    border-color: rgba(181, 63, 43, 0.2);
}

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.panel h2,
.panel h1 {
    margin: 0;
    font-size: 1rem;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.page-head-dashboard {
    display: grid;
    gap: 6px;
    align-items: start;
}

.dashboard-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
}

.page-head-tools {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.dashboard-search-form {
    position: relative;
    width: min(460px, 100%);
}

.dashboard-search-form-wide {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
}

.dashboard-toolbar .dashboard-search-form {
    width: auto !important;
    max-width: none !important;
    flex: 1 1 0%;
    min-width: 0;
}

.dashboard-toolbar > .dashboard-search-form {
    flex: 1 1 0%;
}

.dashboard-search-form-stretch {
    width: 100% !important;
    max-width: none !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
}

.dashboard-toolbar .dashboard-search-box,
.dashboard-toolbar .dashboard-search-input,
.dashboard-search-form-stretch .dashboard-search-box,
.dashboard-search-form-stretch .dashboard-search-input {
    width: 100%;
}

.dashboard-search-label {
    display: grid;
    gap: 4px;
    margin-bottom: 4px;
}

.dashboard-toolbar .dashboard-search-label {
    display: none;
}

.dashboard-search-box {
    position: relative;
}

.dashboard-search-icon {
    position: absolute;
    top: 50%;
    left: 12px;
    width: 18px;
    height: 18px;
    color: #7b8b9c;
    transform: translateY(-50%);
    pointer-events: none;
}

.dashboard-search-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.dashboard-search-input {
    padding-left: 40px;
}

.dashboard-search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 14;
    display: grid;
    gap: 4px;
    padding: 6px;
    border: 1px solid rgba(23, 38, 58, 0.12);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 44px rgba(36, 61, 91, 0.16);
    backdrop-filter: blur(16px);
}

.dashboard-search-results[hidden] {
    display: none !important;
}

.dashboard-search-result,
.dashboard-search-empty {
    display: grid;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 10px;
}

.dashboard-search-result:hover,
.dashboard-search-result.is-active {
    background: rgba(68, 150, 243, 0.1);
}

.dashboard-search-title {
    font-weight: 700;
}

.dashboard-search-meta,
.dashboard-search-empty {
    color: var(--muted);
    font-size: 0.86rem;
}

.range-form {
    display: flex;
    align-items: end;
    gap: 8px;
    flex-wrap: wrap;
}

.range-form-dashboard {
    justify-content: flex-end;
    gap: 5px;
    flex-wrap: nowrap;
    flex: 0 0 auto;
}

.range-form label {
    min-width: 128px;
}

.range-form-dashboard label {
    min-width: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.range-form-dashboard label span {
    color: var(--muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.range-form-dashboard input[type="date"] {
    min-width: 138px;
}

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

.grid-form,
.stack-form {
    display: grid;
    gap: 10px;
}

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

.full-width {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 4px;
    font-size: 0.9rem;
}

label span {
    font-weight: 600;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 9px 11px;
    border-radius: 10px;
    border: 1px solid rgba(23, 38, 58, 0.12);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
}

input::placeholder,
textarea::placeholder {
    color: #728095;
}

textarea {
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 10px;
    padding: 9px 12px;
    cursor: pointer;
    background: rgba(23, 38, 58, 0.06);
    color: var(--text);
}

.button:hover {
    filter: brightness(0.98);
}

.button-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #f8fbff;
}

.button-danger {
    background: linear-gradient(135deg, var(--danger), #7f2a1d);
    color: #fff;
}

.button-small {
    padding: 6px 9px;
    border-radius: 9px;
    font-size: 0.85rem;
}

.button-block {
    width: 100%;
}

.flash {
    padding: 9px 11px;
    border-radius: 10px;
    margin-bottom: 8px;
}

.flash-success {
    background: rgba(68, 150, 243, 0.14);
    border: 1px solid rgba(68, 150, 243, 0.26);
}

.flash-error {
    background: rgba(197, 72, 72, 0.14);
    border: 1px solid rgba(197, 72, 72, 0.24);
}

.flash-info {
    background: rgba(68, 150, 243, 0.12);
    border: 1px solid rgba(68, 150, 243, 0.22);
}

.flash a {
    color: inherit;
    font-weight: 600;
}

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

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

th, td {
    text-align: left;
    padding: 8px 7px;
    border-bottom: 1px solid rgba(23, 38, 58, 0.08);
    vertical-align: middle;
}

tr.row-active td {
    background: rgba(68, 150, 243, 0.12);
}

tr.row-active td:first-child {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

tr.row-active td:last-child {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

th {
    color: var(--muted);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(68, 150, 243, 0.16);
    color: #7fbaff;
    font-size: 0.82rem;
    font-weight: 700;
}

.badge-muted {
    background: rgba(23, 38, 58, 0.06);
    color: var(--muted);
}

.inline-form {
    display: inline;
}

.link-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.link-list a {
    color: #7fbaff;
    font-weight: 700;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 8px;
}

.metric-tile {
    display: grid;
    gap: 4px;
    padding: 11px;
    border-radius: 14px;
    border: 1px solid rgba(23, 38, 58, 0.08);
    background:
        radial-gradient(circle at top right, rgba(68, 150, 243, 0.12), transparent 34%),
        rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
}

.metric-icon {
    width: 20px;
    height: 20px;
    color: #7fbaff;
}

.metric-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}

.metric-label {
    color: var(--muted);
    font-size: 0.84rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    align-items: start;
}

.panel-chart {
    grid-row: auto;
}

.dashboard-stack {
    display: grid;
    gap: 8px;
}

.chart-wrap {
    width: 100%;
    overflow-x: auto;
}

.line-chart {
    width: 100%;
    min-width: 640px;
    height: auto;
}

.chart-grid-line {
    stroke: rgba(23, 38, 58, 0.08);
    stroke-width: 1;
}

.chart-axis-label {
    fill: #95a1b2;
    font-size: 12px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    margin-top: 6px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(23, 38, 58, 0.05);
}

.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 10px;
}

.stack-list,
.quick-grid {
    display: grid;
    gap: 7px;
}

.stack-card,
.quick-card {
    display: grid;
    gap: 3px;
    padding: 10px 11px;
    border-radius: 14px;
    border: 1px solid rgba(23, 38, 58, 0.08);
    background: rgba(255, 255, 255, 0.78);
}

.stack-list-compact {
    gap: 6px;
}

.stack-card-tight {
    padding: 8px 10px;
    border-radius: 12px;
}

.stack-card:hover,
.quick-card:hover {
    background: rgba(68, 150, 243, 0.08);
}

.stack-title,
.quick-title {
    font-weight: 700;
}

.stack-meta,
.quick-meta,
.empty-state {
    color: var(--muted);
    font-size: 0.9rem;
}

.quick-icon {
    width: 18px;
    height: 18px;
    color: #7fbaff;
}

.quick-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.compact-split {
    display: grid;
    gap: 8px;
}

.compact-split-block {
    display: grid;
    gap: 6px;
}

.compact-split-block h3 {
    margin: 0;
    font-size: 0.88rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.user-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
}

.user-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.78);
    border-radius: 16px;
    border: 1px solid rgba(23, 38, 58, 0.08);
}

.user-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.user-tile {
    display: block;
    width: 100%;
    padding: 14px 15px;
    border: 1px solid rgba(23, 38, 58, 0.08);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--text);
    text-align: left;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(36, 61, 91, 0.08);
}

.user-tile:hover {
    background: rgba(68, 150, 243, 0.1);
}

.lightbox-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(18, 28, 40, 0.38);
    backdrop-filter: blur(8px);
}

.lightbox-backdrop[hidden] {
    display: none !important;
}

.lightbox-card {
    width: min(560px, 100%);
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(23, 38, 58, 0.12);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 24px 60px rgba(20, 38, 60, 0.18);
}

.lightbox-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.lightbox-close {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    border: 0;
    background: rgba(23, 38, 58, 0.08);
    color: var(--text);
    font-size: 1.25rem;
    line-height: 1;
}

.password-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.password-field .button {
    white-space: nowrap;
}

.field-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.field-actions .button {
    white-space: nowrap;
}

.copy-field {
    display: grid;
    gap: 8px;
}

.copy-field .button {
    justify-self: start;
}

.lightbox-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

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

body.has-lightbox {
    overflow: hidden;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox input {
    width: auto;
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 20px;
}

.auth-card {
    width: min(480px, 100%);
    padding: 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
    border: 1px solid rgba(23, 38, 58, 0.08);
}

.auth-card h1 {
    margin: 10px 0 6px;
}

.panel-disclosure {
    padding: 0;
    overflow: hidden;
}

.panel-disclosure-accent {
    border: 1px solid rgba(68, 150, 243, 0.18);
    box-shadow: 0 16px 36px rgba(41, 90, 146, 0.14);
}

.disclosure-toggle {
    display: block;
    list-style: none;
    cursor: pointer;
}

.disclosure-toggle::marker {
    display: none;
}

.disclosure-toggle::-webkit-details-marker {
    display: none;
}

.disclosure-toggle-accent {
    position: relative;
    padding: 14px 16px;
    background:
        radial-gradient(circle at top right, rgba(68, 150, 243, 0.2), transparent 38%),
        linear-gradient(135deg, rgba(68, 150, 243, 0.14), rgba(46, 120, 205, 0.06)),
        rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid rgba(68, 150, 243, 0.14);
}

.disclosure-toggle-accent:hover {
    background:
        radial-gradient(circle at top right, rgba(68, 150, 243, 0.24), transparent 38%),
        linear-gradient(135deg, rgba(68, 150, 243, 0.18), rgba(46, 120, 205, 0.08)),
        rgba(255, 255, 255, 1);
}

.disclosure-toggle-accent::after {
    content: "+";
    position: absolute;
    top: 50%;
    right: 14px;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(68, 150, 243, 0.14);
    color: var(--accent-dark);
    font-size: 1.4rem;
    font-weight: 500;
    transform: translateY(-50%);
    box-shadow: inset 0 0 0 1px rgba(68, 150, 243, 0.14);
}

.panel-disclosure[open] .disclosure-toggle-accent::after {
    content: "−";
}

.disclosure-toggle-title {
    display: block;
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--text);
    padding-right: 46px;
}

.disclosure-toggle-meta {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.84rem;
    padding-right: 46px;
}

.panel-disclosure .panel-head,
.panel-disclosure form {
    padding-left: 13px;
    padding-right: 13px;
}

.panel-disclosure .panel-head {
    padding-top: 12px;
}

.panel-disclosure form {
    padding-bottom: 12px;
}

@media (max-width: 960px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .metrics-grid,
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-head-tools,
    .dashboard-search-form {
        width: 100%;
    }

    .dashboard-toolbar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .range-form-dashboard {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

}

@media (max-width: 720px) {
    .content {
        padding: 12px;
    }

    .panel {
        padding: 12px;
    }

    .grid-form {
        grid-template-columns: 1fr;
    }

    .metrics-grid,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}
