/*
 * Yihao Domain Forwarding Admin
 * Shared UI layer for the legacy PHP/CoreUI surface.
 *
 * The token names mirror shadcn/ui's semantic vocabulary so the PHP
 * templates can share one visual system without moving business logic.
 */

:root {
    --background: #f6f8fb;
    --foreground: #172235;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-muted: #eef3f8;
    --surface-inset: #f8fafc;
    --border: #d8e0ea;
    --border-strong: #bcc9d8;
    --muted: #5a6a7d;
    --muted-foreground: #627286;
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-soft: #e8efff;
    --primary-foreground: #ffffff;
    --secondary: #e7edf5;
    --secondary-hover: #dbe5f0;
    --secondary-foreground: #26374d;
    --success: #167347;
    --success-soft: #e8f6ee;
    --warning: #9a6700;
    --warning-soft: #fff5d8;
    --danger: #b42318;
    --danger-hover: #912018;
    --danger-soft: #fff0ee;
    --info: #0c5a84;
    --info-soft: #e8f4fb;
    --sidebar: #10253f;
    --sidebar-deep: #0b1b31;
    --sidebar-border: rgba(255, 255, 255, 0.11);
    --sidebar-text: #e9f1fa;
    --sidebar-muted: #9eb0c6;
    --focus: #2563eb;
    --shadow-xs: 0 1px 2px rgba(16, 37, 63, 0.05);
    --shadow-sm: 0 3px 12px rgba(16, 37, 63, 0.07);
    --shadow-md: 0 14px 35px rgba(16, 37, 63, 0.12);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 999px;
    --sidebar-width: 280px;
    --header-height: 68px;
    --content-gutter: 32px;
    --motion-fast: 140ms;
    --motion-base: 180ms;
    --z-sidebar: 100;
    --z-header: 90;
    --z-overlay: 1000;
    --z-modal: 1010;
    --z-toast: 1100;
}

/* Shared compatibility aliases for legacy templates and chart configs. */
:root {
    --brand-primary: var(--primary);
    --brand-primary-hover: var(--primary-hover);
    --text-muted: var(--muted-foreground);
    --text-subtle: #718096;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--background);
}

body {
    color: var(--foreground);
    background: var(--background);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

::selection {
    color: var(--primary-foreground);
    background: var(--primary);
}

a {
    color: var(--primary);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--primary-hover);
}

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

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

:where(button, a, input, select, textarea):focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.34);
    outline-offset: 2px;
}

body.modal-open {
    overflow: hidden;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: var(--z-toast);
    padding: 9px 12px;
    color: #ffffff;
    background: var(--sidebar-deep);
    border-radius: var(--radius-md);
    transform: translateY(-160%);
    transition: transform var(--motion-fast) ease;
}

.skip-link:focus {
    color: #ffffff;
    transform: translateY(0);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
}

/* Application shell */
.wrapper {
    display: flex;
    width: 100%;
    min-height: 100dvh;
}

.sidebar {
    width: var(--sidebar-width);
    min-height: 100dvh;
    background: var(--sidebar);
    color: var(--sidebar-text);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 5px 0 24px rgba(11, 27, 49, 0.1);
    transition: margin-left var(--motion-base) ease, transform var(--motion-base) ease;
    z-index: var(--z-sidebar);
}

.sidebar.collapsed {
    margin-left: calc(var(--sidebar-width) * -1);
}

.sidebar-brand {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 22px;
    color: var(--sidebar-text);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.01em;
    border-bottom: 1px solid var(--sidebar-border);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand:hover {
    color: #ffffff;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-brand-logo {
    width: 32px;
    height: 32px;
    margin-right: 10px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    flex: 0 0 auto;
}

.sidebar-nav {
    padding: 16px 10px 24px;
}

.sidebar-nav .nav-item {
    display: block;
}

.sidebar-nav .nav-link {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 3px 0;
    padding: 9px 12px;
    color: var(--sidebar-muted);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    transition: color var(--motion-fast) ease, background-color var(--motion-fast) ease,
        border-color var(--motion-fast) ease, transform var(--motion-fast) ease;
}

.sidebar-nav .nav-link:hover {
    color: #ffffff;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-nav .nav-link:active {
    transform: translateY(1px);
}

.sidebar-nav .nav-link.active {
    color: #ffffff;
    background: rgba(37, 99, 235, 0.24);
    border-color: rgba(135, 170, 255, 0.24);
    box-shadow: inset 3px 0 0 #7fa4ff;
}

.sidebar-nav .nav-icon {
    width: 25px;
    height: 25px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 25px;
    color: #b7c9df;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.sidebar-nav .nav-link.active .nav-icon,
.sidebar-nav .nav-link:hover .nav-icon {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.14);
}

.sidebar-nav .nav-title {
    padding: 19px 12px 7px;
    color: #7f95b1;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sidebar-nav .nav-group {
    list-style: none;
    padding: 0;
}

.sidebar-nav .nav-group .nav-link {
    padding-left: 42px;
    font-size: 13px;
}

.main {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    margin-left: var(--sidebar-width);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--motion-base) ease;
}

.main.expanded {
    margin-left: 0;
}

.header {
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px var(--content-gutter);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    position: sticky;
    top: 0;
    z-index: var(--z-header);
}

.header-toggler {
    width: 40px;
    height: 40px;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--foreground);
    cursor: pointer;
    font-size: 0;
    transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease,
        transform var(--motion-fast) ease;
}

.header-toggler::before,
.header-toggler::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 2px;
    background: currentColor;
    border-radius: var(--radius-pill);
}

.header-toggler::before {
    transform: translateY(-4px);
    box-shadow: 0 8px 0 currentColor;
}

.header-toggler:hover {
    background: var(--surface-muted);
    border-color: var(--border-strong);
}

.header-toggler:active {
    transform: translateY(1px);
}

.header-nav {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

.header-nav .nav-item {
    margin-left: 12px;
}

.header-nav .nav-link {
    color: var(--foreground);
    text-decoration: none;
    display: flex;
    align-items: center;
}

.header-nav .nav-link:hover {
    color: var(--primary);
}

.header-nav .avatar {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
}

.header-nav .user-info {
    display: flex;
    align-items: center;
    gap: 9px;
}

.header-nav .role-badge {
    padding: 4px 9px;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid #cbd9ff;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
}

.user-trigger {
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    cursor: pointer;
}

.user-trigger:hover,
.user-trigger[aria-expanded="true"] {
    background: var(--surface-muted);
    border-color: var(--border);
}

.header-nav .dropdown {
    position: relative;
}

.header-nav .dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: var(--z-modal);
    display: none;
    min-width: 168px;
    padding: 6px;
    margin: 0;
    color: var(--foreground);
    text-align: left;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.header-nav .dropdown-menu.show {
    display: block;
}

.header-nav .dropdown-menu li a {
    display: block;
    padding: 9px 11px;
    color: var(--foreground);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.header-nav .dropdown-menu li a:hover {
    color: var(--primary);
    background: var(--surface-muted);
    text-decoration: none;
}

.header-nav .dropdown-divider {
    height: 1px;
    margin: 6px 0;
    background: var(--border);
}

.content {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    padding: 28px var(--content-gutter) 36px;
    background: var(--background);
}

.content-header {
    margin-bottom: 22px;
}

.content-header h1 {
    margin: 0 0 5px;
    color: var(--foreground);
    font-size: 24px;
    font-weight: 750;
    line-height: 1.25;
    text-wrap: balance;
}

.content-header + .d-flex {
    gap: 12px;
}

.content-header + .d-flex > :first-child,
.content-header + .d-flex > :last-child {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.content-header + .d-flex .ml-2,
.content-header + .d-flex .ms-2 {
    margin-left: 0 !important;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    list-style: none;
    padding: 0;
    margin: 0;
    color: var(--muted-foreground);
    font-size: 12px;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    padding: 0 8px;
    color: var(--border-strong);
}

.breadcrumb-item a {
    color: var(--muted);
}

.breadcrumb-item.active {
    color: var(--muted-foreground);
}

.site-footer {
    padding: 14px var(--content-gutter) 22px;
    color: var(--muted-foreground);
    font-size: 12px;
    line-height: 1.7;
    text-align: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 18, 33, 0.55);
    opacity: 0;
    transition: opacity var(--motion-base) ease;
    z-index: calc(var(--z-sidebar) - 1);
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Panels, cards, data and charts */
.card {
    max-width: 100%;
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    color: var(--foreground);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.card-header {
    padding: 14px 18px;
    color: var(--foreground);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.card-body {
    flex: 1 1 auto;
    padding: 18px;
}

.card-footer {
    padding: 13px 18px;
    background: var(--surface-inset);
    border-top: 1px solid var(--border);
}

.stat-card {
    border-color: var(--border);
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--motion-base) ease, transform var(--motion-base) ease,
        border-color var(--motion-base) ease;
}

.stat-card:hover {
    border-color: #b6c8e6;
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.stat-card .card-body {
    padding: 19px 18px;
}

.stat-card .stat-value,
.stat-value {
    display: block;
    margin-bottom: 4px;
    color: var(--foreground);
    font-size: 24px;
    font-weight: 760;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stat-card .stat-label,
.stat-label {
    display: block;
    color: var(--muted-foreground);
    font-size: 12px;
    line-height: 1.35;
}

.db-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.db-chart-grid,
.db-3col-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.db-chart-grid-5-7 {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
}

.db-chart-full {
    grid-column: 1 / -1;
}

.dashboard-chart-shell {
    position: relative;
    width: 100%;
    height: 300px;
    min-height: 300px;
    max-height: 300px;
}

.dashboard-chart-shell canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.table-responsive {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.table-responsive table {
    min-width: 100%;
    margin-bottom: 0;
}

.table-responsive th,
.table-responsive td {
    white-space: nowrap;
}

.table-responsive .btn {
    white-space: nowrap;
}

.scope-domain-toggle {
    color: var(--primary) !important;
    text-decoration: none !important;
    font-size: 12px;
    font-weight: 700;
}

.scope-domain-toggle:hover {
    color: var(--primary-hover) !important;
    text-decoration: underline !important;
}

.scope-domain-toggle:focus-visible {
    text-decoration: underline !important;
}

.text-muted,
small[style*="#6c757d"],
small[style*="#6C757D"] {
    color: var(--muted) !important;
}

.chart-a11y-summary {
    margin-top: 10px;
    color: var(--muted-foreground);
    font-size: 12px;
    line-height: 1.5;
}

.table {
    width: 100%;
    margin-bottom: 1rem;
    color: var(--foreground);
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.table th,
.table td {
    padding: 11px 12px;
    vertical-align: middle;
    border-top: 1px solid var(--border);
}

.table thead th {
    color: var(--muted);
    background: var(--surface-inset);
    border-top: 0;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.table tbody tr {
    transition: background-color var(--motion-fast) ease;
}

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

.table tbody tr:first-child td {
    border-top: 0;
}

.table-bordered {
    border: 0;
}

.table-bordered th,
.table-bordered td {
    border-right: 1px solid var(--border);
}

.table-bordered th:last-child,
.table-bordered td:last-child {
    border-right: 0;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(240, 244, 248, 0.42);
}

.table-striped tbody tr:nth-of-type(odd):hover {
    background: #f4f7fb;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pagination .page-item {
    display: inline-flex;
}

.pagination .page-link {
    min-width: 34px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    line-height: 1;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
}

.pagination button.page-link {
    appearance: none;
}

.pagination .page-link:hover {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: #b8caff;
}

.pagination .page-item.active .page-link {
    color: var(--primary-foreground);
    background: var(--primary);
    border-color: var(--primary);
    font-weight: 700;
}

.pagination .page-item.disabled .page-link {
    color: #9aa8b8;
    background: var(--surface-inset);
    border-color: var(--border);
    cursor: not-allowed;
    pointer-events: none;
}

.pagination .page-link[aria-current="page"] {
    color: var(--primary-foreground);
    background: var(--primary);
    border-color: var(--primary);
    font-weight: 700;
}

.rank-badge {
    min-width: 25px;
    height: 25px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid #cbd9ff;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

canvas {
    display: block;
    width: 100% !important;
}

/* Buttons and controls */
.btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    color: var(--foreground);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 650;
    line-height: 1.25;
    cursor: pointer;
    transition: color var(--motion-fast) ease, background-color var(--motion-fast) ease,
        border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease,
        transform var(--motion-fast) ease, opacity var(--motion-fast) ease;
}

.btn:hover {
    text-decoration: none;
    border-color: #9fb0c3;
    background: var(--surface-muted);
}

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

.btn:disabled,
.btn.disabled {
    opacity: 0.52;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

.btn-primary:hover,
.btn-primary:focus-visible {
    color: var(--primary-foreground);
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 3px 9px rgba(29, 78, 216, 0.22);
}

.btn-secondary {
    color: var(--secondary-foreground);
    background: var(--secondary);
    border-color: var(--secondary);
}

.btn-secondary:hover {
    color: var(--secondary-foreground);
    background: var(--secondary-hover);
    border-color: var(--secondary-hover);
}

.btn-success {
    color: #ffffff;
    background: var(--success);
    border-color: var(--success);
}

.btn-success:hover {
    color: #ffffff;
    background: #105c39;
    border-color: #105c39;
}

.btn-danger {
    color: #ffffff;
    background: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    color: #ffffff;
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

.btn-warning {
    color: #4f3600;
    background: #f7c948;
    border-color: #f7c948;
}

.btn-warning:hover {
    color: #3b2900;
    background: #eab83b;
    border-color: #eab83b;
}

.btn-info {
    color: #ffffff;
    background: var(--info);
    border-color: var(--info);
}

.btn-info:hover {
    color: #ffffff;
    background: #084365;
    border-color: #084365;
}

.btn-light {
    color: var(--secondary-foreground);
    background: var(--surface-muted);
    border-color: var(--border);
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-danger,
.btn-outline-warning,
.btn-outline-info {
    background: transparent;
}

.btn-outline-primary {
    color: var(--primary);
    border-color: #9db6ef;
}

.btn-outline-primary:hover,
.btn-outline-primary.active {
    color: #ffffff;
    background: var(--primary);
    border-color: var(--primary);
}

.btn-outline-secondary {
    color: var(--secondary-foreground);
    border-color: var(--border-strong);
}

.btn-outline-secondary:hover {
    color: var(--secondary-foreground);
    background: var(--secondary);
}

.btn-outline-info {
    color: var(--info);
    border-color: #9cc9df;
}

.btn-outline-info:hover {
    color: #ffffff;
    background: var(--info);
    border-color: var(--info);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: #e3aaa4;
}

.btn-outline-danger:hover {
    color: #ffffff;
    background: var(--danger);
    border-color: var(--danger);
}

.btn-sm {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 12px;
}

.btn-group {
    display: inline-flex;
    position: relative;
    flex-wrap: wrap;
    gap: 6px;
}

.btn-group .btn {
    border-radius: var(--radius-md);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

label,
.form-label {
    display: block;
    margin-bottom: 6px;
    color: var(--foreground);
    font-size: 13px;
    font-weight: 650;
}

.form-control {
    width: 100%;
    min-height: 40px;
    display: block;
    padding: 9px 11px;
    color: var(--foreground);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.45;
    transition: border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease,
        background-color var(--motion-fast) ease;
}

textarea.form-control {
    min-height: 92px;
    resize: vertical;
}

.form-control::placeholder {
    color: #748398;
    opacity: 1;
}

.form-control:hover {
    border-color: #9fb0c3;
}

.form-control:focus {
    color: var(--foreground);
    background: var(--surface);
    border-color: var(--focus);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-control:disabled {
    color: #7b8998;
    background: var(--surface-muted);
}

.form-control.is-invalid,
.form-control[aria-invalid="true"] {
    border-color: var(--danger);
    background: #fffafa;
}

.form-control.is-invalid:focus,
.form-control[aria-invalid="true"]:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.15);
}

.invalid-feedback,
.field-error {
    display: block;
    margin-top: 5px;
    color: var(--danger);
    font-size: 12px;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--primary);
}

small,
.small {
    color: var(--muted-foreground);
    font-size: 12px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

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

.input-group {
    display: flex;
    width: 100%;
}

.input-group > .form-control {
    min-width: 0;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group > .form-control:only-child {
    border-radius: var(--radius-md);
}

.input-group-append {
    display: flex;
}

.input-group-append .btn {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    white-space: nowrap;
}

.custom-switch input {
    accent-color: var(--primary);
}

/* Status feedback */
.alert {
    position: relative;
    padding: 11px 14px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 13px;
}

.alert-success {
    color: #125c3a;
    background: var(--success-soft);
    border-color: #a9ddbf;
}

.alert-danger {
    color: #8c1d15;
    background: var(--danger-soft);
    border-color: #edb6b0;
}

.alert-warning {
    color: #6d4b00;
    background: var(--warning-soft);
    border-color: #efd17a;
}

.alert-info {
    color: #0b4b6c;
    background: var(--info-soft);
    border-color: #add4e7;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    color: var(--secondary-foreground);
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 750;
    line-height: 1.1;
    vertical-align: middle;
}

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

.badge-success {
    color: #125c3a;
    background: var(--success-soft);
    border-color: #a9ddbf;
}

.badge-danger {
    color: #8c1d15;
    background: var(--danger-soft);
    border-color: #edb6b0;
}

.badge-warning {
    color: #6d4b00;
    background: var(--warning-soft);
    border-color: #efd17a;
}

.badge-info {
    color: #0b4b6c;
    background: var(--info-soft);
    border-color: #add4e7;
}

/* Modal and overlay */
.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: none;
    width: 100%;
    height: 100%;
    padding: 24px;
    overflow-x: hidden;
    overflow-y: auto;
    background: rgba(7, 18, 33, 0.62);
    outline: 0;
}

.modal.show {
    display: block;
}

.modal-dialog {
    width: auto;
    max-width: 720px;
    min-height: calc(100% - 24px);
    display: flex;
    align-items: center;
    margin: 0 auto;
}

.modal-content {
    width: 100%;
    max-height: calc(100dvh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--foreground);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.modal-header,
.modal-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
    background: var(--surface);
}

.modal-header {
    border-bottom: 1px solid var(--border);
}

.modal-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--border);
}

.modal-title {
    margin: 0;
    color: var(--foreground);
    font-size: 16px;
    font-weight: 750;
}

.modal-body {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    padding: 18px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.close {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.close:hover {
    color: var(--foreground);
    background: var(--surface-muted);
    border-color: var(--border);
}

.nav-tpl-card {
    min-width: 112px;
    transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease,
        box-shadow var(--motion-fast) ease;
}

.nav-tpl-card:hover {
    border-color: #9db6ef !important;
    background: var(--primary-soft) !important;
}

/* Pagination */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-left: 0;
    margin: 0;
    list-style: none;
}

.page-item {
    margin: 0;
}

.page-link {
    min-width: 34px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 9px;
    color: var(--secondary-foreground);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 12px;
    text-decoration: none;
}

.page-link:hover {
    color: var(--primary);
    background: var(--surface-muted);
    text-decoration: none;
}

.page-item.active .page-link {
    color: #ffffff;
    background: var(--primary);
    border-color: var(--primary);
}

.page-item.disabled .page-link {
    color: #8a97a6;
    background: var(--surface-muted);
    cursor: not-allowed;
    pointer-events: none;
}

/* Loading, empty and inline status helpers */
.loading {
    width: 16px;
    height: 16px;
    display: inline-block;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner 650ms linear infinite;
    vertical-align: -3px;
}

.skeleton {
    min-height: 14px;
    display: block;
    border-radius: var(--radius-sm);
    background: #e8eef5;
}

td.text-center:has(.loading),
td.text-center {
    min-height: 48px;
}

.empty-state {
    padding: 34px 18px;
    color: var(--muted-foreground);
    text-align: center;
}

.empty-state strong {
    display: block;
    margin-bottom: 4px;
    color: var(--foreground);
}

.empty-state .btn {
    margin-top: 12px;
}

.table .text-center {
    min-height: 52px;
    vertical-align: middle;
}

.table td code,
.table td .url-value {
    color: var(--secondary-foreground);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
}

.cron-task-url {
    display: inline-block;
    max-width: 100%;
    margin-top: 4px;
    padding: 4px 8px;
    color: var(--secondary-foreground);
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    user-select: all;
}

.chart-shell {
    position: relative;
    min-height: 250px;
}

.chart-shell canvas {
    min-height: 250px;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-indicator::before {
    content: "";
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    background: currentColor;
}

.status-indicator.is-success { color: var(--success); }
.status-indicator.is-warning { color: var(--warning); }
.status-indicator.is-danger { color: var(--danger); }
.status-indicator.is-muted { color: var(--muted); }

.dns-summary-row {
    align-items: stretch;
}

.dns-summary-col {
    display: flex;
}

.dns-summary-col > .card {
    width: 100%;
    height: 100%;
}

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

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* Responsive shell */
.mobile-mini-sidebar {
    display: none;
}

@media (max-width: 1100px) {
    :root {
        --content-gutter: 24px;
    }

    .sidebar {
        width: 248px;
    }

    .main {
        margin-left: 248px;
    }

    .sidebar.collapsed {
        margin-left: -248px;
    }

    .db-chart-grid-5-7 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --content-gutter: 16px;
    }

    .sidebar {
        width: min(296px, calc(100vw - 56px));
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        margin-left: 0;
        box-shadow: var(--shadow-md);
        z-index: calc(var(--z-sidebar) + 1);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .mobile-mini-sidebar {
        width: 56px;
        display: flex;
        flex-direction: column;
        align-items: center;
        position: fixed;
        inset: 0 auto 0 0;
        padding-top: 6px;
        overflow-y: auto;
        overflow-x: hidden;
        background: var(--sidebar-deep);
        border-right: 1px solid var(--sidebar-border);
        z-index: var(--z-sidebar);
    }

    .mobile-mini-sidebar .mini-toggle,
    .mobile-mini-sidebar .mini-link {
        width: 44px;
        height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin: 2px 0;
        padding: 0;
        color: var(--sidebar-muted);
        background: transparent;
        border: 1px solid transparent;
        border-radius: var(--radius-md);
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
        font-size: 10px;
        font-weight: 800;
        text-decoration: none;
    }

    .mobile-mini-sidebar .mini-toggle {
        font-size: 0;
        position: relative;
        cursor: pointer;
    }

    .mobile-mini-sidebar .mini-toggle::before,
    .mobile-mini-sidebar .mini-toggle::after {
        content: "";
        position: absolute;
        width: 16px;
        height: 2px;
        background: currentColor;
        border-radius: var(--radius-pill);
    }

    .mobile-mini-sidebar .mini-toggle::before {
        transform: translateY(-4px);
        box-shadow: 0 8px 0 currentColor;
    }

    .mobile-mini-sidebar .mini-link:hover,
    .mobile-mini-sidebar .mini-link.active,
    .mobile-mini-sidebar .mini-toggle:hover {
        color: #ffffff;
        background: rgba(255, 255, 255, 0.11);
        border-color: rgba(255, 255, 255, 0.12);
    }

    .mobile-mini-sidebar .mini-link.active::before {
        content: "";
        position: absolute;
        left: 0;
        width: 3px;
        height: 24px;
        background: #8babff;
        border-radius: 0 2px 2px 0;
    }

    .mobile-mini-sidebar .mini-sep {
        width: 26px;
        height: 1px;
        margin: 6px 0;
        background: var(--sidebar-border);
    }

    .main {
        margin-left: 56px;
    }

    .main.expanded {
        margin-left: 56px;
    }

    .header {
        min-height: 60px;
        padding: 10px var(--content-gutter);
        justify-content: flex-end;
    }

    .header-toggler {
        display: none;
    }

    .content {
        padding-top: 22px;
    }

    .dns-summary-row {
        margin-right: -5px !important;
        margin-left: -5px !important;
    }

    .dns-summary-col {
        min-width: 0;
        padding-right: 5px !important;
        padding-left: 5px !important;
    }

    .content-header {
        margin-bottom: 18px;
    }

    .content-header h1 {
        font-size: 21px;
    }

    .header-nav .username-text {
        max-width: 86px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-nav .role-badge {
        display: none;
    }

    .db-chart-grid,
    .db-chart-grid-5-7,
    .db-3col-grid,
    .settings-2col {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .db-chart-full {
        grid-column: auto;
    }

    .content-header + div[class*="d-flex"] {
        align-items: stretch;
        flex-wrap: wrap;
        gap: 9px;
    }

    .content-header + div[class*="d-flex"] > div {
        width: 100%;
    }

    .content-header + div[class*="d-flex"] .form-control {
        width: min(100%, 100%) !important;
        margin-left: 0 !important;
    }

    .content-header + div[class*="d-flex"] .btn {
        margin-left: 0;
        margin-right: 5px;
        margin-bottom: 5px;
    }

    .content-header + .d-flex > :first-child,
    .content-header + .d-flex > :last-child {
        width: 100%;
    }

    .content-header + .d-flex > :last-child .form-control {
        flex: 1 1 180px;
        width: auto !important;
    }

    .content-header + .d-flex > :last-child .btn {
        flex: 0 0 auto;
    }

    .modal {
        padding: 8px;
    }

    .modal-dialog {
        min-height: calc(100% - 16px);
    }

    .modal-content {
        max-height: calc(100dvh - 16px);
    }

    .modal-body {
        padding: 15px;
    }

    .modal-footer {
        padding: 12px 15px;
    }

    .table {
        font-size: 12px;
    }

    .table th,
    .table td {
        padding: 9px 10px;
    }

    .site-footer {
        padding-right: 16px;
        padding-left: 16px;
    }
}

@media (max-width: 480px) {
    .db-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stat-card .card-body {
        padding: 14px 12px;
    }

    .stat-card .stat-value,
    .stat-value {
        font-size: 20px;
    }

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

    .header-nav .username-text {
        max-width: 70px;
    }
}
