/* =============================================================
   תורנויות — duty-roster system
   Design language: "duty board"
   - Hebrew editorial typography: Frank Ruhl Libre (display)
     over Heebo (UI), tabular numerals in data grids
   - Warm paper surfaces, ink text, one deep-pine accent
   - Flat 1px-bordered panels; shadows reserved for overlays
   ============================================================= */

/* ---------- tokens ---------- */
:root {
    /* surfaces */
    --paper: #f6f4ef;
    --surface: #fffefb;
    --surface-2: #f1eee7;
    --border: #e3ded3;
    --border-strong: #cfc8b9;

    /* ink */
    --ink: #232019;
    --ink-2: #575144;
    --ink-3: #8a8273;

    /* accent: deep pine */
    --pine: #1d5c4f;
    --pine-deep: #154439;
    --pine-tint: #e3eeea;
    --pine-tint-2: #d2e4dd;

    /* semantic */
    --sand: #f8efdc;
    --sand-edge: #e8d9b8;
    --sand-ink: #7c5e1c;
    --clay: #b13e2e;
    --clay-tint: #f7e7e2;
    --clay-edge: #e5c0b6;
    --sky-ink: #2d5a82;
    --sky-tint: #e5eef5;
    --sky-edge: #c3d6e5;

    /* states on the preferences calendar / report */
    --want-bg: #e0eee6;
    --want-edge: #4d8b71;
    --dw-bg: #f8efdc;
    --dw-edge: #c9a04a;
    --cant-bg: #f7e3de;
    --cant-edge: #c4664f;

    /* weekend marker on the preferences calendar — cool & neutral so it
       never reads as the (warm/amber) "לא רוצה" state, which shares --sand */
    --cal-weekend-bg: #e9edf1;
    --cal-weekend-edge: #cdd6dd;

    --radius: 10px;
    --radius-lg: 14px;
    --radius-sm: 6px;

    --shadow-pop: 0 12px 32px -8px rgba(35, 32, 25, 0.22), 0 2px 8px rgba(35, 32, 25, 0.08);

    --font-ui: 'Heebo', 'Segoe UI', Arial, sans-serif;
    --font-display: 'Frank Ruhl Libre', 'Heebo', serif;

    --focus-ring: 0 0 0 3px rgba(29, 92, 79, 0.25);
}

/* ---------- base ---------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    direction: rtl;
    text-align: right;
}

body {
    font-family: var(--font-ui);
    background: var(--paper);
    color: var(--ink);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--ink);
    line-height: 1.25;
    letter-spacing: -0.01em;
}

a {
    color: var(--pine);
}

::selection {
    background: var(--pine-tint-2);
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

/* ---------- topbar ---------- */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 clamp(1rem, 4vw, 2.5rem);
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    position: sticky;
    top: 0;
    z-index: 1000;
    min-height: 60px;
}

.nav-brand {
    display: flex;
    align-items: center;
}

.nav-brand a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--pine);
    color: #f3efe2;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.25rem;
    display: grid;
    place-items: center;
    line-height: 1;
    padding-bottom: 2px;
}

.logo-text {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.01em;
}

.logo-sub {
    font-size: 0.7rem;
    color: var(--ink-3);
    display: block;
    margin-top: -3px;
    font-family: var(--font-ui);
    font-weight: 400;
    letter-spacing: 0.08em;
}

.nav-links {
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
}

.nav-link {
    color: var(--ink-2);
    text-decoration: none;
    padding: 0 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 500;
    font-size: 0.95rem;
    border-bottom: 2px solid transparent;
    border-top: 2px solid transparent;
    transition: color 0.15s;
}

.nav-link .icon {
    opacity: 0.75;
}

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

.nav-link.active {
    color: var(--pine);
    border-bottom-color: var(--pine);
}

.nav-link.active .icon {
    opacity: 1;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-right: 0.9rem;
    padding-right: 1.1rem;
    border-right: 1px solid var(--border);
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.85rem;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.4;
}

.user-name:hover {
    background: var(--surface-3, #ece6d6);
    border-color: var(--brand, #1d5c4f);
}

.nav-link.logout {
    color: var(--ink-3);
    font-size: 0.875rem;
    padding: 0 0.4rem;
}

.nav-link.logout:hover {
    color: var(--clay);
}

/* ---------- layout ---------- */
.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: clamp(1.25rem, 3vw, 2.25rem);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: clamp(1.5rem, 3vw, 2rem);
}

.page-header .page-kicker {
    display: block;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--pine);
    margin-bottom: 0.3rem;
}

.header-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.page-footer {
    margin-top: 1.5rem;
}

/* ---------- icons ---------- */
.icon {
    width: 1.1em;
    height: 1.1em;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
    vertical-align: -0.18em;
}

/* ---------- panels & cards ---------- */
.form-card,
.table-container,
.schedule-page,
.calendar-container,
.preferences-instructions,
.notes-group,
.stat-card,
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

/* ---------- flash messages ---------- */
.flash-messages {
    margin-bottom: 1.25rem;
}

.flash-message {
    padding: 0.8rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-weight: 500;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    border-right-width: 4px;
    background: var(--surface);
    animation: rise 0.25s ease;
}

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

.flash-success { border-right-color: var(--pine); color: var(--pine-deep); }
.flash-error   { border-right-color: var(--clay); color: #8c3023; }
.flash-info    { border-right-color: var(--sky-ink); color: var(--sky-ink); }
.flash-warning { border-right-color: var(--dw-edge); color: var(--sand-ink); }

.flash-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: var(--ink-3);
}

.flash-close:hover { color: var(--ink); }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.15rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.btn:focus-visible { box-shadow: var(--focus-ring); }

.btn-primary {
    background: var(--pine);
    color: #f6f3e9;
}

.btn-primary:hover { background: var(--pine-deep); }

.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    border-color: var(--ink-3);
    background: var(--surface-2);
}

.btn-danger {
    background: var(--surface);
    color: var(--clay);
    border-color: var(--clay-edge);
}

.btn-danger:hover {
    background: var(--clay-tint);
    border-color: var(--clay);
}

.btn-info {
    background: var(--sky-tint);
    color: var(--sky-ink);
    border-color: var(--sky-edge);
}

.btn-info:hover { border-color: var(--sky-ink); }

.btn-small { padding: 0.3rem 0.7rem; font-size: 0.85rem; border-radius: var(--radius-sm); }
.btn-large { padding: 0.8rem 1.8rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.18rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--ink-2);
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-active    { background: var(--sky-tint);  border-color: var(--sky-edge);  color: var(--sky-ink); }
.badge-published { background: var(--want-bg);   border-color: var(--want-edge); color: var(--pine-deep); }
.badge-draft     { background: var(--dw-bg);     border-color: var(--sand-edge); color: var(--sand-ink); }
.badge-not-submitted { background: var(--clay-tint); border-color: var(--clay-edge); color: var(--clay); }

/* ---------- forms ---------- */
.form-card {
    padding: clamp(1.25rem, 3vw, 2rem);
    max-width: 860px;
}

.form-section {
    margin-bottom: 1.75rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px dashed var(--border-strong);
}

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

.form-section h3 {
    margin-bottom: 1rem;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-section h3::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: var(--pine);
    transform: rotate(45deg);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink-2);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 1rem;
    background: var(--surface);
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--pine);
    box-shadow: var(--focus-ring);
}

.form-group select.multi-select { height: auto; min-height: 120px; }
.form-group select.multi-select option { padding: 0.4rem 0.6rem; border-radius: 4px; }
.form-group select.multi-select option:checked {
    background: var(--pine) linear-gradient(0deg, var(--pine), var(--pine));
    color: #fff;
}

.form-group small {
    display: block;
    margin-top: 0.3rem;
    color: var(--ink-3);
    font-size: 0.82rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--ink);
}

.checkbox-group input[type="checkbox"] {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--pine);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.75rem;
}

/* ---------- data tables ---------- */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
    padding: 0.7rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--surface-2);
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    color: var(--ink-2);
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: #faf8f2; }

.data-table .actions { display: flex; gap: 0.4rem; }

.empty-message {
    text-align: center;
    color: var(--ink-3);
    padding: 2.5rem 1rem !important;
}

.active-row { background: var(--pine-tint) !important; }

/* report status cells */
.report-table td.full     { background: var(--want-bg); color: var(--pine-deep); font-weight: 600; }
.report-table td.partial  { background: var(--dw-bg); color: var(--sand-ink); }
.report-table td.exceeded { background: var(--cant-bg); color: var(--clay); font-weight: 700; }

/* ---------- home ---------- */
.home-hero { padding: 1rem 0 2rem; }

.hero-content {
    margin-bottom: 2rem;
}

.hero-content h1 {
    font-size: clamp(1.7rem, 4vw, 2.4rem);
}

.hero-subtitle {
    color: var(--ink-2);
    font-size: 1.05rem;
    margin-top: 0.35rem;
}

.hero-month {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    background: var(--pine-tint);
    color: var(--pine-deep);
    border: 1px solid var(--pine-tint-2);
    border-radius: 999px;
    padding: 0.15rem 0.85rem;
    font-weight: 700;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.action-card,
.admin-action-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.5rem;
    text-decoration: none;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: relative;
    transition: border-color 0.15s, background-color 0.15s;
    cursor: pointer;
}

.action-card:hover,
.admin-action-card:hover {
    border-color: var(--pine);
    background: #fffef7;
}

.action-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: var(--pine-tint);
    color: var(--pine);
    margin-bottom: 0.6rem;
}

.action-icon .icon { width: 22px; height: 22px; }

.action-card h3,
.admin-action-card h3 {
    font-size: 1.1rem;
    font-family: var(--font-ui);
    font-weight: 700;
}

.action-card p,
.admin-action-card p {
    color: var(--ink-3);
    font-size: 0.88rem;
    line-height: 1.45;
}

.card-arrow {
    position: absolute;
    top: 1.4rem;
    left: 1.3rem;
    color: var(--border-strong);
    transition: color 0.15s, transform 0.15s;
}

.action-card:hover .card-arrow,
.admin-action-card:hover .card-arrow {
    color: var(--pine);
    transform: translateX(-3px);
}

/* ---------- admin dashboard ---------- */
.admin-dashboard h1 { margin-bottom: 1.5rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.1rem 1.4rem;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.1rem;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2.1rem;
    font-weight: 800;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.stat-label {
    color: var(--ink-3);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.06em;
}

.admin-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* the generate tile is the one loud element on the dashboard */
.generate-card {
    background: var(--pine);
    border-color: var(--pine-deep);
    color: #f3efe2;
}

.generate-card h3 { color: #fff; }
.generate-card p { color: rgba(243, 239, 226, 0.75); }

.generate-card .action-icon {
    background: rgba(255, 255, 255, 0.14);
    color: #f3efe2;
}

.generate-card:hover {
    background: var(--pine-deep);
    border-color: var(--pine-deep);
}

.generate-card.working {
    cursor: wait;
    animation: breathe 2s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

.generate-card.working .action-icon .icon {
    animation: spin 1.6s linear infinite;
}

/* Escape hatch shown only while a run is in progress, so a generation that
   was closed mid-creation can be cleared without waiting for auto-recovery. */
.generate-reset {
    margin-top: 0.9rem;
    padding: 0.4rem 0.9rem;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: #f3efe2;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s;
}

.generate-reset:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.6);
}

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

/* ---------- login ---------- */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background:
        radial-gradient(1100px 500px at 85% -10%, var(--pine-tint) 0%, transparent 60%),
        var(--paper);
    padding: 1rem;
}

.login-container { width: 100%; max-width: 410px; }

.login-card {
    padding: 2.5rem 2.25rem 2rem;
    box-shadow: var(--shadow-pop);
}

.login-header { text-align: center; margin-bottom: 1.75rem; }

.login-header .brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    font-size: 2rem;
    margin: 0 auto 1rem;
}

.login-header h1 { font-size: 1.7rem; margin-bottom: 0.25rem; }
.login-header p { color: var(--ink-3); font-size: 0.92rem; }

.login-form { margin-bottom: 1.25rem; }

.login-form input {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    font-variant-numeric: tabular-nums;
}

.login-footer {
    text-align: center;
    color: var(--ink-3);
    font-size: 0.8rem;
    border-top: 1px dashed var(--border-strong);
    padding-top: 1rem;
}

/* ---------- schedule board ---------- */
.schedule-page {
    padding: clamp(1.25rem, 3vw, 2rem);
}

.schedule-info {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.schedule-info span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--ink-2);
    border-radius: 999px;
    padding: 0.25rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.schedule-table-container {
    overflow: auto;
    max-height: 75vh;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.schedule-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 760px;
    font-variant-numeric: tabular-nums;
}

.schedule-table th,
.schedule-table td {
    padding: 0.5rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
    font-size: 0.92rem;
}

.schedule-table th:last-child,
.schedule-table td:last-child { border-left: none; }

.schedule-table thead th {
    background: var(--ink);
    color: var(--paper);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.84rem;
    letter-spacing: 0.04em;
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: none;
}

/* day + weekday columns pinned to the right (RTL) */
.schedule-table .day-col,
.schedule-table .weekday-col {
    position: sticky;
    background: var(--surface-2);
    z-index: 10;
    font-weight: 600;
    white-space: nowrap;
}

.schedule-table .day-col { right: 0; min-width: 3rem; }
.schedule-table .weekday-col { right: 3rem; color: var(--ink-2); font-weight: 500; }

.schedule-table thead .day-col,
.schedule-table thead .weekday-col {
    background: var(--ink);
    color: var(--paper);
    z-index: 30;
}

.schedule-table tbody tr:last-child td { border-bottom: none; }

.schedule-table .assignment-cell.filled {
    background: var(--surface);
    font-weight: 500;
}

/* empty slot: quiet diagonal hatch, not screaming red */
.schedule-table .assignment-cell.empty {
    background: repeating-linear-gradient(
        -45deg,
        var(--surface),
        var(--surface) 5px,
        #f0ece2 5px,
        #f0ece2 10px
    );
    color: var(--border-strong);
}

/* weekend rows */
.schedule-table tr.is-weekend .day-col,
.schedule-table tr.is-weekend .weekday-col {
    background: var(--sand);
    color: var(--sand-ink);
}

.schedule-table tr.is-weekend .assignment-cell.filled {
    background: #fdf8ec;
}

.schedule-table tr.is-weekend .assignment-cell.empty {
    background: repeating-linear-gradient(
        -45deg,
        #fdf8ec,
        #fdf8ec 5px,
        #f3e9d2 5px,
        #f3e9d2 10px
    );
}

.schedule-table tr.is-thursday .weekday-col { color: var(--ink-2); }

/* editable grid */
.schedule-table .editable-cell { cursor: pointer; }

.schedule-table .editable-cell:hover {
    box-shadow: inset 0 0 0 2px var(--pine);
    background: var(--pine-tint);
    color: var(--pine-deep);
}

/* ---------- modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(35, 32, 25, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 84vh;
    overflow-y: auto;
    box-shadow: var(--shadow-pop);
    animation: rise 0.18s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
}

.modal-header h2 { font-size: 1.2rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--ink-3);
}

.modal-close:hover { color: var(--ink); }

.modal-body { padding: 1.4rem; }

.current-assignment {
    padding: 0.8rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.quick-select { margin-bottom: 1.25rem; }

.quick-select label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink-2);
}

.quick-select select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font-ui);
    margin-top: 0.4rem;
    background: var(--surface);
}

.suggestions-section h3 {
    font-size: 0.95rem;
    font-family: var(--font-ui);
    font-weight: 700;
    color: var(--ink-2);
    margin-bottom: 0.75rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-strong);
}

.suggestion-card {
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.suggestion-card:hover {
    border-color: var(--pine);
    background: var(--pine-tint);
}

.suggestion-card .title { font-weight: 600; }

.suggestion-card .details {
    font-size: 0.85rem;
    color: var(--ink-3);
    margin-top: 0.15rem;
}

.suggestion-card .changes {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.7rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    color: var(--ink-2);
}

.loading,
.no-suggestions {
    text-align: center;
    color: var(--ink-3);
    padding: 1rem;
    font-size: 0.9rem;
}

/* ---------- preferences calendar ---------- */
.preferences-page { max-width: 760px; margin: 0 auto; }

.preferences-instructions {
    padding: 1.1rem 1.4rem;
    margin-bottom: 1.25rem;
}

.preferences-instructions > p {
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.legend {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink-2);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.2rem 0.75rem 0.2rem 0.9rem;
}

.legend-item .box {
    width: 13px;
    height: 13px;
    border-radius: 4px;
    border: 1.5px solid var(--border-strong);
}

.legend-item .box.want        { background: var(--want-bg); border-color: var(--want-edge); }
.legend-item .box.doesnt-want { background: var(--dw-bg);   border-color: var(--dw-edge); }
.legend-item .box.cant        { background: var(--cant-bg); border-color: var(--cant-edge); }
.legend-item .box.full        { background: var(--want-bg); border-color: var(--want-edge); }
.legend-item .box.partial     { background: var(--dw-bg);   border-color: var(--dw-edge); }
.legend-item .box.exceeded    { background: var(--cant-bg); border-color: var(--cant-edge); }

.calendar-container {
    padding: 1.4rem;
    margin-bottom: 1.25rem;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.45rem;
    margin-bottom: 0.65rem;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    color: var(--ink-3);
    text-align: center;
}

.calendar-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.45rem;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: 1.5px solid var(--border);
    background: var(--surface);
    font-size: 1.05rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.12s, background-color 0.12s;
}

.calendar-day:hover { border-color: var(--pine); }

.calendar-day.empty {
    border: none;
    background: transparent;
    cursor: default;
}

.calendar-day.weekend {
    background: var(--cal-weekend-bg);
    border-color: var(--cal-weekend-edge);
}

.calendar-day.want {
    background: var(--want-bg);
    border-color: var(--want-edge);
    color: var(--pine-deep);
}

.calendar-day.doesnt-want {
    background: var(--dw-bg);
    border-color: var(--dw-edge);
    color: var(--sand-ink);
}

.calendar-day.cant {
    background: var(--cant-bg);
    border-color: var(--cant-edge);
    color: var(--clay);
    text-decoration: line-through;
}

.notes-group {
    padding: 1.25rem 1.4rem;
    margin-bottom: 1.25rem;
}

/* ---------- empty state ---------- */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.25rem;
    border-radius: 20px;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    display: grid;
    place-items: center;
    color: var(--ink-3);
    font-size: 2rem;
}

.empty-icon .icon { width: 32px; height: 32px; }

.empty-state h2 { margin-bottom: 0.5rem; font-size: 1.35rem; }
.empty-state p { color: var(--ink-3); margin-bottom: 1.5rem; }

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

/* ---------- bulk edit ---------- */
.bulk-edit-note {
    background: var(--sky-tint);
    border: 1px solid var(--sky-edge);
    padding: 0.8rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    color: var(--sky-ink);
    font-size: 0.92rem;
}

.bulk-edit-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.bulk-edit-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1200px;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.bulk-edit-table th,
.bulk-edit-table td {
    padding: 0.45rem 0.6rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
    white-space: nowrap;
}

.bulk-edit-table th {
    background: var(--ink);
    color: var(--paper);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.bulk-edit-table th:first-child {
    position: sticky;
    right: 0;
    background: var(--ink);
    z-index: 15;
}

.bulk-edit-table td:first-child {
    position: sticky;
    right: 0;
    background: var(--surface-2);
    z-index: 5;
    font-weight: 600;
    text-align: right;
}

.bulk-edit-table input[type="number"],
.bulk-edit-table input[type="text"] {
    width: 60px;
    padding: 0.3rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.875rem;
    font-family: var(--font-ui);
    background: var(--surface);
}

.bulk-edit-table input[type="text"] { width: 100px; }

.bulk-edit-table input:focus {
    outline: none;
    border-color: var(--pine);
    box-shadow: var(--focus-ring);
}

.bulk-edit-table tbody tr:nth-child(even) td { background-color: #fbf9f4; }
.bulk-edit-table tbody tr:nth-child(even) td:first-child { background-color: var(--surface-2); }
.bulk-edit-table tbody tr:hover td { background-color: var(--pine-tint); }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
    .container { padding: 1.25rem; }
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        padding: 0.5rem 1rem;
        gap: 0.25rem;
    }

    .nav-brand a { padding: 0.4rem 0; }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    .nav-link {
        padding: 0.55rem 0.7rem;
        font-size: 0.9rem;
        border-bottom-width: 2px;
    }

    .nav-user {
        margin-right: 0.4rem;
        padding-right: 0.6rem;
    }

    .page-header { flex-direction: column; align-items: flex-start; }
    .header-actions { width: 100%; }

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

    /* Fit the whole grid to the screen width instead of scrolling sideways. */
    .schedule-table-container { overflow-x: hidden; }
    .schedule-table { min-width: 0; width: 100%; table-layout: fixed; font-size: 0.66rem; }
    .schedule-table th, .schedule-table td {
        /* font-size must be set on th/td: a base `.schedule-table td` rule
           (higher specificity than `.schedule-table`) otherwise wins */
        font-size: 0.66rem;
        padding: 0.3rem 0.14rem;
        /* show the FULL name — shrink the text and let it wrap rather than
           clipping it with an ellipsis */
        white-space: normal; overflow-wrap: break-word; word-break: break-word;
        line-height: 1.15; vertical-align: middle;
    }
    .schedule-table .weekday-col { display: none; }
    .schedule-table thead .weekday-col { display: none; }
    .schedule-table .day-col { width: 1.7rem; min-width: 1.7rem; }
    /* header titles shrink with the body (own rule beats the base 0.84rem);
       drop the widening letter-spacing so they don't wrap needlessly */
    .schedule-table thead th { font-size: 0.66rem; letter-spacing: 0; padding: 0.3rem 0.14rem; }

    .stat-value { font-size: 1.7rem; }

    .form-group input,
    .form-group select,
    .form-group textarea { font-size: 16px; /* prevents iOS zoom */ }
}

@media (max-width: 480px) {
    .container { padding: 0.85rem; }

    .login-card { padding: 1.75rem 1.25rem 1.25rem; }

    .calendar-body, .calendar-header { gap: 0.3rem; }
    .calendar-day { font-size: 0.9rem; border-radius: var(--radius-sm); }

    .legend { gap: 0.4rem; }

    .form-actions { flex-direction: column; }

    /* very narrow phones: shrink the grid text further so full names fit
       without sideways scrolling (still wrap, never truncate) */
    .schedule-table { font-size: 0.58rem; }
    .schedule-table th, .schedule-table td { font-size: 0.58rem; padding: 0.25rem 0.1rem; letter-spacing: -0.2px; }
    .schedule-table thead th { font-size: 0.58rem; letter-spacing: 0; padding: 0.25rem 0.1rem; }
    .schedule-table .day-col { width: 1.4rem; min-width: 1.4rem; }
}

@media (hover: none) and (pointer: coarse) {
    .calendar-day { min-height: 44px; }
    .btn { min-height: 42px; }
}

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

/* ---------- print ---------- */
@media print {
    .navbar, .form-actions, .header-actions, .flash-messages, .bulk-edit-note { display: none !important; }
    body { background: white; }
    .container { max-width: none; padding: 0; }
    .schedule-page, .table-container { border: none; }
    .schedule-table-container { max-height: none; overflow: visible; border: 1px solid #999; }
    .schedule-table { min-width: auto; }
    .schedule-table thead th { background: #eee !important; color: #000 !important; }
}
