/* ============================================================
   Boligplan — Apartment Association Scheduler
   Warm Scandinavian theme
   ============================================================ */

/* ── Reset & Variables ──────────────────────────────────── */
:root {
    /* Warm, natural palette */
    --clr-bg:         #FAF7F2;
    --clr-surface:    #FFFFFF;
    --clr-surface-alt:#F3EDE4;
    --clr-border:     #E2D9CC;
    --clr-text:       #2C2417;
    --clr-text-muted: #8A7E6E;
    --clr-primary:    #5B7F5E;
    --clr-primary-hover:#4A6B4D;
    --clr-primary-light:#E8F0E8;
    --clr-accent:     #C2956B;
    --clr-accent-hover:#A87D55;
    --clr-danger:     #C44D3F;
    --clr-danger-light:#FCEAE8;
    --clr-success:    #5B7F5E;
    --clr-success-light:#E8F0E8;
    --clr-warning:    #D4A843;
    --clr-warning-light:#FDF5E3;
    --clr-info:       #5578A0;
    --clr-info-light: #E8EFF5;

    /* Calendar-specific */
    --clr-period-open:      #C44D3F;
    --clr-period-open-bg:   #FCEAE8;
    --clr-period-taken:     #5B7F5E;
    --clr-period-taken-bg:  #E8F0E8;
    --clr-period-unavail:   #8A7E6E;
    --clr-period-unavail-bg:#F0ECE6;

    /* Typography */
    --ff-heading: 'Fraunces', Georgia, serif;
    --ff-body:    'DM Sans', system-ui, sans-serif;

    /* Spacing */
    --sp-xs: 0.25rem;
    --sp-sm: 0.5rem;
    --sp-md: 1rem;
    --sp-lg: 1.5rem;
    --sp-xl: 2.5rem;
    --sp-2xl: 4rem;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(44,36,23,0.06);
    --shadow-md:  0 4px 12px rgba(44,36,23,0.08);
    --shadow-lg:  0 8px 30px rgba(44,36,23,0.12);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--ff-body);
    color: var(--clr-text);
    background: var(--clr-bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4 {
    font-family: var(--ff-heading);
    font-weight: 600;
    line-height: 1.25;
    color: var(--clr-text);
}

h1 { font-size: 2rem;   margin-bottom: var(--sp-lg); }
h2 { font-size: 1.5rem; margin-bottom: var(--sp-md); }
h3 { font-size: 1.2rem; margin-bottom: var(--sp-sm); }

p { margin-bottom: var(--sp-md); }

a {
    color: var(--clr-primary);
    text-decoration: none;
    transition: color 0.2s;
}
a:hover { color: var(--clr-primary-hover); }

.text-muted { color: var(--clr-text-muted); }
.text-danger { color: var(--clr-danger); }
.text-success { color: var(--clr-success); }

/* ── Layout ─────────────────────────────────────────────── */
.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--sp-lg);
}

.main-content {
    flex: 1;
    padding: var(--sp-xl) 0;
}

/* ── Header ─────────────────────────────────────────────── */
.site-header {
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    color: var(--clr-text);
    font-family: var(--ff-heading);
    font-weight: 700;
    font-size: 1.15rem;
}
.logo:hover { color: var(--clr-text); }

.logo-icon {
    font-size: 1.6rem;
    color: var(--clr-primary);
}

.main-nav {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
}

.nav-link {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    padding: var(--sp-xs) var(--sp-sm);
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
}
.nav-link:hover {
    color: var(--clr-text);
    background: var(--clr-surface-alt);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding-left: var(--sp-sm);
    border-left: 1px solid var(--clr-border);
}

.nav-user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

/* Language switch */
.lang-switch {
    display: flex;
    gap: 2px;
    background: var(--clr-surface-alt);
    border-radius: var(--radius-full);
    padding: 2px;
}

.lang-btn {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    color: var(--clr-text-muted);
    transition: all 0.2s;
}
.lang-btn.active {
    background: var(--clr-primary);
    color: #fff;
}
.lang-btn:hover:not(.active) {
    color: var(--clr-text);
}

/* Mobile toggle */
.mobile-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--sp-sm);
}
.mobile-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--clr-text);
    border-radius: 1px;
    transition: transform 0.2s;
}

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
    background: var(--clr-surface);
    border-top: 1px solid var(--clr-border);
    padding: var(--sp-lg) 0;
    margin-top: auto;
}

.footer-inner {
    text-align: center;
    color: var(--clr-text-muted);
    font-size: 0.85rem;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-sm);
    padding: 10px 22px;
    font-family: var(--ff-body);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    background: var(--clr-primary);
    color: #fff;
}
.btn:hover {
    background: var(--clr-primary-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn--sm {
    padding: 6px 16px;
    font-size: 0.82rem;
}

.btn--outline {
    background: transparent;
    border: 1.5px solid var(--clr-primary);
    color: var(--clr-primary);
}
.btn--outline:hover {
    background: var(--clr-primary-light);
    color: var(--clr-primary);
}

.btn--danger {
    background: var(--clr-danger);
}
.btn--danger:hover {
    background: #a8392e;
}

.btn--accent {
    background: var(--clr-accent);
}
.btn--accent:hover {
    background: var(--clr-accent-hover);
}

.btn--ghost {
    background: none;
    color: var(--clr-text-muted);
    padding: 6px 12px;
}
.btn--ghost:hover {
    background: var(--clr-surface-alt);
    color: var(--clr-text);
    box-shadow: none;
    transform: none;
}

/* ── Forms ──────────────────────────────────────────────── */
.form-group {
    margin-bottom: var(--sp-md);
}

.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.88rem;
    margin-bottom: var(--sp-xs);
    color: var(--clr-text);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--ff-body);
    font-size: 0.95rem;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-md);
    background: var(--clr-surface);
    color: var(--clr-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px var(--clr-primary-light);
}

.form-control::placeholder {
    color: var(--clr-text-muted);
    opacity: 0.6;
}

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238A7E6E' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-md);
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--sp-md);
}

.form-check {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-sm);
}

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

.form-check label {
    font-size: 0.88rem;
    margin-bottom: 0;
    cursor: pointer;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-xl);
    box-shadow: var(--shadow-sm);
}

.card--flat {
    box-shadow: none;
}

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
    padding: var(--sp-md) var(--sp-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-md);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideDown 0.3s ease;
}

.alert--success {
    background: var(--clr-success-light);
    color: var(--clr-success);
    border: 1px solid #c3d9c4;
}

.alert--error {
    background: var(--clr-danger-light);
    color: var(--clr-danger);
    border: 1px solid #f0c5c0;
}

.alert--warning {
    background: var(--clr-warning-light);
    color: #8a6d1b;
    border: 1px solid #e8d699;
}

.alert--info {
    background: var(--clr-info-light);
    color: var(--clr-info);
    border: 1px solid #b3c8dc;
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    opacity: 0.5;
    line-height: 1;
    color: inherit;
}
.alert-close:hover { opacity: 1; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Auth pages ─────────────────────────────────────────── */
.auth-page {
    display: flex;
    justify-content: center;
    padding-top: var(--sp-xl);
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-2xl);
    box-shadow: var(--shadow-md);
}

.auth-card h1 {
    text-align: center;
    font-size: 1.6rem;
    margin-bottom: var(--sp-xl);
}

.auth-alt {
    text-align: center;
    margin-top: var(--sp-lg);
    font-size: 0.88rem;
    color: var(--clr-text-muted);
}

.auth-icon {
    text-align: center;
    font-size: 2.4rem;
    color: var(--clr-primary);
    margin-bottom: var(--sp-md);
}

.auth-subtitle {
    text-align: center;
    margin-bottom: var(--sp-xl);
    font-size: 0.92rem;
}

.auth-card--wide {
    max-width: 580px;
}

.auth-forgot {
    text-align: center;
    margin-top: var(--sp-md);
    font-size: 0.85rem;
}
.auth-forgot a {
    color: var(--clr-text-muted);
}
.auth-forgot a:hover {
    color: var(--clr-primary);
}

.form-section-label {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--clr-text-muted);
    margin-bottom: var(--sp-sm);
    margin-top: var(--sp-sm);
}

.btn--full {
    width: 100%;
}

.reset-info {
    text-align: center;
    padding: var(--sp-lg) 0;
}

.reset-info-icon {
    font-size: 2.5rem;
    margin-bottom: var(--sp-md);
    color: var(--clr-accent);
}

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--clr-border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: var(--clr-surface-alt);
}

th, td {
    padding: var(--sp-sm) var(--sp-md);
    text-align: left;
    border-bottom: 1px solid var(--clr-border);
}

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

tbody tr:hover {
    background: var(--clr-surface-alt);
}

/* ── Badge / pill ───────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge--pending  { background: var(--clr-warning-light); color: #8a6d1b; }
.badge--approved { background: var(--clr-success-light); color: var(--clr-success); }
.badge--rejected { background: var(--clr-danger-light);  color: var(--clr-danger); }
.badge--admin    { background: var(--clr-info-light);    color: var(--clr-info); }
.badge--formand  { background: #F0E6F5;                 color: #7B4A9E; }
.badge--root     { background: #2C2417;                  color: #FAF7F2; }

/* ── Admin nav ──────────────────────────────────────────── */
.admin-nav {
    display: flex;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-xl);
    border-bottom: 2px solid var(--clr-border);
    padding-bottom: var(--sp-sm);
}

.admin-nav a {
    padding: var(--sp-sm) var(--sp-md);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: color 0.2s, background 0.2s;
}
.admin-nav a:hover,
.admin-nav a.active {
    color: var(--clr-primary);
    background: var(--clr-primary-light);
}

/* ── Calendar month grid ────────────────────────────────── */
.cal-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-md);
    margin-bottom: var(--sp-lg);
}
.cal-month-title {
    margin: 0;
    min-width: 220px;
    text-align: center;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--clr-border);
    gap: 1px;
}

.cal-day-header {
    background: var(--clr-surface-alt);
    padding: var(--sp-sm);
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--clr-text-muted);
}

.cal-cell {
    background: var(--clr-surface);
    min-height: 100px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    transition: background 0.15s;
}
.cal-cell:hover {
    background: var(--clr-surface-alt);
}
.cal-cell--other {
    background: var(--clr-bg);
}
.cal-cell--other .cal-date {
    color: var(--clr-text-muted);
    opacity: 0.5;
}
.cal-cell--today {
    background: var(--clr-primary-light);
}

.cal-date {
    font-size: 0.82rem;
    font-weight: 600;
    padding: 2px 6px;
    color: var(--clr-text);
    line-height: 1.4;
}
.cal-date--today {
    background: var(--clr-primary);
    color: #fff;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
}

.cal-events {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 2px;
}

/* Event bar — start of period */
.cal-event {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
    line-height: 1.3;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    overflow: hidden;
}
.cal-event:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.cal-event--open {
    background: var(--clr-period-open);
    color: #fff;
}
.cal-event--taken {
    background: var(--clr-period-taken);
    color: #fff;
}
.cal-event--mine {
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.5);
}
.cal-event--done {
    opacity: 0.55;
}

.cal-event-name {
    display: block;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-event-who {
    display: block;
    font-size: 0.65rem;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Continuation bar */
.cal-event-cont {
    height: 6px;
    border-radius: 3px;
    cursor: pointer;
    transition: opacity 0.15s;
}
.cal-event-cont:hover {
    opacity: 0.7;
}
.cal-event-cont--open {
    background: var(--clr-period-open);
    opacity: 0.4;
}
.cal-event-cont--taken {
    background: var(--clr-period-taken);
    opacity: 0.4;
}

/* ── Calendar modal ────────────────────────────────────── */
.cal-modal {
    position: fixed;
    inset: 0;
    background: rgba(44,36,23,0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-lg);
    animation: fadeIn 0.15s ease;
}
.cal-modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    padding: var(--sp-xl);
    animation: slideDown 0.2s ease;
}
.cal-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--clr-text-muted);
    line-height: 1;
}
.cal-modal-close:hover {
    color: var(--clr-text);
}
.cal-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-sm);
    margin-top: var(--sp-md);
    padding-top: var(--sp-md);
    border-top: 1px solid var(--clr-border);
}

/* ── 404 ────────────────────────────────────────────────── */
.page-404 {
    text-align: center;
    padding: var(--sp-2xl) 0;
}
.page-404 h1 {
    font-size: 5rem;
    color: var(--clr-text-muted);
    margin-bottom: var(--sp-sm);
}

/* ── Stats grid ─────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--sp-md);
}

.stat-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-lg);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-card--ok  { border-color: var(--clr-success); background: var(--clr-success-light); }
.stat-card--warn { border-color: var(--clr-warning); background: var(--clr-warning-light); }

.stat-number {
    font-family: var(--ff-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--clr-text);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--clr-text-muted);
    margin-top: var(--sp-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Filter tabs ───────────────────────────────────────── */
.filter-tabs {
    display: flex;
    gap: var(--sp-xs);
    background: var(--clr-surface-alt);
    border-radius: var(--radius-full);
    padding: 3px;
    width: fit-content;
}

.filter-tab {
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    transition: all 0.2s;
}
.filter-tab:hover { color: var(--clr-text); }
.filter-tab.active {
    background: var(--clr-surface);
    color: var(--clr-text);
    box-shadow: var(--shadow-sm);
}

/* ── Action dropdown ───────────────────────────────────── */
.action-btns {
    display: flex;
    gap: var(--sp-xs);
}

.action-dropdown {
    position: relative;
}

.dropdown-toggle {
    font-size: 1.3rem;
    letter-spacing: 2px;
    min-width: 36px;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 200px;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: var(--sp-xs) 0;
    animation: dropIn 0.15s ease;
}

.action-dropdown.open .dropdown-menu {
    display: block;
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    font-size: 0.88rem;
    font-family: var(--ff-body);
    color: var(--clr-text);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}
.dropdown-item:hover {
    background: var(--clr-surface-alt);
    color: var(--clr-text);
}

.dropdown-item--danger { color: var(--clr-danger); }
.dropdown-item--danger:hover { background: var(--clr-danger-light); }
.dropdown-item--warning { color: #8a6d1b; }
.dropdown-item--warning:hover { background: var(--clr-warning-light); }

/* ── Month grid ────────────────────────────────────────── */
.month-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-xs) var(--sp-md);
}

/* ── Inline form (buttons in tables) ───────────────────── */
.inline-form {
    display: inline;
}

/* ── Contact recipient ─────────────────────────────────── */
.contact-recipient {
    padding: var(--sp-md);
    background: var(--clr-surface-alt);
    border-radius: var(--radius-md);
    font-size: 0.92rem;
}

.contact-recipient-label {
    margin-right: var(--sp-sm);
}

/* ── SMTP test section ─────────────────────────────────── */
.smtp-test-section {
    margin-top: var(--sp-sm);
}

/* ── Polish & Micro-interactions ────────────────────────── */
body {
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(91,127,94,0.04) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(194,149,107,0.05) 0%, transparent 50%);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.3s;
}

.period-card:hover:not(.period-card--unavailable) {
    box-shadow: var(--shadow-sm);
}

.stat-card {
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.month-list {
    font-size: 0.82rem;
    color: var(--clr-text-muted);
    line-height: 1.5;
}

hr {
    border: none;
    border-top: 1px solid var(--clr-border);
    margin: var(--sp-lg) 0;
}

small {
    display: block;
    margin-top: var(--sp-xs);
    font-size: 0.8rem;
    color: var(--clr-text-muted);
}

/* Focus styles for accessibility */
a:focus-visible,
.btn:focus-visible,
.form-control:focus-visible {
    outline: 2px solid var(--clr-primary);
    outline-offset: 2px;
}

/* Loading state for buttons */
.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Fade-in animation for page content */
.main-content {
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Front page (public) ────────────────────────────────── */
.front-page {
    min-height: 60vh;
}
.front-hero {
    height: 300px;
    background-size: cover;
    background-position: center;
    position: relative;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    margin-bottom: calc(var(--sp-xl) * -1);
}
.front-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(44,36,23,0.1), rgba(44,36,23,0.5));
    border-radius: inherit;
}
.front-content {
    position: relative;
    z-index: 1;
    max-width: 640px;
    margin: 0 auto;
    text-align: center;
    padding: var(--sp-2xl);
}
.front-body h2 {
    font-size: 1.8rem;
    margin-bottom: var(--sp-md);
}
.front-actions {
    display: flex;
    gap: var(--sp-md);
    justify-content: center;
    margin-top: var(--sp-xl);
}

/* ── Dashboard ─────────────────────────────────────────── */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-lg);
    align-items: start;
}
.dash-full-width {
    grid-column: 1 / -1;
}
.dash-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dash-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-sm) var(--sp-md);
    border-radius: var(--radius-sm);
    background: var(--clr-surface-alt);
    gap: var(--sp-sm);
}
.dash-item--done {
    opacity: 0.6;
}
.dash-item--open {
    border-left: 3px solid var(--clr-period-open);
}
.dash-item-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dash-item-date {
    font-size: 0.82rem;
    color: var(--clr-text-muted);
}
.dash-item-note {
    font-size: 0.82rem;
    font-style: italic;
    color: var(--clr-text-muted);
}

/* ── Announcements ─────────────────────────────────────── */
.announcement-item {
    padding: var(--sp-md) 0;
    border-bottom: 1px solid var(--clr-border);
}
.announcement-item:last-child {
    border-bottom: none;
}
.announcement-item--pinned {
    background: var(--clr-warning-light);
    margin: 0 calc(var(--sp-xl) * -1);
    padding: var(--sp-md) var(--sp-xl);
    border-radius: var(--radius-sm);
    border-bottom: none;
    margin-bottom: var(--sp-sm);
}
.announcement-item h3 {
    margin-bottom: var(--sp-xs);
    font-size: 1rem;
}
.announcement-body {
    font-size: 0.92rem;
    line-height: 1.5;
    margin-bottom: var(--sp-xs);
}
.announcement-meta {
    font-size: 0.78rem;
}

/* ── Swaps ─────────────────────────────────────────────── */
.swap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--sp-md);
}
.swap-card {
    padding: var(--sp-lg);
}
.swap-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-sm);
}
.swap-card-task {
    font-family: var(--ff-heading);
    font-weight: 600;
    margin-bottom: var(--sp-xs);
}
.swap-card-period {
    font-size: 0.85rem;
}
.swap-card-reason {
    font-style: italic;
    font-size: 0.88rem;
    color: var(--clr-text-muted);
    margin-top: var(--sp-sm);
    margin-bottom: 0;
}

/* ── Period comments ───────────────────────────────────── */
.period-comments {
    margin-top: var(--sp-sm);
    padding-top: var(--sp-sm);
    border-top: 1px dashed rgba(0,0,0,0.08);
}
.period-comment {
    padding: var(--sp-xs) 0;
    font-size: 0.85rem;
}
.period-comment p {
    margin: 2px 0 0 0;
    font-size: 0.85rem;
}
.period-comment-form {
    margin-top: var(--sp-sm);
}

/* ── Swap notice in calendar ───────────────────────────── */
.period-swap-notice {
    font-size: 0.82rem;
    color: var(--clr-accent);
    background: var(--clr-warning-light);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--sp-sm);
}

/* ── Completion styles ─────────────────────────────────── */
.period-card--completed {
    border-color: var(--clr-success);
    position: relative;
}
.period-card--completed::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: var(--clr-success);
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='10' viewBox='0 0 12 10'%3E%3Cpath d='M1 5l3 3 7-7' stroke='white' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}
.assignee-tag--done {
    opacity: 0.7;
    text-decoration: line-through;
}
.period-btn-complete {
    background: var(--clr-success);
    color: #fff;
    flex: 1;
}
.period-btn-complete:hover {
    background: var(--clr-primary-hover);
}
.period-action-row {
    display: flex;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-sm);
    flex-wrap: wrap;
}

/* ── Profile page ──────────────────────────────────────── */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-lg);
    align-items: start;
}

.profile-grid .card:last-child {
    grid-column: 1 / -1;
}

.profile-meta {
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
}

.profile-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-sm) 0;
    border-bottom: 1px solid var(--clr-border);
}

.profile-meta-row:last-child {
    border-bottom: none;
}

.profile-meta-label {
    font-size: 0.88rem;
    color: var(--clr-text-muted);
}

/* ── Utility ────────────────────────────────────────────── */
.mt-sm  { margin-top: var(--sp-sm); }
.mt-md  { margin-top: var(--sp-md); }
.mt-lg  { margin-top: var(--sp-lg); }
.mt-xl  { margin-top: var(--sp-xl); }
.mb-md  { margin-bottom: var(--sp-md); }
.mb-lg  { margin-bottom: var(--sp-lg); }
.flex   { display: flex; }
.gap-sm { gap: var(--sp-sm); }
.gap-md { gap: var(--sp-md); }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .mobile-toggle { display: flex; }

    .main-nav {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--clr-surface);
        flex-direction: column;
        padding: var(--sp-md) var(--sp-lg);
        border-bottom: 1px solid var(--clr-border);
        box-shadow: var(--shadow-md);
    }
    .main-nav.open { display: flex; }

    .nav-user {
        border-left: none;
        padding-left: 0;
        padding-top: var(--sp-sm);
        border-top: 1px solid var(--clr-border);
    }

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

    .auth-card {
        padding: var(--sp-lg);
    }

    h1 { font-size: 1.6rem; }

    .admin-nav {
        flex-wrap: wrap;
    }

    .cal-header {
        flex-wrap: wrap;
    }

    .cal-cell {
        min-height: 70px;
    }

    .cal-event-name {
        font-size: 0.65rem;
    }

    .cal-event-who {
        display: none;
    }

    .cal-modal-content {
        max-height: 90vh;
        padding: var(--sp-lg);
    }

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

    .month-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .filter-tabs {
        width: 100%;
    }

    .filter-tab {
        flex: 1;
        text-align: center;
    }

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

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

    .front-hero {
        height: 200px;
    }

    .front-content {
        padding: var(--sp-lg);
    }

    .period-action-row {
        flex-direction: column;
    }

    .dropdown-menu {
        position: fixed;
        left: var(--sp-md);
        right: var(--sp-md);
        top: auto;
        bottom: var(--sp-md);
        min-width: auto;
    }
}

/* Dropdown fix */
.action-dropdown {
    position: relative;
}
.dropdown-menu {
    z-index: 999;
}
tbody tr:last-child .action-dropdown .dropdown-menu,
tbody tr:nth-last-child(2) .action-dropdown .dropdown-menu {
    top: auto;
    bottom: 100%;
}
.table-wrap {
    overflow: visible !important;
}
