:root {
    --bg: #f0f0f1;
    --panel: #ffffff;
    --sidebar: #1d2327;
    --sidebar-hover: #2c3338;
    --sidebar-active: #2271b1;
    --text: #1d2327;
    --muted: #646970;
    --border: #dcdcde;
    --primary: #2271b1;
    --primary-hover: #135e96;
    --danger: #b32d2e;
    --success-bg: #edfaef;
    --success-text: #0a5c24;
    --error-bg: #fcf0f1;
    --error-text: #8a2424;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --radius: 12px;
    --font: "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
a { color: var(--primary); text-decoration: none; }
button, input, select { font: inherit; }
input, select { width: 100%; padding: 0.72rem 0.85rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
label span { display: block; margin-bottom: 0.45rem; color: var(--muted); font-size: 0.92rem; }
.checkbox-field { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0; }
.checkbox-field input { width: auto; margin: 0; }
.checkbox-field span { display: inline; margin: 0; color: var(--text); font-size: 1rem; }
.stack { display: grid; gap: 1rem; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.68rem 0.95rem; border: 1px solid var(--border); border-radius: 6px; background: #f6f7f7; color: var(--text); cursor: pointer; }
.button:hover { background: #f0f0f1; }
.button-primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-hover); }
.button-small { padding: 0.4rem 0.7rem; }
.button-link-danger { border: 0; padding: 0; background: transparent; color: var(--danger); }
.icon-button { min-width: 2.25rem; padding-left: 0.55rem; padding-right: 0.55rem; }
.notice { margin-bottom: 1rem; padding: 0.9rem 1rem; border-left: 4px solid currentColor; border-radius: 8px; }
.notice-success { background: var(--success-bg); color: var(--success-text); }
.notice-error { background: var(--error-bg); color: var(--error-text); }
.auth-page { min-height: 100vh; background: radial-gradient(circle at top left, rgba(34, 113, 177, 0.18), transparent 30%), linear-gradient(135deg, #eef4f8, #f7f7f7 55%, #ffffff); }
.auth-shell { display: grid; place-items: center; min-height: 100vh; padding: 2rem 2rem 6rem; }
.auth-card { width: min(100%, 460px); padding: 2rem; border: 1px solid var(--border); border-radius: 18px; background: rgba(255, 255, 255, 0.94); box-shadow: var(--shadow); }
.brand-block { margin-bottom: 1.5rem; }
.brand-block h1 { margin: 0.2rem 0 0.5rem; font-size: 2rem; }
.brand-kicker { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; color: var(--primary); }
.auth-switch { margin: 1rem 0 0; color: var(--muted); }
.auth-legal { position: fixed; left: 50%; bottom: 1rem; z-index: 10; width: min(100% - 2rem, 820px); transform: translateX(-50%); padding: 0.9rem 1rem; border: 1px solid rgba(34, 113, 177, 0.25); border-radius: 12px; background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.auth-legal p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.admin-layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; background: var(--sidebar); color: #fff; padding: 1rem 0 0; }
.sidebar-brand { padding: 0 1rem 1rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand span { margin-top: 0.25rem; color: rgba(255, 255, 255, 0.7); font-size: 0.85rem; }
.menu { display: grid; gap: 0.15rem; padding-top: 1rem; }
.sidebar-footer { margin-top: auto; padding: 1rem 0 0; }
.menu-link { display: block; padding: 0.9rem 1rem; color: rgba(255, 255, 255, 0.82); border-left: 4px solid transparent; }
.menu-link:hover, .menu-link.is-active { background: var(--sidebar-hover); }
.menu-link.is-active { border-left-color: var(--sidebar-active); color: #fff; }
.menu-group { display: block; }
.submenu { display: none; gap: 0; background: rgba(0, 0, 0, 0.12); }
.menu-group:hover .submenu,
.menu-group.is-open .submenu { display: grid; }
.submenu-link { display: block; padding: 0.75rem 1rem 0.75rem 2.25rem; color: rgba(255, 255, 255, 0.78); border-left: 4px solid transparent; font-size: 0.92rem; }
.submenu-link:hover, .submenu-link.is-active { background: var(--sidebar-hover); color: #fff; }
.submenu-link.is-active { border-left-color: var(--sidebar-active); }
.menu-link-logout { border-top: 1px solid rgba(255, 255, 255, 0.08); }
.sidebar-user { padding: 0.9rem 1rem 1rem; color: rgba(255, 255, 255, 0.72); font-size: 0.92rem; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.topbar { padding: 1.5rem 2rem; border-bottom: 1px solid var(--border); background: #fff; }
.topbar h1 { margin: 0 0 0.35rem; font-size: 1.65rem; }
.topbar p { margin: 0; color: var(--muted); }
.content { padding: 2rem; }
.dashboard-grid, .form-grid { display: grid; gap: 1rem; }
.dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-full { grid-column: 1 / -1; }
.page-section { margin-bottom: 1.5rem; }
.page-section h2 { margin: 0 0 1rem; font-size: 1.9rem; }
.card { padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.03); margin-bottom: 1rem; }
.audit-date-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.audit-filters .form-grid-full { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.filters-bar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; margin: 0 0 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.filters-bar .form-group { min-width: 260px; flex: 1 1 260px; }
.filters-bar label { display: block; margin-bottom: 0.45rem; color: var(--muted); font-size: 0.92rem; }
.filters-bar .form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.client-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.checkbox-grid { display: grid; gap: 0.5rem; margin-top: 0.5rem; }
.checkbox-item { display: flex; align-items: flex-start; gap: 0.65rem; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.checkbox-item input { width: auto; margin-top: 0.2rem; }
.checkbox-item span { margin: 0; }
.report-dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1rem; margin: 0; }
.report-dl dt { font-weight: 700; }
.report-dl dd { margin: 0; color: var(--muted); }
.metric-card { display: flex; flex-direction: column; gap: 0.4rem; }
.metric-label { color: var(--muted); }
.metric-value { font-size: 2rem; }
.inline-check { display: inline-flex; align-items: center; gap: 0.6rem; align-self: end; }
.inline-check input { width: auto; }
.table-wrap { overflow-x: auto; }
.wp-table { width: 100%; border-collapse: collapse; }
.wp-table th, .wp-table td { padding: 0.9rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.wp-table th { color: var(--muted); font-size: 0.92rem; background: #f6f7f7; }
.status-pill { display: inline-block; padding: 0.22rem 0.6rem; border-radius: 999px; font-size: 0.8rem; }
.status-pill.is-active { background: #dff4e4; color: #135e2c; }
.status-pill.is-inactive { background: #f7e0e1; color: #8a2424; }
.status-pill-neutral { background: #e8f1fb; color: #135e96; }
.inline-form { display: inline; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); }
.modal-dialog { position: relative; z-index: 1; width: min(100% - 2rem, 560px); margin: 6vh auto 0; padding: 1.25rem; border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.modal-header h3 { margin: 0; }
.modal-close { border: 0; background: transparent; font-size: 1.5rem; cursor: pointer; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }
.modal-actions-start { justify-content: flex-start; flex-wrap: wrap; }

@media (max-width: 900px) {
    .admin-layout { grid-template-columns: 1fr; }
    .sidebar { padding-bottom: 0; }
    .menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid, .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .content, .topbar { padding: 1rem; }
    .auth-shell { padding-bottom: 7.5rem; }
    .auth-card, .modal-dialog { padding: 1rem; }
    .auth-legal { left: 1rem; right: 1rem; bottom: 0.75rem; width: auto; transform: none; }
    .form-grid { grid-template-columns: 1fr; }
    .modal-actions { flex-direction: column; }
}
