/* ─────────────────────────────────────────────────────────────────────────
   Maktab dashboards — shared styles
   Default palette: white + gold, mirroring the BJ app (bj/assets/style.css).
   Kept in sync with theme_defaults() in includes/theme.php — the per-user
   theme editor overrides these same tokens at :root.
   The green/gold original is still available as the "เขียว–ทอง" preset.
   ───────────────────────────────────────────────────────────────────────── */

:root {
    --gold-bright:  #a07e18;    /* headings/highlights — BJ --gold-deep       */
    --gold-mid:     #c9a227;    /* BJ --gold                                  */
    --gold-dark:    #a07e18;    /* BJ --gold-deep                             */
    --green-dark:   #fbfaf7;    /* page background — BJ --bg                  */
    --green-mid:    #fbfaf7;
    --green-card:   #fbfaf7;
    --green-deep:   #8a8a88;
    --green-cta:    #c9a227;    /* action buttons are gold in the BJ theme    */
    --green-accent: #977a1d;
    --text-primary: #2b2620;    /* BJ --ink                                   */
    --text-muted:   #8a8174;    /* BJ --muted                                 */
    --text-dim:     #9a8f80;
    --text-gold:    #d9be68;  /* derived; theme-light remaps it to the dark gold */
    --error-bg:     rgba(182, 68, 74, 0.15);
    --error-fg:     #b6444a;    /* BJ .btn-danger                             */
    --ok-bg:        rgba(201, 162, 39, 0.10);
    --ok-fg:        #2f9e6f;    /* BJ .ok-badge                               */

    /* RGB channels for the translucent surfaces/accents below. Themed per-user
       (see includes/theme.php) so cards & tints follow the chosen palette
       instead of staying green. */
    --bg-rgb:       251,250,247;  /* --green-dark          */
    --bg-rgb-soft:  251,250,247;  /* --green-mid           */
    --bg-rgb-deep:  176,175,173;  /* --green-deep          */
    --accent-rgb:   201,162,39;   /* --gold-mid            */
    --cta-rgb:      201,162,39;   /* --green-cta           */
    --text-rgb:     43,38,32;     /* --text-primary        */
    --error-rgb:    182,68,74;    /* --error-fg            */

    /* Per-element pins the BJ palette sets explicitly (light backgrounds can't
       derive these by shading). Mirrors theme_defaults()'s optional colors. */
    --card-rgb:      255,255,255; /* BJ --white            */
    --card-rgb-soft: 245,245,245;
    --card-rgb-deep: 230,230,230;
    --border-rgb:    236,231,218; /* BJ --line             */
    --cta-text:      #ffffff;
    --link:          #a07e18;

    --topbar-h:     58px;
    --sidebar-w:    220px;
    --bottomnav-h:  64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
.dash-body, .qp-body {
    font-family: 'Niramit', sans-serif;
    background:
        radial-gradient(ellipse 800px 500px at 80% 5%, rgba(var(--accent-rgb),0.05) 0%, transparent 70%),
        radial-gradient(ellipse 600px 700px at 5% 95%, rgba(var(--accent-rgb),0.04) 0%, transparent 70%),
        linear-gradient(160deg, var(--green-dark) 0%, var(--green-mid) 40%, var(--green-deep) 100%);
    color: var(--text-primary);
    min-height: 100vh;
}
a { color: var(--link, var(--gold-mid)); text-decoration: none; }
a:hover { color: var(--gold-bright); }

/* ── Login (reuses qp-* primitives) ────────────────────────────────────── */
.qp-wrap          { max-width: 620px; margin: 0 auto; padding: 32px 16px; }
.qp-wrap--narrow  { max-width: 460px; }
.qp-header        { text-align: center; margin-bottom: 22px; }
.text-label       { display:inline-block; font-size:12px; color: var(--gold-mid); letter-spacing:2px; text-transform:uppercase; font-weight:600; }
.gold-divider     { display:flex; align-items:center; gap:10px; justify-content:center; margin: 10px 0; }
.gold-divider .line { height:1px; width:60px; background: linear-gradient(90deg, transparent, var(--gold-mid), transparent); }
.gold-divider .star { color: var(--gold-mid); font-size:12px; }
.qp-title {
    background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold-mid) 50%, var(--gold-dark) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    font-weight: 800; font-size: 1.8rem; margin: 4px 0 6px; line-height: 1.25;
}
.qp-subtitle      { font-size:.95rem; color: var(--text-muted); margin: 6px auto 0; max-width:460px; line-height:1.5; }
.qp-card {
    background: linear-gradient(160deg,
        rgba(var(--card-rgb, var(--bg-rgb)),0.85) 0%,
        rgba(var(--card-rgb-soft, var(--bg-rgb-soft)),0.9) 40%,
        rgba(var(--card-rgb-deep, var(--bg-rgb-deep)),0.95) 100%);
    border: 1px solid rgba(var(--border-rgb, var(--accent-rgb)),0.28);
    border-radius: 18px; padding: 24px 22px;
    box-shadow: 0 20px 50px -20px rgba(0,0,0,.55);
    margin-bottom: 18px;
}
.qp-flash         { margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; border:1px solid transparent; font-size:.9rem; }
.qp-flash--ok     { background: var(--ok-bg);    color: var(--ok-fg);    border-color: rgba(var(--accent-rgb),0.35); }
.qp-flash--err    { background: var(--error-bg); color: var(--error-fg); border-color: rgba(252,165,165,0.25); }
.qp-field         { margin-bottom: 14px; }
.qp-label         { display:block; font-size:.85rem; font-weight:600; color: var(--gold-mid); margin-bottom:6px; }
.qp-label .req    { color: var(--error-fg); margin-left: 4px; }
.qp-input, .qp-select {
    width: 100%; padding: 11px 14px; border-radius: 10px;
    background: rgba(0,0,0,0.25); color: var(--text-primary);
    border: 1px solid rgba(var(--accent-rgb),0.25);
    font-size: .95rem; font-family: inherit;
    transition: border-color .2s, box-shadow .2s;
}
.qp-input:focus, .qp-select:focus { outline:none; border-color: var(--gold-mid); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.12); }
.qp-select option { background: var(--green-mid); color: var(--text-primary); }
.qp-cta {
    display:inline-flex; align-items:center; justify-content:center; gap:8px; width:100%;
    font-size:1rem; font-weight:700; letter-spacing:.04em;
    padding: 13px 22px; border-radius: 40px;
    border: 1px solid var(--gold-mid);
    background: linear-gradient(90deg, var(--green-accent), var(--green-cta), var(--green-accent));
    color: var(--cta-text, var(--gold-bright)); cursor: pointer;
    box-shadow: 0 0 20px rgba(var(--accent-rgb),0.18);
    transition: box-shadow .2s, transform .15s;
    margin-top: 4px; font-family: inherit;
}
.qp-cta:hover { box-shadow: 0 0 32px rgba(var(--accent-rgb),0.32); transform: translateY(-1px); }

/* ── Dashboard chrome ──────────────────────────────────────────────────── */
.dash-topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: 12px;
    height: var(--topbar-h); padding: 0 16px;
    background: rgba(var(--bg-rgb-deep), 0.92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid rgba(var(--accent-rgb),0.25);
}
.dash-logo {
    display: flex; align-items: center; gap: 8px; padding: 6px 10px;
    border-radius: 10px; color: var(--gold-bright); font-weight: 700;
    flex: 0 0 auto;          /* never let the brand get crushed on phones */
}
.dash-logo:hover { background: rgba(var(--accent-rgb),0.08); color: var(--gold-bright); }
.dash-logo-mark svg { width: 22px; height: 22px; }
.dash-logo-text {
    background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold-mid) 50%, var(--gold-dark) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    letter-spacing: .02em;
    /* keep brand on one line — overrides the global mobile rule
       `a { overflow-wrap: anywhere }` in app-mobile.css that was breaking it */
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-break: keep-all !important;
}
.dash-topbar-spacer { flex: 1; }

.dash-imp-banner {
    font-size: .82rem; color: var(--gold-bright);
    background: rgba(var(--accent-rgb),0.12); border: 1px solid rgba(var(--accent-rgb),0.35);
    padding: 5px 10px; border-radius: 999px;
}
.dash-imp-banner strong { color: var(--gold-bright); }
.dash-imp-stop { margin-left: 8px; color: var(--error-fg); }

.dash-imp-form { min-width: 0; }   /* allow the wide select to shrink, not the brand */
.dash-imp-form .dash-select,
.dash-imp-filters .dash-select {
    background: rgba(0,0,0,0.30); color: var(--text-primary);
    border: 1px solid rgba(var(--accent-rgb),0.25); border-radius: 8px;
    padding: 6px 10px; font-size: .85rem; font-family: inherit;
    max-width: 240px; min-width: 0;
}
.dash-imp-form .dash-select option,
.dash-imp-filters .dash-select option { background: var(--green-mid); }

.dash-user-chip {
    display: flex; flex-direction: column; align-items: flex-end;
    line-height: 1.15; font-size: .82rem;
}
.dash-user-name { color: var(--text-primary); font-weight: 600; }
.dash-user-role { color: var(--text-dim); font-size: .72rem; }

.dash-iconbtn {
    width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px; color: var(--text-muted);
    border: 1px solid rgba(var(--accent-rgb),0.20);
}
.dash-iconbtn:hover { background: rgba(var(--accent-rgb),0.10); color: var(--gold-bright); }
.dash-iconbtn svg { width: 18px; height: 18px; }

/* ── Sidebar (desktop) ─────────────────────────────────────────────────── */
.dash-sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0;
    width: var(--sidebar-w);
    padding: 18px 12px; display: none; flex-direction: column; gap: 6px;
    background: rgba(var(--bg-rgb-deep), 0.6);
    border-right: 1px solid rgba(var(--accent-rgb),0.15);
    overflow-y: auto;
}
.dash-side-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    color: var(--text-muted); font-size: .92rem;
    border: 1px solid transparent;
}
.dash-side-item:hover { background: rgba(var(--accent-rgb),0.07); color: var(--text-primary); }
.dash-side-item.is-active {
    background: linear-gradient(90deg, rgba(var(--accent-rgb),0.18), rgba(var(--accent-rgb),0.04));
    border-color: rgba(var(--accent-rgb),0.35); color: var(--gold-bright);
}
.dash-side-icon svg { width: 18px; height: 18px; }
.dash-side-label { white-space: nowrap; }

/* ── Main area ─────────────────────────────────────────────────────────── */
.dash-main {
    padding: 20px 18px calc(var(--bottomnav-h) + 28px);
    max-width: 1280px; margin: 0 auto;
}

/* ── Bottom nav (mobile) ───────────────────────────────────────────────── */
.dash-bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: flex; height: var(--bottomnav-h);
    background: rgba(5, 27, 18, 0.95);
    backdrop-filter: blur(6px);
    border-top: 1px solid rgba(var(--accent-rgb),0.30);
}
.dash-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 6px 4px; color: var(--text-dim); font-size: .68rem;
    transition: color .15s;
}
.dash-nav-item:hover { color: var(--text-muted); }
.dash-nav-item.is-active { color: var(--gold-bright); }
.dash-nav-item.is-active .dash-nav-icon { filter: drop-shadow(0 0 6px rgba(var(--accent-rgb),0.4)); }
.dash-nav-icon svg { width: 22px; height: 22px; }
.dash-nav-label { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* ── Responsive: desktop uses sidebar, hides bottom nav ────────────────── */
@media (min-width: 900px) {
    .dash-sidebar { display: flex; }
    .dash-main { margin-left: var(--sidebar-w); padding-bottom: 28px; max-width: none; padding-right: 28px; padding-left: 28px;}
    .dash-bottomnav { display: none; }
}
@media (max-width: 540px) {
    .dash-user-name { display: none; }
    .dash-user-role { display: none; }
    .dash-imp-banner { display: none; }
    .dash-nav-label { font-size: .65rem; }
}

/* ── Generic dashboard primitives ──────────────────────────────────────── */
.dash-card {
    /* Surface follows --card-rgb when the theme sets an explicit card color,
       else falls back to the bg-tinted gradient (unchanged default look). */
    background: linear-gradient(160deg,
        rgba(var(--card-rgb, var(--bg-rgb)),0.85) 0%,
        rgba(var(--card-rgb-soft, var(--bg-rgb-soft)),0.9) 40%,
        rgba(var(--card-rgb-deep, var(--bg-rgb-deep)),0.95) 100%);
    border: 1px solid rgba(var(--border-rgb, var(--accent-rgb)),0.20);
    border-radius: 16px; padding: 18px 20px; margin-bottom: 16px;
    box-shadow: 0 12px 32px -16px rgba(0,0,0,.55);
}
.dash-card h2 {
    margin: 0 0 12px; font-size: 1.05rem; color: var(--gold-bright);
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.dash-card h2 small { color: var(--text-dim); font-size: .8rem; font-weight: 400; }

.dash-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

/* ── Tabs (segmented) ──────────────────────────────────────────────────── */
.dash-tabs {
    display: inline-flex; gap: 4px; margin: 4px 0 16px; padding: 4px;
    background: rgba(var(--bg-rgb-deep), 0.4);
    border: 1px solid rgba(var(--accent-rgb), 0.18); border-radius: 12px;
}
.dash-tab {
    font-family: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
    padding: 7px 18px; border-radius: 9px; border: 1px solid transparent;
    background: transparent; color: var(--text-muted);
    transition: background .15s, color .15s, border-color .15s;
}
.dash-tab small { font-weight: 600; opacity: .75; }
.dash-tab:hover { color: var(--gold-bright); }
.dash-tab.is-active {
    background: linear-gradient(180deg, var(--green-accent), var(--green-cta));
    color: var(--gold-bright); border-color: var(--gold-mid); font-weight: 700;
}
.dash-tabpane[hidden] { display: none; }

/* ── People admin (Nazim/HODT add-edit) + Markaz change-log filter ───────── */
.pa-form .pa-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 16px;
}
.pa-form label, .pa-filter label {
    display: flex; flex-direction: column; gap: 5px;
    font-size: .82rem; color: var(--text-muted); font-weight: 600;
}
/* Reserve two lines for every caption so helper text (e.g. "(ใช้เข้าสู่ระบบ)")
   never pushes one field's input out of line with the rest of the row. */
.pa-form .pa-cap {
    display: block; min-height: 2.6em; line-height: 1.3;
}
.pa-form .pa-cap small { font-weight: 400; }
.pa-form .pa-cap--nowrap { white-space: nowrap; }
.pa-form .qp-input, .pa-filter .qp-input { width: 100%; }
.pa-filter {
    display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
    margin-bottom: 16px; padding-bottom: 16px;
    border-bottom: 1px solid rgba(var(--accent-rgb), 0.14);
}
.pa-filter label { min-width: 150px; }

.dash-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.dash-table th, .dash-table td {
    text-align: left; padding: 8px 10px; border-bottom: 1px solid rgba(var(--border-rgb, var(--accent-rgb)),0.10);
}
.dash-table th { color: var(--gold-mid); font-weight: 600; user-select: none; font-size: .82rem; letter-spacing: .02em; text-transform: uppercase; }
.dash-table tbody tr:hover { background: rgba(var(--accent-rgb),0.05); }
.dash-table .muted { color: var(--text-dim); }
.dash-row-link { cursor: pointer; }
.dash-row-link:hover { background: rgba(var(--accent-rgb),0.12) !important; }
.dash-row-link:hover td:first-child { box-shadow: inset 3px 0 0 var(--gold-mid); }

/* People tables: keep each cell's text on one line so narrow columns don't
   collapse text into a vertical, one-glyph-per-line column. The tables live in
   an overflow-x:auto wrapper, so wide rows scroll horizontally instead. */
.dash-table--ppl th, .dash-table--ppl td { white-space: nowrap; }
/* Name: "first last" on one line for desktop… */
.dash-name-first, .dash-name-last { display: inline; }
@media (max-width: 600px) {
    /* …but stack first name and last name on separate lines on mobile. */
    .dash-name-first, .dash-name-last { display: block; }
}

.dash-pill {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: .75rem; background: rgba(var(--accent-rgb),0.10);
    color: var(--gold-bright); border: 1px solid rgba(var(--border-rgb, var(--accent-rgb)),0.20);
}
.dash-pill--dim { color: var(--text-dim); background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.07); }

.dash-empty {
    text-align: center; padding: 36px 20px; color: var(--text-muted);
    border: 1px dashed rgba(var(--accent-rgb),0.25); border-radius: 14px;
    background: rgba(0,0,0,0.18);
}
.dash-empty strong { color: var(--gold-bright); display: block; margin-bottom: 6px; }

/* ── Calendar surface ──────────────────────────────────────────────────── */
.dash-calendar-card {
    background: linear-gradient(160deg, rgba(var(--bg-rgb),0.92) 0%, rgba(var(--bg-rgb-soft),0.95) 50%, rgba(var(--bg-rgb-deep),0.97) 100%);
    border: 1px solid rgba(var(--accent-rgb),0.22);
    border-radius: 18px; padding: 18px;
    box-shadow: 0 24px 60px -28px rgba(0,0,0,.6);
}
#dash-calendar { min-height: 540px; }

/* Working-month (งวดทำงาน) period banner above the calendar. */
.dash-cal-period {
    text-align: center; font-weight: 700; font-size: .92rem;
    color: var(--gold-bright); margin: 0 0 12px;
    padding: 7px 12px; border-radius: 10px;
    background: rgba(var(--accent-rgb),0.10);
    border: 1px solid rgba(var(--border-rgb, var(--accent-rgb)),0.30);
}
/* Days outside the working period (the full-week padding) read as muted. */
.fc .fc-day-disabled { opacity: .42; background: rgba(0,0,0,0.10) !important; }

/* The day the calendar jumped to right after a booking was saved (dashboard.js
   consumes the stashed date). A gold ring that fades out on its own, so a
   booking made in a period the user wasn't viewing is easy to spot. */
.fc .fc-daygrid-day.fc-day-jump {
    border-radius: 10px;
    animation: dash-cal-jump 5.5s ease-out forwards;
}
/* The ring carries the cue on its own: the mobile block below paints day cells
   with `background: transparent !important`, which an animation can't override. */
@keyframes dash-cal-jump {
    0%, 70% { background: rgba(var(--accent-rgb),0.16); box-shadow: inset 0 0 0 2px var(--gold-mid, #d4af37); }
    100%    { background: transparent;                  box-shadow: inset 0 0 0 2px rgba(212,175,55,0); }
}

.fc {
    color: var(--text-primary); font-family: 'Niramit', sans-serif;
    --fc-border-color: rgba(var(--accent-rgb),0.13);
    --fc-page-bg-color: transparent;
    --fc-neutral-bg-color: rgba(0,0,0,0.20);
    --fc-today-bg-color: rgba(var(--accent-rgb),0.08);
    --fc-now-indicator-color: var(--gold-bright);
    --fc-event-bg-color: var(--green-cta);
    --fc-event-border-color: var(--gold-mid);
    --fc-event-text-color: var(--gold-bright);
    --fc-list-event-hover-bg-color: rgba(var(--accent-rgb),0.10);
}

/* Toolbar — gold gradient title + layered 3D pill buttons */
/* flex-wrap + min-width:0 stop the title from being crushed to 1 char (which
   made "มิถุนายน 2569" wrap vertically) when the row is too narrow on phones. */
.fc .fc-toolbar.fc-header-toolbar { margin-bottom: 16px; flex-wrap: wrap; gap: 8px; row-gap: 10px; justify-content: center; }
.fc .fc-toolbar-chunk { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; min-width: 0; }
.fc .fc-toolbar-title {
    background: linear-gradient(180deg, #f5e16a 0%, #d4af37 55%, #a87c20 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800; font-size: 1.25rem; letter-spacing: .01em;
    white-space: nowrap;   /* keep the month/year on one line */
}
/* On phones, stack the toolbar so the title gets a full-width row of its own. */
@media (max-width: 600px) {
    .fc .fc-toolbar.fc-header-toolbar { flex-direction: column; align-items: stretch; }
    .fc .fc-toolbar-title { font-size: 1.05rem; text-align: center; }
}
.fc .fc-button-primary {
    background: linear-gradient(180deg, rgba(var(--accent-rgb),0.20), rgba(var(--accent-rgb),0.07));
    border: 1px solid rgba(var(--accent-rgb),0.32);
    color: var(--gold-bright); text-transform: none; font-weight: 600;
    border-radius: 10px; padding: 6px 13px;
    box-shadow: 0 2px 0 rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06);
    transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.fc .fc-button-primary:not(:disabled):hover {
    background: linear-gradient(180deg, rgba(var(--accent-rgb),0.34), rgba(var(--accent-rgb),0.16));
    border-color: var(--gold-mid); transform: translateY(-1px);
    box-shadow: 0 5px 14px -5px rgba(var(--accent-rgb),0.55), inset 0 1px 0 rgba(255,255,255,0.08);
}
.fc .fc-button-primary:not(:disabled):active,
.fc .fc-button-primary:not(:disabled).fc-button-active {
    background: linear-gradient(180deg, rgba(var(--accent-rgb),0.42), rgba(var(--accent-rgb),0.22));
    border-color: var(--gold-bright); color: #fff7d6; transform: translateY(0);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.4);
}
.fc .fc-button-primary:disabled { opacity: .4; }
.fc .fc-button-primary:focus,
.fc .fc-button-primary:focus-visible { box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.28); outline: none; }

/* Grid frame — rounded, contained surface */
.fc .fc-scrollgrid {
    border-radius: 14px; overflow: hidden;
    border: 1px solid rgba(var(--accent-rgb),0.18);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

/* Weekday header */
.fc .fc-col-header-cell {
    background: linear-gradient(180deg, rgba(var(--accent-rgb),0.12), rgba(var(--accent-rgb),0.02));
    padding: 8px 0;
}
.fc .fc-col-header-cell-cushion {
    color: var(--gold-mid); text-decoration: none;
    font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em;
}

/* Day cells — layered surface with hover lift */
.fc .fc-daygrid-day {
    background: rgba(var(--bg-rgb-deep),0.40);
    transition: background .15s ease, box-shadow .15s ease;
}
.fc .fc-daygrid-day:hover {
    background: rgba(var(--accent-rgb),0.07);
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb),0.28);
    cursor: pointer;
}
.fc .fc-daygrid-day-number {
    color: var(--text-muted); text-decoration: none;
    font-weight: 600; padding: 6px 8px;
}
.fc .fc-day-sat, .fc .fc-day-sun { background: rgba(0,0,0,0.22); }

/* Today — glowing gold chip on the date number */
.fc .fc-day-today { background: rgba(var(--accent-rgb),0.07) !important; }
.fc .fc-day-today .fc-daygrid-day-number {
    color: var(--green-dark); font-weight: 800;
    background: linear-gradient(180deg, #f5e16a, #d4af37);
    border-radius: 8px; margin: 4px; padding: 2px 9px;
    box-shadow: 0 2px 10px -2px rgba(245,225,106,0.7);
}

/* Month-start tag — small gold caption beside the day number (desktop). */
.fc .fc-monthtag { margin-left: 5px; font-size: .72rem; font-weight: 700; color: var(--gold-mid); }

/* Other-month days dimmed */
.fc .fc-day-other { background: rgba(0,0,0,0.30); }
.fc .fc-day-other .fc-daygrid-day-number { color: var(--text-dim); opacity: .45; }

/* Events — 3D gradient pills */
.fc .fc-event {
    background: linear-gradient(180deg, var(--green-accent), var(--green-cta));
    border: 1px solid rgba(var(--accent-rgb),0.55); color: var(--gold-bright);
    border-radius: 7px; padding: 1px 6px; font-size: .76rem; font-weight: 600;
    box-shadow: 0 2px 6px -2px rgba(0,0,0,0.5);
    transition: filter .12s ease, transform .12s ease;
}
.fc .fc-event:hover { filter: brightness(1.15); transform: translateY(-1px); }
.fc .fc-daygrid-event { margin-top: 2px; }
.fc .fc-daygrid-more-link { color: var(--gold-mid); font-weight: 600; }

/* List view */
.fc .fc-list {
    border-radius: 14px; overflow: hidden; border: 1px solid rgba(var(--accent-rgb),0.18);
}
.fc .fc-list-day-cushion {
    background: linear-gradient(180deg, rgba(var(--accent-rgb),0.14), rgba(var(--accent-rgb),0.04));
    color: var(--gold-bright);
}
.fc .fc-list-event:hover td { background: rgba(var(--accent-rgb),0.10); }
.fc .fc-list-event-dot { border-color: var(--green-cta); }
.fc .fc-list-empty { background: rgba(0,0,0,0.18); color: var(--text-muted); }

/* Time-grid (week / day views) */
.fc .fc-timegrid-axis-cushion,
.fc .fc-timegrid-slot-label-cushion { color: var(--text-dim); }

/* ── Mobile month view — clean, airy calendar (reference layout, app theme) ──
   Borderless grid, centered day numbers, circular "today" chip, pill events.
   Matches the green/gold theme rather than the reference's blue/white.        */
@media (max-width: 600px) {
    .fc .fc-toolbar-title { font-size: 1.15rem; }

    /* Drop the boxy frame + inner gridlines for an open, modern look */
    .fc .fc-scrollgrid { border: none; border-radius: 0; box-shadow: none; }
    .fc .fc-scrollgrid td, .fc .fc-scrollgrid th,
    .fc .fc-scrollgrid-section > * { border: none !important; }

    /* Weekday header: quiet, uppercase (SU MO TU …) */
    .fc .fc-col-header-cell { background: transparent; padding: 4px 0; }
    .fc .fc-col-header-cell-cushion { color: var(--text-dim); font-size: .7rem; letter-spacing: .06em; }

    /* Day cells: no fills, centered number, comfy tap target */
    .fc .fc-daygrid-day,
    .fc .fc-day-sat, .fc .fc-day-sun, .fc .fc-day-other { background: transparent !important; }
    .fc .fc-daygrid-day-frame { min-height: 46px; padding: 3px 0 4px; }
    .fc .fc-daygrid-day-top { justify-content: center; }
    /* The number anchor is a centered column: the circle on top, the optional
       month-start tag as a small caption beneath it — so the month name is kept
       on mobile but never sits inside/over the 34px circle. */
    .fc .fc-daygrid-day-number {
        display: flex; flex-direction: column; align-items: center;
        width: auto; height: auto; line-height: 1; padding: 0; margin: 0;
        color: var(--text-primary); font-weight: 600;
    }
    .fc .fc-daynum {
        width: 34px; height: 34px; line-height: 34px; text-align: center;
        border-radius: 50%;
    }
    /* Month-start tag: small gold caption under the circle. */
    .fc .fc-monthtag {
        display: block; margin: 1px 0 0; font-size: .58rem; line-height: 1;
        font-weight: 700; color: var(--gold-mid); white-space: nowrap;
    }
    /* Neutralize FullCalendar's enlarged month-start number. */
    .fc .fc-daygrid-month-start { font-size: 1em; }
    .fc .fc-daygrid-day:hover { background: transparent !important; box-shadow: none; }
    .fc .fc-daygrid-day:hover .fc-daynum { background: rgba(var(--accent-rgb),0.14); }
    .fc .fc-day-other .fc-daygrid-day-number { color: var(--text-dim); opacity: .4; }

    /* Today: filled gold circle (reference uses a blue circle — themed gold) */
    .fc .fc-day-today { background: transparent !important; }
    .fc .fc-day-today .fc-daynum {
        background: linear-gradient(180deg, #f5e16a, #d4af37);
        color: var(--green-dark); font-weight: 800;
        box-shadow: 0 4px 12px -3px rgba(245,225,106,0.6);
    }

    /* Events: slim centered pills / multi-day range bars */
    .fc .fc-daygrid-day-events { margin-top: 1px; min-height: 0; }
    .fc .fc-daygrid-event-harness { margin: 0 2px; }
    .fc .fc-event {
        border-radius: 999px; padding: 0 6px; font-size: .68rem; line-height: 1.5;
        border-color: rgba(var(--accent-rgb),0.45);
    }
    /* Hide the tiny event title text in the dense grid — keep the colored pill */
    .fc .fc-daygrid-day-bottom { margin-top: 0; }
}

/* ── "Today's schedule" list — numbered timeline cards (reference layout) ──── */
.dash-today-card { margin-top: 14px; }
.dash-today-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.dash-today-head small { color: var(--text-dim); font-size: .78rem; font-weight: 500; }
.dash-today { display: flex; flex-direction: column; gap: 10px; }
.dts-empty { color: var(--text-dim); font-style: italic; text-align: center; padding: 18px 0; }
.dts-item {
    display: flex; gap: 12px; align-items: flex-start; text-decoration: none;
    background: rgba(var(--bg-rgb-deep), 0.45);
    border: 1px solid rgba(var(--accent-rgb), 0.18);
    border-left: 3px solid var(--green-cta);
    border-radius: 12px; padding: 12px 14px; color: inherit;
    transition: border-color .15s, background .15s, transform .1s;
}
a.dts-item:hover { border-color: var(--gold-mid); background: rgba(var(--accent-rgb), 0.08); transform: translateY(-1px); }
.dts-num {
    flex: 0 0 auto; width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 50%;
    background: linear-gradient(180deg, var(--green-accent), var(--green-cta));
    color: var(--gold-bright); font-weight: 800; font-size: .8rem;
    border: 1px solid rgba(var(--accent-rgb), 0.4);
}
.dts-body { min-width: 0; flex: 1; }
.dts-time { color: var(--gold-bright); font-weight: 700; font-size: .82rem; }
.dts-title { color: var(--text-primary); font-weight: 700; font-size: .95rem; margin-top: 2px; }
.dts-desc { color: var(--text-muted); font-size: .84rem; line-height: 1.5; margin-top: 3px; }
.dts-by { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: .8rem; margin-top: 3px; }
.dts-by-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }

/* ── Calendar creator filter (oversight: Markaz / admin) ───────────────── */
.dash-cal-controls {
    margin-bottom: 12px; padding: 8px 12px;
    background: rgba(var(--bg-rgb-deep), 0.4);
    border: 1px solid rgba(var(--accent-rgb), 0.18); border-radius: 12px;
}
/* Collapsible wrapper — closed by default; the summary shows the active filters. */
.dcc-summary {
    cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    color: var(--gold-bright); font-size: .88rem; font-weight: 700; padding: 2px 0;
}
.dcc-summary::-webkit-details-marker { display: none; }
.dcc-summary::before { content: '▸'; display: inline-block; transition: transform .15s; }
.dcc-details[open] > .dcc-summary::before { transform: rotate(90deg); }
.dcc-summary-cur { color: var(--text-muted); font-weight: 500; font-size: .8rem; }
.dcc-body { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.dcc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.dcc-groups { display: flex; flex-direction: column; gap: 8px; }
.dcc-group { display: flex; flex-direction: column; gap: 4px; }
.dcc-group-label { color: var(--text-muted); font-size: .78rem; font-weight: 700; }
.dcc-group-n {
    display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; text-align: center;
    background: rgba(var(--accent-rgb), 0.14); color: var(--gold-bright); font-size: .72rem;
}
.dcc-select { max-width: 100%; }
.dcc-label { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: .85rem; font-weight: 600; }
.dcc-select {
    font-family: inherit; font-size: .85rem; padding: 5px 10px; border-radius: 8px;
    background: rgba(0,0,0,0.3); color: var(--text-primary);
    border: 1px solid rgba(var(--accent-rgb), 0.28);
}
.dcc-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.dcc-chip {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
    font-family: inherit; font-size: .8rem; padding: 4px 10px; border-radius: 999px;
    background: rgba(var(--accent-rgb), 0.06); color: var(--text-muted);
    border: 1px solid rgba(var(--accent-rgb), 0.2); transition: border-color .15s, background .15s, color .15s;
}
.dcc-chip:hover { color: var(--gold-bright); border-color: var(--gold-mid); }
.dcc-chip.is-active { background: rgba(var(--accent-rgb), 0.18); color: var(--gold-bright); border-color: var(--gold-mid); font-weight: 700; }
.dcc-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }

/* Event "who booked it" chip inside FullCalendar cells. */
.fc-by { display: flex; flex-direction: column; gap: 1px; line-height: 1.2; overflow: hidden; }
.fc-by-name { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 700; opacity: .95; }
.fc-by-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.fc-by-title { font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-by-time { font-weight: 700; opacity: .9; }

/* ── Action buttons / row controls ─────────────────────────────────────── */
.btn { display:inline-flex; align-items:center; gap:6px; padding: 7px 14px; border-radius: 8px; font-size:.85rem; border: 1px solid rgba(var(--accent-rgb),0.25); background: rgba(var(--accent-rgb),0.08); color: var(--gold-bright); cursor: pointer; font-family: inherit; }
.btn:hover { background: rgba(var(--accent-rgb),0.18); }
.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { color: var(--gold-bright); }
.btn--danger { background: rgba(180,30,30,0.18); border-color: rgba(252,165,165,0.30); color: var(--error-fg); }
.btn--cta { background: linear-gradient(90deg, var(--green-accent), var(--green-cta)); border-color: var(--gold-mid); color: var(--cta-text, var(--gold-bright)); font-weight: 700; }

/* ── "Set login" inline form (admin People section) ────────────────────── */
.dash-setlogin > summary { list-style: none; cursor: pointer; user-select: none; }
.dash-setlogin > summary::-webkit-details-marker { display: none; }
.dash-setlogin[open] > summary { background: rgba(var(--accent-rgb),0.18); color: var(--gold-bright); }
.dash-setlogin-form {
    margin-top: 8px; padding: 12px;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(var(--accent-rgb),0.22); border-radius: 10px;
    display: flex; flex-direction: column; gap: 8px;
    min-width: 240px;
}
.dash-setlogin-form label { font-size: .76rem; color: var(--gold-mid); font-weight: 600; }
.dash-setlogin-form .qp-input { font-size: .85rem; padding: 7px 10px; }
.dash-setlogin-form .btn { align-self: flex-start; }

/* ── R02 status overlays on calendar events ─────────────────────────────
   Set by api/calendar_events.php extendedProps + dashboard.js eventClassNames.
   pending     = edit awaiting Markaz approval (greyed + dashed, everyone)
   reminder    = the target, 48h before the visit (alert red, gentle pulse)
   rescheduled = the target, visit moved within last 7 days (amber)            */
.fc .fc-event.fc-pending {
    opacity: .55;
    border-style: dashed !important;
    border-width: 1.5px !important;
}
.fc .fc-event.fc-reminder {
    border-color: #ffd0d0 !important;
    box-shadow: 0 0 0 1px rgba(226,59,59,0.45);
    animation: r02-remind-pulse 1.8s ease-in-out infinite;
}
.fc .fc-event.fc-rescheduled {
    border-color: #ffe1b0 !important;
}
@keyframes r02-remind-pulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(226,59,59,0.35); }
    50%      { box-shadow: 0 0 7px 2px rgba(226,59,59,0.55); }
}
@media (prefers-reduced-motion: reduce) {
    .fc .fc-event.fc-reminder { animation: none; }
}
