:root {
    --hcad-navy: #004481;
    --hcad-navy-dark: #003366;
    --hcad-red: #d9534f;
    --hcad-red-dark: #c9302c;
    --hcad-gray: #f5f5f5;
    --hcad-border: #e5e5e5;
    --hcad-text: #333;
    --hcad-muted: #666;
    --bg-page: #fafafa;
    --bg-surface: #ffffff;
    --bg-input: #ffffff;
    --bg-subtle: #f5f5f5;
    --row-hover: #f9f9f9;
    --input-border: #ccc;
}

[data-theme="dark"] {
    --hcad-navy: #1a5fa3;
    --hcad-navy-dark: #134a82;
    --hcad-red: #e26b67;
    --hcad-red-dark: #c9302c;
    --hcad-gray: #2a2f36;
    --hcad-border: #3a3f47;
    --hcad-text: #e8eaed;
    --hcad-muted: #a0a4ab;
    --bg-page: #15181d;
    --bg-surface: #1f2329;
    --bg-input: #2a2f36;
    --bg-subtle: #2a2f36;
    --row-hover: #262a31;
    --input-border: #3a3f47;
}

html {
    position: relative;
    min-height: 100%;
}

body {
    margin-bottom: 60px;
    font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--hcad-text);
    background: var(--bg-page);
    transition: background 0.2s, color 0.2s;
}

.navbar-hcad {
    background: var(--hcad-navy);
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-hcad .navbar-brand {
    color: #fff !important;
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: 0.5px;
}

.navbar-hcad .nav-link {
    color: rgba(255,255,255,0.85) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: 4px;
    transition: background 0.15s;
}

.navbar-hcad .nav-link:hover,
.navbar-hcad .nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,0.12);
}

.page-header {
    background: var(--bg-surface);
    padding: 25px 30px;
    margin-bottom: 25px;
    border-left: 4px solid var(--hcad-navy);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.page-header h1 {
    margin: 0;
    color: var(--hcad-navy);
    font-size: 1.75rem;
    font-weight: 600;
}

.page-header .page-subtitle {
    color: var(--hcad-muted);
    margin-top: 4px;
    font-size: 0.95rem;
}

.card-hcad {
    background: var(--bg-surface);
    border: 1px solid var(--hcad-border);
    border-radius: 6px;
    padding: 25px 30px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.btn-hcad-primary {
    background: var(--hcad-navy);
    border: 1px solid var(--hcad-navy);
    color: #fff;
    padding: 8px 20px;
    border-radius: 4px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: background 0.15s;
    cursor: pointer;
}

.btn-hcad-primary:hover {
    background: var(--hcad-navy-dark);
    border-color: var(--hcad-navy-dark);
    color: #fff;
    text-decoration: none;
}

.btn-hcad-danger {
    background: var(--hcad-red);
    border: 1px solid var(--hcad-red);
    color: #fff;
    padding: 8px 20px;
    border-radius: 4px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
}

.btn-hcad-danger:hover {
    background: var(--hcad-red-dark);
    border-color: var(--hcad-red-dark);
    color: #fff;
    text-decoration: none;
}

.btn-hcad-outline {
    background: transparent;
    border: 1px solid var(--hcad-navy);
    color: var(--hcad-navy);
    padding: 8px 20px;
    border-radius: 4px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
}

.btn-hcad-outline:hover {
    background: var(--hcad-navy);
    color: #fff;
    text-decoration: none;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 0.85rem;
}

.table-hcad {
    width: 100%;
    background: var(--bg-surface);
    border-collapse: collapse;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border-radius: 6px;
    overflow: hidden;
}

.table-hcad thead {
    background: var(--hcad-navy);
    color: #fff;
}

.table-hcad thead th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-hcad tbody tr {
    border-bottom: 1px solid var(--hcad-border);
    transition: background 0.1s;
}

.table-hcad tbody tr:hover {
    background: var(--row-hover);
}

.table-hcad tbody td {
    padding: 12px 15px;
    vertical-align: middle;
    font-size: 0.95rem;
}

.table-hcad .actions {
    white-space: nowrap;
}

.table-hcad .actions a {
    margin-right: 6px;
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-paused {
    background: #fff3cd;
    color: #856404;
}

.status-expired {
    background: #f8d7da;
    color: #721c24;
}

.status-scheduled {
    background: #cfe2ff;
    color: #084298;
}

.badge-alert {
    background: var(--hcad-red);
    color: #fff;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-left: 6px;
}

.list-section {
    margin-bottom: 32px;
}

.list-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--hcad-navy);
    margin: 0 0 4px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--hcad-border);
}

.alert-hcad-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffe69c;
    border-left: 4px solid #e0a800;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

[data-theme="dark"] .alert-hcad-warning {
    background: #3a341f;
    color: #f0d98c;
    border-color: #5a4f2a;
    border-left-color: #e0a800;
}

.form-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--hcad-border);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section-title {
    color: var(--hcad-navy);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--hcad-text);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--hcad-text);
}

.form-control:focus {
    outline: none;
    border-color: var(--hcad-navy);
    box-shadow: 0 0 0 3px rgba(0,68,129,0.15);
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--hcad-navy);
    cursor: pointer;
}

.form-check label {
    margin: 0;
    font-weight: normal;
    cursor: pointer;
    font-size: 0.95rem;
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    padding: 15px;
    background: var(--bg-subtle);
    border-radius: 4px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 30px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc;
    border-radius: 30px;
    transition: 0.2s;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
}

input:checked + .toggle-slider {
    background: var(--hcad-navy);
}

input:checked + .toggle-slider::before {
    transform: translateX(26px);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--hcad-border);
}

.text-muted-hcad {
    color: var(--hcad-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--hcad-muted);
}

.empty-state h3 {
    color: var(--hcad-navy);
    margin-bottom: 10px;
}

.filter-bar {
    background: var(--bg-surface);
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-bar label {
    font-weight: 600;
    font-size: 0.9rem;
    margin: 0;
}

.filter-bar select {
    padding: 6px 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-size: 0.9rem;
    background: var(--bg-input);
    color: var(--hcad-text);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.dashboard-card {
    background: var(--bg-surface);
    border: 1px solid var(--hcad-border);
    border-radius: 6px;
    padding: 25px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
    display: block;
    border-top: 4px solid var(--hcad-navy);
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    text-decoration: none;
    color: inherit;
}

.dashboard-card h3 {
    color: var(--hcad-navy);
    margin: 0 0 10px 0;
    font-size: 1.25rem;
}

.dashboard-card p {
    color: var(--hcad-muted);
    margin: 0;
    font-size: 0.95rem;
}

.dashboard-stat {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    color: var(--hcad-text);
}

.dashboard-stat strong {
    font-size: 1.4rem;
    color: var(--hcad-navy);
    margin-right: 4px;
}

.footer-hcad {
    background: var(--hcad-navy);
    color: rgba(255,255,255,0.75);
    padding: 20px 0;
    text-align: center;
    font-size: 0.85rem;
    margin-top: 40px;
}

.theme-toggle {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
    margin-left: 12px;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.22);
}

.theme-toggle .icon {
    font-size: 1rem;
    line-height: 1;
}

.navbar-user {
    color: rgba(255,255,255,0.9);
    font-weight: 500;
    padding: 0 0.5rem 0 1rem;
    font-size: 0.9rem;
}

.logout-form {
    margin: 0;
}

/* --- Auth / login pages --- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

.auth-brand {
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 0.5px;
    color: var(--hcad-navy);
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 3px solid var(--hcad-red);
    margin-bottom: 24px;
}

.auth-title {
    font-size: 1.4rem;
    margin-bottom: 6px;
}

.auth-sub {
    margin-bottom: 24px;
}

.auth-footer {
    margin-top: 20px;
    text-align: center;
    font-size: 0.9rem;
}
