:root {
    --primary: #409eff;
    --primary-dark: #337ecc;
    --primary-soft: #ecf5ff;
    --success: #16a34a;
    --success-soft: #ecfdf3;
    --danger: #e5484d;
    --danger-soft: #fff1f2;
    --warning: #d97706;
    --warning-soft: #fff7ed;
    --purple: #7c3aed;
    --purple-soft: #f5f3ff;
    --text: #303133;
    --text-secondary: #606266;
    --muted: #909399;
    --line: #e5e7eb;
    --line-strong: #dcdfe6;
    --surface: #ffffff;
    --canvas: #f3f4f6;
    --sidebar-width: 240px;
    --topbar-height: 72px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 4px rgba(15, 23, 42, .04);
    --shadow-md: 0 12px 32px rgba(15, 23, 42, .12);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
    color: var(--text);
    background: var(--canvas);
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

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

body {
    font-size: 14px;
    line-height: 1.5;
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

[hidden] {
    display: none !important;
}

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

.block {
    display: block;
}

.align-right {
    text-align: right !important;
}

.danger-text {
    color: var(--danger) !important;
}

.success-text {
    color: var(--success) !important;
}

/* Authentication */
.auth-page {
    overflow-x: hidden;
    background: #fff;
}

.auth-layout {
    display: grid;
    grid-template-columns: minmax(420px, 42%) 1fr;
    min-height: 100vh;
}

.auth-form-section {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px clamp(28px, 5vw, 84px);
    background: #fff;
    z-index: 2;
}

.auth-form-wrap {
    width: min(100%, 440px);
}

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

.auth-brand {
    margin-bottom: 66px;
}

.brand-mark {
    display: inline-grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(145deg, #66b1ff, #337ecc);
    box-shadow: 0 8px 18px rgba(64, 158, 255, .26);
    font-size: 19px;
    font-weight: 800;
}

.brand-eyebrow,
.modal-eyebrow,
.breadcrumb {
    margin: 0;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .13em;
}

.auth-brand h1 {
    margin: 1px 0 0;
    font-size: 22px;
    line-height: 1.2;
}

.auth-heading h2 {
    margin: 0 0 10px;
    font-size: clamp(26px, 3vw, 34px);
    line-height: 1.2;
    letter-spacing: -.02em;
}

.auth-heading p {
    margin: 0 0 34px;
    color: var(--text-secondary);
}

.auth-form {
    display: grid;
    gap: 22px;
}

.field {
    display: grid;
    gap: 8px;
    min-width: 0;
    color: var(--text-secondary);
    font-weight: 600;
}

.field > span b {
    color: var(--danger);
}

.field small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.field input,
.field select,
.field textarea,
.search-box input {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    outline: none;
    color: var(--text);
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.field input,
.field select {
    height: 42px;
    padding: 0 12px;
}

.field textarea {
    min-height: 78px;
    padding: 10px 12px;
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(64, 158, 255, .13);
}

.field input:disabled {
    color: var(--muted);
    background: #f5f7fa;
    cursor: not-allowed;
}

.input-with-icon {
    position: relative;
    display: block;
}

.input-with-icon svg {
    position: absolute;
    top: 50%;
    left: 14px;
    width: 19px;
    height: 19px;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.input-with-icon input {
    height: 50px;
    padding-left: 44px;
}

.btn {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 8px 16px;
    font-weight: 600;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

.btn.is-loading {
    cursor: wait;
}

.btn-primary {
    color: #fff;
    border-color: var(--primary);
    background: var(--primary);
}

.btn-primary:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
}

.btn-ghost {
    color: var(--text-secondary);
    border-color: var(--line-strong);
    background: #fff;
}

.btn-ghost:hover {
    color: var(--primary);
    border-color: #a0cfff;
    background: var(--primary-soft);
}

.btn-block {
    width: 100%;
    min-height: 50px;
    margin-top: 4px;
}

.btn-sm {
    min-height: 32px;
    padding: 5px 11px;
    font-size: 13px;
}

.button-spinner,
.loader-spinner {
    display: none;
    width: 17px;
    height: 17px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .75s linear infinite;
}

.is-loading .button-spinner {
    display: inline-block;
}

.is-loading .button-label {
    opacity: .75;
}

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

.alert {
    margin-bottom: 20px;
    border: 1px solid;
    border-radius: 8px;
    padding: 11px 13px;
    font-size: 13px;
}

.alert-danger {
    color: #b4232b;
    border-color: #fecdd3;
    background: var(--danger-soft);
}

.auth-security-note {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    margin: 28px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.auth-security-note svg {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    color: var(--success);
}

.auth-visual {
    position: relative;
    display: grid;
    min-height: 100vh;
    place-items: center;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(145deg, #0f5fa9 0%, #1677c8 48%, #43a4ef 100%);
}

.auth-grid {
    position: absolute;
    inset: 0;
    opacity: .15;
    background-image: linear-gradient(rgba(255,255,255,.22) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.22) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(circle at center, #000 20%, transparent 78%);
}

.auth-visual::before,
.auth-visual::after {
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    content: "";
    filter: blur(4px);
}

.auth-visual::before {
    top: -190px;
    right: -110px;
    background: rgba(255,255,255,.11);
}

.auth-visual::after {
    bottom: -230px;
    left: -120px;
    background: rgba(5, 55, 112, .25);
}

.visual-card {
    position: absolute;
    z-index: 2;
    border: 1px solid rgba(255,255,255,.25);
    background: rgba(255,255,255,.14);
    box-shadow: 0 28px 60px rgba(6, 52, 100, .24);
    backdrop-filter: blur(16px);
}

.visual-card-main {
    width: min(440px, 64%);
    border-radius: 24px;
    padding: 38px;
    transform: rotate(-2deg);
}

.visual-card-icon {
    display: grid;
    width: 54px;
    height: 54px;
    place-items: center;
    margin-bottom: 30px;
    border-radius: 16px;
    background: rgba(255,255,255,.18);
    font-size: 28px;
}

.visual-card-main p {
    margin: 0 0 3px;
    color: rgba(255,255,255,.72);
}

.visual-card-main strong {
    font-size: clamp(25px, 3vw, 38px);
}

.visual-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 34px;
}

.visual-stats span {
    display: grid;
    gap: 5px;
    border-radius: 12px;
    padding: 13px;
    background: rgba(255,255,255,.1);
    color: rgba(255,255,255,.73);
    font-size: 11px;
}

.visual-stats b {
    color: #fff;
    font-size: 13px;
}

.visual-card-small {
    display: grid;
    width: 110px;
    height: 62px;
    place-items: center;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .13em;
}

.visual-card-small.one {
    top: 22%;
    right: 10%;
    transform: rotate(8deg);
}

.visual-card-small.two {
    bottom: 19%;
    left: 9%;
    transform: rotate(-7deg);
}

.visual-orbit {
    width: min(650px, 82%);
    aspect-ratio: 1;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 50%;
}

/* Console shell */
.console-page {
    overflow: hidden;
    background: var(--canvas);
}

.console-layout {
    display: flex;
    width: 100%;
    height: 100vh;
}

.sidebar {
    position: relative;
    z-index: 40;
    display: flex;
    width: var(--sidebar-width);
    height: 100%;
    flex: 0 0 var(--sidebar-width);
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: #fff;
}

.console-brand {
    height: var(--topbar-height);
    flex: 0 0 var(--topbar-height);
    border-bottom: 1px solid var(--line);
    padding: 0 18px;
    color: var(--text);
    text-decoration: none;
}

.console-brand small,
.console-brand strong {
    display: block;
}

.console-brand small {
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .1em;
}

.console-brand strong {
    font-size: 17px;
}

.console-nav {
    flex: 1;
    overflow-y: auto;
    padding: 18px 12px;
}

.nav-label {
    margin: 0 10px 8px;
    color: #a8abb2;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
}

.nav-item {
    display: flex;
    width: 100%;
    height: 46px;
    align-items: center;
    gap: 12px;
    margin: 3px 0;
    border: 0;
    border-radius: 7px;
    padding: 0 13px;
    color: var(--text-secondary);
    background: transparent;
    text-align: left;
    transition: color .15s ease, background .15s ease;
}

.nav-item:hover {
    color: var(--primary);
    background: #f5f7fa;
}

.nav-item.is-active {
    color: var(--primary);
    background: var(--primary-soft);
    font-weight: 600;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.sidebar-foot {
    display: flex;
    min-height: 56px;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--line);
    padding: 12px 20px;
    color: var(--muted);
    font-size: 10px;
}

.sidebar-foot b {
    font-weight: 500;
}

.environment-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, .12);
}

.console-main {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.topbar {
    position: relative;
    z-index: 20;
    display: flex;
    height: var(--topbar-height);
    flex: 0 0 var(--topbar-height);
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    padding: 0 24px;
    background: #fff;
}

.topbar-left,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar h1 {
    margin: 1px 0 0;
    font-size: 20px;
    line-height: 1.2;
}

.icon-button {
    display: inline-grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    background: transparent;
    font-size: 23px;
    line-height: 1;
}

.icon-button:hover {
    color: var(--primary);
    border-color: var(--line);
    background: #f8fafc;
}

.icon-button svg {
    width: 20px;
    height: 20px;
}

.user-menu-wrap {
    position: relative;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    border: 0;
    border-radius: 9px;
    padding: 5px 8px;
    color: var(--text);
    background: transparent;
}

.user-chip:hover {
    background: #f5f7fa;
}

.user-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, #79bbff, #337ecc);
    font-weight: 700;
}

.user-copy {
    display: grid;
    text-align: left;
}

.user-copy strong {
    max-width: 150px;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-copy small {
    color: var(--muted);
    font-size: 9px;
    letter-spacing: .05em;
}

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

.user-menu {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    width: 154px;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 6px;
    background: #fff;
    box-shadow: var(--shadow-md);
}

.user-menu button {
    width: 100%;
    border: 0;
    border-radius: 6px;
    padding: 9px 10px;
    color: var(--text-secondary);
    background: transparent;
    text-align: left;
}

.user-menu button:hover {
    background: #f5f7fa;
}

.content-area {
    flex: 1;
    overflow: auto;
    padding: 24px;
}

.view-section {
    display: none;
    width: min(100%, 1500px);
    margin: 0 auto;
    animation: fadeIn .18s ease;
}

.view-section.is-active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: none; }
}

.page-intro {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.page-intro h2 {
    margin: 0 0 4px;
    font-size: 21px;
}

.page-intro p,
.panel-head p,
.modal-toolbar p,
.modal-head p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.metric-card {
    position: relative;
    display: flex;
    min-height: 126px;
    align-items: center;
    gap: 17px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 21px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.metric-card::after {
    position: absolute;
    top: -28px;
    right: -28px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: currentColor;
    content: "";
    opacity: .055;
}

.metric-icon {
    display: grid;
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 12px;
    background: currentColor;
    font-size: 17px;
    font-weight: 800;
}

.metric-card p {
    margin: 0 0 3px;
    color: var(--muted);
    font-size: 13px;
}

.metric-card strong {
    color: var(--text);
    font-size: 30px;
    line-height: 1.1;
}

.accent-blue { color: var(--primary); }
.accent-blue .metric-icon { color: var(--primary); background: var(--primary-soft); }
.accent-green { color: var(--success); }
.accent-green .metric-icon { color: var(--success); background: var(--success-soft); }
.accent-amber { color: var(--warning); }
.accent-amber .metric-icon { color: var(--warning); background: var(--warning-soft); }
.accent-purple { color: var(--purple); }
.accent-purple .metric-icon { color: var(--purple); background: var(--purple-soft); }

.panel {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.panel-head {
    display: flex;
    min-height: 68px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--line);
    padding: 14px 18px;
}

.panel-head h3 {
    margin: 0 0 2px;
    font-size: 16px;
}

.filter-head {
    min-height: 62px;
}

.search-box {
    position: relative;
    display: block;
    width: min(360px, 100%);
}

.search-box svg {
    position: absolute;
    top: 50%;
    left: 12px;
    width: 17px;
    height: 17px;
    color: var(--muted);
    transform: translateY(-50%);
}

.search-box input {
    height: 38px;
    padding: 0 12px 0 38px;
}

.result-count {
    color: var(--muted);
    font-size: 12px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th,
td {
    border-bottom: 1px solid #ebeef5;
    padding: 13px 16px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--text-secondary);
    background: #f5f7fa;
    font-size: 12px;
    font-weight: 600;
}

td {
    color: var(--text-secondary);
    font-size: 13px;
}

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

tbody tr:hover td {
    background: #fafcff;
}

td strong {
    color: var(--text);
}

code {
    border-radius: 4px;
    padding: 2px 5px;
    color: #52606d;
    background: #f3f4f6;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
}

.table-title {
    display: grid;
    justify-items: start;
    gap: 3px;
}

.empty-cell {
    height: 116px;
    color: var(--muted);
    text-align: center;
}

.status-badge,
.type-badge,
.primary-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
}

.status-badge i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-enabled {
    color: var(--success);
    background: var(--success-soft);
}

.status-disabled {
    color: #7c8491;
    background: #f1f3f5;
}

.type-badge {
    color: #475569;
    border-radius: 5px;
    background: #f1f5f9;
    letter-spacing: .03em;
}

.primary-badge {
    color: var(--primary);
    background: var(--primary-soft);
}

.table-actions {
    min-width: 195px;
}

.btn-link,
.count-link {
    border: 0;
    padding: 3px 5px;
    color: var(--primary);
    background: transparent;
    font-size: 12px;
    font-weight: 600;
}

.btn-link:hover,
.count-link:hover {
    text-decoration: underline;
}

.request-id {
    display: inline-block;
    max-width: 135px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.inline-field {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12px;
}

.inline-field select {
    width: 230px;
    height: 36px;
}

/* Modals */
.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
}

.modal-nested {
    z-index: 110;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .42);
    opacity: 0;
    transition: opacity .16s ease;
    backdrop-filter: blur(2px);
}

.modal-dialog {
    position: relative;
    display: flex;
    width: min(620px, 100%);
    max-height: calc(100vh - 48px);
    flex-direction: column;
    overflow: hidden;
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 26px 70px rgba(15, 23, 42, .22);
    opacity: 0;
    transform: translateY(10px) scale(.985);
    transition: opacity .16s ease, transform .16s ease;
}

.modal.is-open .modal-backdrop,
.modal.is-open .modal-dialog {
    opacity: 1;
}

.modal.is-open .modal-dialog {
    transform: none;
}

.modal-xl .modal-dialog,
.modal-dialog.modal-xl {
    width: min(1060px, 100%);
}

.modal-sm .modal-dialog,
.modal-dialog.modal-sm {
    width: min(480px, 100%);
}

.modal-head {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--line);
    padding: 18px 20px;
}

.modal-head h2 {
    margin: 2px 0 0;
    font-size: 19px;
}

.modal-head > div > p:last-child:not(.modal-eyebrow) {
    margin-top: 3px;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-body.no-pad {
    padding: 0;
}

.modal-foot,
.modal-toolbar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--line);
    padding: 13px 20px;
    background: #fafafa;
}

.modal-toolbar {
    justify-content: space-between;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

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

.reset-target {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #f8fafc;
}

.reset-target span {
    color: var(--muted);
}

.reset-mode {
    display: grid;
    gap: 10px;
    margin: 0;
    border: 0;
    padding: 0;
}

.reset-mode legend {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 600;
}

.reset-mode label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
}

.reset-mode label:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.reset-mode input {
    margin-top: 4px;
}

.reset-mode span,
.reset-mode small {
    display: block;
}

.reset-mode small {
    margin-top: 3px;
    color: var(--muted);
}

.password-policy {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    background: #f8fafc;
}

.password-policy p {
    margin: 4px 0 8px;
    color: var(--muted);
    font-size: 12px;
}

.password-policy ul {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.password-policy li {
    color: var(--text-secondary);
    font-size: 12px;
}

.password-policy li::before {
    margin-right: 6px;
    color: var(--muted);
    content: "○";
}

.password-policy li.is-met {
    color: var(--success);
}

.password-policy li.is-met::before {
    content: "✓";
}

.password-policy li.is-unmet {
    color: var(--danger);
}

.password-policy li.is-unmet::before {
    color: var(--danger);
    content: "×";
}

.password-policy .field-error {
    margin: 10px 0 0;
    color: var(--danger);
    font-weight: 600;
}

.password-policy .field-error[hidden] {
    display: none;
}

.password-policy-form {
    display: grid;
    gap: 18px;
}

.policy-state-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 12px 14px;
    background: #f8fafc;
}

.policy-state-banner p,
.policy-section-head p,
.policy-preview p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.policy-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr);
    gap: 20px;
}

.policy-editor,
.policy-preview {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px;
}

.policy-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 0 14px;
}

.policy-section-head:not(:first-child) {
    margin-top: 24px;
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.policy-section-head h3,
.policy-preview h3 {
    margin: 0 0 3px;
    font-size: 14px;
}

.policy-toggle-grid,
.symbol-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.policy-toggle {
    height: auto;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 11px;
}

.symbol-choice-grid {
    grid-template-columns: repeat(12, minmax(32px, 1fr));
}

.symbol-choice {
    position: relative;
    cursor: pointer;
}

.symbol-choice input {
    position: absolute;
    opacity: 0;
}

.symbol-choice span {
    display: grid;
    min-height: 36px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text-secondary);
    background: #fff;
    font: 600 14px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.symbol-choice input:checked + span {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
}

.symbol-choice input:focus-visible + span {
    outline: 2px solid rgba(64, 158, 255, .35);
    outline-offset: 2px;
}

.policy-preview {
    align-self: start;
    background: #f8fafc;
}

.policy-preview ul {
    display: grid;
    gap: 8px;
    margin: 16px 0;
    padding: 0;
    list-style: none;
}

.policy-preview li {
    color: var(--text-secondary);
    font-size: 12px;
}

.policy-preview li::before {
    margin-right: 7px;
    color: var(--muted);
    content: "○";
}

.policy-preview li.is-met {
    color: var(--success);
}

.policy-preview li.is-met::before {
    content: "✓";
}

.policy-preview li.is-unmet {
    color: var(--danger);
}

.policy-preview li.is-unmet::before {
    content: "×";
}

.policy-preview .policy-note {
    margin-top: 14px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
    line-height: 1.6;
}

.policy-preview .field-error {
    margin: 14px 0 0;
    color: var(--danger);
    font-weight: 600;
}

.policy-preview .btn {
    margin-top: 12px;
}

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

.switch-stack {
    align-content: start;
}

.switch-row {
    display: flex;
    height: 28px;
    align-items: center;
    gap: 9px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.switch-row input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.switch {
    position: relative;
    width: 34px;
    height: 19px;
    border-radius: 999px;
    background: #c0c4cc;
    transition: background .15s ease;
}

.switch::after {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    content: "";
    transition: transform .15s ease;
}

.switch-row input:checked + .switch {
    background: var(--primary);
}

.switch-row input:checked + .switch::after {
    transform: translateX(15px);
}

.audit-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.audit-detail-grid h3 {
    margin: 0 0 8px;
    font-size: 13px;
}

.audit-detail-grid pre {
    min-height: 240px;
    max-height: 52vh;
    overflow: auto;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px;
    color: #dbeafe;
    background: #172033;
    font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    white-space: pre-wrap;
}

/* Feedback */
.toast-container {
    position: fixed;
    z-index: 200;
    top: 18px;
    right: 18px;
    display: grid;
    gap: 9px;
    width: min(360px, calc(100vw - 36px));
}

.toast {
    border: 1px solid var(--line);
    border-left: 4px solid var(--success);
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--text-secondary);
    background: #fff;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateX(12px);
    transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
    opacity: 1;
    transform: none;
}

.toast-error {
    border-left-color: var(--danger);
}

.page-loader {
    position: fixed;
    z-index: 180;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 10px;
    color: var(--text-secondary);
    background: rgba(255,255,255,.58);
    backdrop-filter: blur(1px);
}

.page-loader .loader-spinner {
    display: block;
    width: 28px;
    height: 28px;
    border-color: #dbeafe;
    border-top-color: var(--primary);
}

.page-loader p {
    margin: 0;
    font-size: 12px;
}

.sidebar-close,
.sidebar-backdrop,
.mobile-only {
    display: none;
}

@media (max-width: 1180px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 860px) {
    .auth-layout {
        grid-template-columns: 1fr;
    }

    .auth-form-section {
        min-height: 100vh;
    }

    .auth-visual {
        display: none;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    .sidebar.is-open {
        transform: none;
    }

    .sidebar-close {
        position: absolute;
        z-index: 2;
        top: 16px;
        right: -48px;
        display: grid;
        color: #fff;
        background: rgba(15,23,42,.72);
    }

    .sidebar-backdrop {
        position: fixed;
        z-index: 35;
        inset: 0;
        display: block;
        background: rgba(15, 23, 42, .4);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }

    .sidebar-backdrop.is-open {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-only {
        display: grid;
    }

    .content-area {
        padding: 18px;
    }

    .policy-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .auth-form-section {
        padding: 32px 22px;
    }

    .auth-brand {
        margin-bottom: 50px;
    }

    .topbar {
        padding: 0 12px;
    }

    .topbar-actions {
        gap: 2px;
    }

    .user-copy,
    .chevron {
        display: none;
    }

    .content-area {
        padding: 14px;
    }

    .page-intro,
    .page-intro-actions,
    .panel-head,
    .modal-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .metric-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .metric-card {
        min-height: 102px;
    }

    .search-box,
    .inline-field select {
        width: 100%;
    }

    .inline-field {
        align-items: stretch;
        flex-direction: column;
    }

    .modal {
        align-items: end;
        padding: 0;
    }

    .modal-dialog,
    .modal-xl .modal-dialog,
    .modal-dialog.modal-xl,
    .modal-sm .modal-dialog,
    .modal-dialog.modal-sm {
        width: 100%;
        max-height: 94vh;
        border-radius: 13px 13px 0 0;
    }

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

    .policy-toggle-grid {
        grid-template-columns: 1fr;
    }

    .symbol-choice-grid {
        grid-template-columns: repeat(6, minmax(32px, 1fr));
    }

    .field-full {
        grid-column: auto;
    }

    .audit-detail-grid pre {
        min-height: 160px;
    }
}
