:root {
  color-scheme: dark;
  --bg: #0a0f1c;
  --bg-2: #0d1426;
  --surface: #121a2f;
  --surface-2: #172139;
  --surface-3: #1d2945;
  --border: rgba(148, 163, 196, 0.12);
  --border-strong: rgba(148, 163, 196, 0.22);
  --text: #e7ecf6;
  --muted: #8d99b4;
  --faint: #5c6884;
  --brand: #4b7be0;
  --brand-deep: #2c5596;
  --brand-soft: rgba(75, 123, 224, 0.16);
  --ok: #34c79a;
  --warn: #f2b84b;
  --bad: #f2718a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.7);
  --cell: 40px;
  --name-col: 190px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(75, 123, 224, 0.16), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(60, 200, 180, 0.07), transparent 60%);
}
#app { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2);
  font-weight: 600; font-size: 13.5px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: var(--surface-3); border-color: rgba(148, 163, 196, 0.32); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: linear-gradient(180deg, #5687ea, #3d6bd0); border-color: transparent; color: #fff; box-shadow: 0 8px 22px -10px rgba(75, 123, 224, .8); }
.btn.primary:hover { background: linear-gradient(180deg, #6391f0, #4673d6); }
.btn.ok { background: rgba(52, 199, 154, .14); border-color: rgba(52, 199, 154, .35); color: #6ee0bb; }
.btn.ok:hover { background: rgba(52, 199, 154, .22); }
.btn.danger { background: rgba(242, 113, 138, .1); border-color: rgba(242, 113, 138, .3); color: #f79aac; }
.btn.danger:hover { background: rgba(242, 113, 138, .18); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn.icon { width: 38px; padding: 0; justify-content: center; }
.btn.icon.sm { width: 32px; }
.btn:disabled { opacity: .5; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.input {
  height: 42px; padding: 0 14px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border-strong); outline: none;
  transition: border-color .15s, box-shadow .15s; width: 100%;
}
textarea.input { height: auto; min-height: 76px; padding: 10px 14px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type="date"].input, input[type="time"].input { color-scheme: dark; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.row .field, .row .input { min-width: 0; }

.segmented { display: inline-flex; padding: 4px; gap: 4px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; }
.segmented button {
  border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 9px;
  font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; transition: all .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface-3); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
.segmented button svg { width: 16px; height: 16px; flex: none; }
.segmented.full { display: flex; width: 100%; }
.segmented.full button { flex: 1; justify-content: center; }

/* ---------- login ---------- */
.login-wrap { flex: 1; display: grid; place-items: center; padding: 32px 16px; }
.login-card {
  width: 100%; max-width: 400px; padding: 36px 32px 28px;
  background: linear-gradient(180deg, rgba(23, 33, 57, .9), rgba(18, 26, 47, .9));
  border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow);
  backdrop-filter: blur(12px); animation: rise .5s cubic-bezier(.2, .8, .2, 1);
}
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 26px; text-align: center; }
.login-logo img { width: 76px; height: 76px; border-radius: 16px; box-shadow: 0 14px 40px -12px rgba(75, 123, 224, .8); }
.login-logo h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: .02em; }
.login-logo p { margin: -10px 0 0; color: var(--muted); font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 16px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-inline-end: 44px; }
.input.ltr { direction: ltr; text-align: left; }
/* typed usernames and passwords stay left-to-right; the empty-field example follows the page direction */
.input.ltr:placeholder-shown { direction: inherit; text-align: start; }
.input.ltr[type="password"]:placeholder-shown { direction: ltr; text-align: left; }
.pw-wrap button { position: absolute; inset-inline-end: 4px; top: 4px; height: 34px; width: 36px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; }
.pw-wrap button:hover { color: var(--text); background: var(--surface-2); }
.pw-wrap svg { width: 18px; height: 18px; }
.login-error { color: #f79aac; font-size: 13px; min-height: 18px; margin-top: -6px; }
.login-card .btn.primary { height: 44px; justify-content: center; font-size: 14.5px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px;
  padding: 12px 24px; background: rgba(10, 15, 28, .78); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; letter-spacing: .02em; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0; margin-top: -3px; }
.nav { display: flex; gap: 4px; margin-inline-start: 12px; }
.nav button { position: relative; border: 0; background: transparent; color: var(--muted); font-weight: 600; padding: 8px 14px; border-radius: 10px; display: flex; align-items: center; gap: 8px; }
.nav button:hover { color: var(--text); background: var(--surface); }
.nav button.active { color: var(--text); background: var(--surface-2); }
.nav svg { width: 16px; height: 16px; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.badge.warn { background: var(--warn); color: #241a05; }
.spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 5px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; flex: none; }
.user-chip .who { font-weight: 600; font-size: 13px; white-space: nowrap; }
.user-chip .who span { color: var(--muted); font-weight: 500; }

/* ---------- main ---------- */
main { flex: 1; width: 100%; max-width: 1680px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.page-head h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav .label { min-width: 170px; text-align: center; font-size: 20px; font-weight: 800; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; gap: 14px; }
main.fresh .stat { animation: rise .4s both; }
main.fresh .req { animation: rise .3s both; }
.stat .dot { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.stat .dot svg { width: 18px; height: 18px; }
.stat b { display: block; font-size: 20px; font-weight: 800; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 12px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- schedule grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid-wrap { overflow: auto; max-height: calc(100vh - 300px); min-height: 280px; border-radius: var(--radius); }
.grid-wrap::-webkit-scrollbar { height: 10px; width: 10px; }
.grid-wrap::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--surface); }
table.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.grid th, .grid td { padding: 0; }
.grid thead th {
  position: sticky; top: 0; z-index: 3; background: var(--surface-2);
  width: var(--cell); min-width: var(--cell); height: 52px; text-align: center;
  font-size: 11px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border);
}
.grid thead th .dn { display: block; font-size: 14px; color: var(--text); font-weight: 700; }
.grid thead th.weekend { color: #9aa6c2; background: #1a2440; }
.grid thead th.today { background: var(--brand-deep); color: #dfe8ff; }
.grid thead th.today .dn { color: #fff; }
.grid .name-col { position: sticky; left: 0; z-index: 2; background: var(--surface); width: var(--name-col); min-width: var(--name-col); text-align: left; border-right: 1px solid var(--border); }
.grid thead .name-col { z-index: 4; background: var(--surface-2); padding-left: 16px; font-size: 12px; }
.grid .agent { display: flex; align-items: center; gap: 10px; padding: 0 12px 0 14px; height: 46px; }
.grid .agent .avatar { width: 28px; height: 28px; font-size: 11px; }
.grid .agent .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid .agent .you { font-size: 10px; font-weight: 700; color: var(--brand); background: var(--brand-soft); padding: 1px 6px; border-radius: 6px; margin-left: auto; }
.grid tbody tr td { border-bottom: 1px solid var(--border); }
.grid tbody tr:hover td { background-color: rgba(255, 255, 255, .015); }
.grid tbody tr:hover .name-col { background: var(--surface-2); }
.grid tr.me .name-col { background: #16213d; box-shadow: inset 3px 0 0 var(--brand); }
.grid tr.me td { background-color: rgba(75, 123, 224, .05); }
.grid tr.team-row td { background: var(--bg-2); height: 34px; border-bottom: 1px solid var(--border); }
.grid tr.team-row .name-col { background: var(--bg-2); }
.team-label { display: flex; align-items: center; gap: 8px; padding-left: 14px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.team-label i { width: 8px; height: 8px; border-radius: 3px; }
.grid td.cell { text-align: center; position: relative; }
.grid td.cell.weekend { background-color: rgba(26, 36, 64, .45); }
.grid td.cell.today { background-color: rgba(75, 123, 224, .1); }

.chip {
  width: 34px; height: 30px; margin: 0 auto; border-radius: 8px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .02em; border: 1px solid transparent;
  transition: transform .12s, box-shadow .12s, outline-color .12s; position: relative; outline: 2px solid transparent; outline-offset: 1px;
}
button.chip { padding: 0; background-clip: padding-box; }
button.chip:hover { transform: translateY(-1px) scale(1.06); box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .8); }
.chip.empty { background: transparent; border: 1px dashed var(--border-strong); color: var(--faint); }
.chip.selected { outline-color: #fff; }
.chip .mark { position: absolute; top: -4px; right: -4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); }
.chip .mark.pending { background: var(--warn); animation: pulse 1.8s infinite; }
.chip .mark.hours { background: #7dd3fc; }
.chip .mark.hours.pending { background: var(--warn); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 14px 18px; align-items: center; color: var(--muted); font-size: 12.5px; }
.legend .item { display: flex; align-items: center; gap: 8px; }
.legend .chip { width: 30px; height: 24px; margin: 0; font-size: 10px; }
.legend .mk { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- popover ---------- */
.popover {
  position: fixed; z-index: 60; min-width: 240px; max-width: 290px; padding: 8px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .85);
  animation: pop .14s ease-out;
}
.popover .ph { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.popover .ph b { display: block; font-size: 13.5px; }
.popover .ph span { color: var(--muted); font-size: 12px; }
.popover .note { padding: 6px 10px; font-size: 12px; color: var(--muted); }
.popover .note b { color: var(--text); font-weight: 600; }
.popover .opt { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: transparent; border-radius: 9px; text-align: start; font-weight: 500; font-size: 13px; }
.popover .opt:hover { background: var(--surface-3); }
.popover .opt svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.popover .shift-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px 4px 8px; }
.popover .shift-pick button { height: 34px; border-radius: 8px; border: 1px solid transparent; font-weight: 700; font-size: 12px; }
.popover .shift-pick button.current { outline: 2px solid #fff; outline-offset: 1px; }
.popover .sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(4, 7, 15, .66); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px; box-shadow: var(--shadow); animation: rise .22s cubic-bezier(.2, .8, .2, 1); }
.modal header { display: flex; align-items: center; gap: 12px; padding: 20px 22px 6px; }
.modal header .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.modal header .ic svg { width: 20px; height: 20px; }
.modal header h3 { margin: 0; font-size: 17px; font-weight: 800; }
.modal header p { margin: 0; color: var(--muted); font-size: 12.5px; }
.modal header .btn { margin-inline-start: auto; }
.modal .body { padding: 16px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal footer { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 10px; }

.swap-preview { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 14px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); }
.swap-preview .side { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 12px; color: var(--muted); }
.swap-preview .side b { color: var(--text); font-size: 13px; }
.swap-preview .arrow { color: var(--brand); }
.swap-preview .arrow svg { width: 22px; height: 22px; }
.hint { font-size: 12px; color: var(--muted); background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }

/* ---------- requests ---------- */
.req-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.req {
  padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px; transition: border-color .15s, transform .15s;
}
.req:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.req .top { display: flex; align-items: center; gap: 10px; }
.req .top .who b { display: block; font-size: 13.5px; }
.req .top .who span { color: var(--muted); font-size: 12px; }
.status { margin-inline-start: auto; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: capitalize; }
.status.pending { background: rgba(242, 184, 75, .14); color: var(--warn); }
.status.approved { background: rgba(52, 199, 154, .14); color: var(--ok); }
.status.rejected { background: rgba(242, 113, 138, .14); color: var(--bad); }
.status.cancelled { background: rgba(141, 153, 180, .14); color: var(--muted); }
.req .what { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--border); font-size: 13px; }
.req .what .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.req .what .ic svg { width: 17px; height: 17px; }
.req .what b { display: block; }
.req .what span { color: var(--muted); font-size: 12px; }
.req .reason { font-size: 12.5px; color: var(--muted); font-style: italic; }
.req .meta { font-size: 11.5px; color: var(--faint); display: flex; justify-content: space-between; gap: 8px; }
.req .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.req .actions .btn { flex: 1; justify-content: center; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-state svg { width: 44px; height: 44px; color: var(--faint); margin-bottom: 10px; }

/* ---------- misc ---------- */
.swap-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; background: var(--brand-soft); border: 1px solid rgba(75, 123, 224, .4); font-size: 13px; animation: rise .2s; }
.swap-banner svg { width: 18px; height: 18px; color: var(--brand); }

#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; padding: 12px 16px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 13px; animation: slide .25s cubic-bezier(.2, .8, .2, 1); }
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.ok svg { color: var(--ok); }
.toast.err svg { color: var(--bad); }
.toast.out { animation: slideOut .25s forwards; }

.footer { text-align: center; padding: 22px 16px 26px; color: var(--faint); font-size: 12px; letter-spacing: .08em; }
.footer b { background: linear-gradient(90deg, #7aa2f5, #3cc8b4); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); border-top-color: #fff; animation: spin .7s linear infinite; }
.loading { display: grid; place-items: center; padding: 80px; }
.loading .spinner { width: 30px; height: 30px; border-color: var(--surface-3); border-top-color: var(--brand); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { opacity: 0; transform: translateX(30px); } }
@keyframes slideOut { to { opacity: 0; transform: translateX(30px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242, 184, 75, .6); } 50% { box-shadow: 0 0 0 4px rgba(242, 184, 75, 0); } }

/* crosshair highlight: the row and column under the pointer light up */
.grid .hl { background-image: linear-gradient(rgba(255, 255, 255, .075), rgba(255, 255, 255, .075)); }
.grid thead th.hl { color: #fff; }
.grid thead th.hl .dn { color: #fff; }
.grid .name-col.hl { background-image: linear-gradient(rgba(120, 165, 255, .18), rgba(120, 165, 255, .18)); }
.grid .name-col.hl .nm { color: #fff; }
.grid td.cell.hl .chip { filter: brightness(1.2); }
.grid td.cell.hl-x { background-image: linear-gradient(rgba(255, 255, 255, .14), rgba(255, 255, 255, .14)); }
.grid td.cell.hl-x .chip { outline: 2px solid rgba(255, 255, 255, .85); outline-offset: 1px; filter: brightness(1.3); }

/* ---------- phone view button ---------- */
.ui-toggle { gap: 8px; }
.login-tools { position: fixed; top: 14px; inset-inline-end: 14px; z-index: 40; display: flex; gap: 8px; }

/* ---------- day-by-day schedule (phone view) ---------- */
.day-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; scrollbar-width: none; margin: 0 -2px; }
.day-strip::-webkit-scrollbar { display: none; }
.day-pill {
  flex: none; width: 54px; padding: 8px 0 9px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 11px; font-weight: 600; scroll-snap-align: center; transition: background .15s, border-color .15s;
}
.day-pill .num { font-size: 18px; font-weight: 800; color: var(--text); line-height: 1.15; }
.day-pill i { width: 18px; height: 4px; border-radius: 3px; background: var(--surface-3); margin-top: 3px; }
.day-pill.weekend { background: #151e38; }
.day-pill.today { border-color: rgba(75, 123, 224, .6); }
.day-pill.active { background: var(--brand-deep); border-color: transparent; color: #dfe8ff; box-shadow: 0 8px 22px -10px rgba(75, 123, 224, .9); }
.day-pill.active .num { color: #fff; }
.day-head { display: flex; align-items: baseline; gap: 10px; padding: 14px 16px 4px; }
.day-head b { font-size: 17px; font-weight: 800; }
.day-head span { color: var(--muted); font-size: 12.5px; }
.day-list .team-label { padding: 14px 16px 6px; }
.day-row {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 16px; border: 0; border-top: 1px solid var(--border);
  background: transparent; text-align: start; min-height: 56px;
}
.day-row:active { background: var(--surface-2); }
.day-row.me { background: rgba(75, 123, 224, .08); box-shadow: inset 3px 0 0 var(--brand); }
.day-row .who { flex: 1; min-width: 0; }
.day-row .who b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-row .who span { color: var(--muted); font-size: 12px; }
.day-row .chip { width: 52px; height: 34px; margin: 0; font-size: 12.5px; flex: none; }
.view-switch { display: none; }

/* ---------- phone layout: switched on by the button, or automatically on narrow screens ---------- */
.mobile-ui { --name-col: 120px; --cell: 38px; --phone: 480px; }
.mobile-ui body { font-size: 15px; }
.mobile-ui #app { max-width: var(--phone); margin: 0 auto; width: 100%; box-shadow: 0 0 0 1px var(--border); background: rgba(10, 15, 28, .5); }
/* no blur on the top bar here: a blur would trap the fixed bottom menu inside it */
.mobile-ui .topbar { padding: 10px 14px; gap: 8px; flex-wrap: nowrap; backdrop-filter: none; background: rgba(10, 15, 28, .97); }
.mobile-ui .brand { gap: 9px; font-size: 14px; }
.mobile-ui .brand img { width: 30px; height: 30px; }
.mobile-ui .brand small { display: none; }
.mobile-ui .ui-toggle .lbl, .mobile-ui .lang-toggle .lbl { display: none; }
.mobile-ui .ui-toggle, .mobile-ui .lang-toggle { width: 38px; padding: 0; justify-content: center; flex: none; }
.mobile-ui .user-chip { padding: 4px 4px 4px 4px; gap: 8px; min-width: 0; }
.mobile-ui .user-chip .who { font-size: 12.5px; line-height: 1.2; max-width: 128px; overflow: hidden; text-overflow: ellipsis; }
.mobile-ui .user-chip .who span { display: block; font-size: 10.5px; }
.mobile-ui .user-chip .who .dash { display: none; }
.day-row.selected { background: rgba(75, 123, 224, .22); }
.user-chip .who .dash { font-style: normal; }
.mobile-ui main { padding: 14px 14px 96px; gap: 14px; }
.mobile-ui .footer { padding-bottom: 92px; }

.mobile-ui .nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, var(--phone)); margin: 0; z-index: 45;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(13, 20, 38, .94); backdrop-filter: blur(16px); border-top: 1px solid var(--border-strong);
}
.mobile-ui .nav button { flex-direction: column; justify-content: center; gap: 3px; padding: 8px 0 7px; font-size: 11.5px; min-height: 52px; border-radius: 12px; }
.mobile-ui .nav svg { width: 20px; height: 20px; }
.mobile-ui .nav .badge { position: absolute; top: 3px; left: calc(50% + 8px); }

.mobile-ui .page-head { gap: 10px; }
.mobile-ui .page-head .spacer { display: none; }
.mobile-ui .month-nav { width: 100%; justify-content: space-between; }
.mobile-ui .month-nav .label { flex: 1; min-width: 0; font-size: 18px; }
.mobile-ui .page-head > .toolbar { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mobile-ui .page-head > .toolbar .btn { justify-content: center; }
.mobile-ui .page-head h2 { font-size: 21px; }
.mobile-ui .page-head .btn { justify-content: center; flex: 1; }

.mobile-ui .btn { height: 46px; border-radius: 12px; font-size: 14px; }
.mobile-ui .btn.sm { height: 38px; }
.mobile-ui .btn.icon { width: 46px; }
.mobile-ui .btn.icon.sm { width: 38px; }
.mobile-ui .input { height: 48px; font-size: 16px; }
.mobile-ui textarea.input { font-size: 16px; }
.mobile-ui .segmented button { padding: 9px 14px; }
.mobile-ui .toolbar { gap: 8px; }
.mobile-ui .toolbar .spacer, .mobile-ui .toolbar > span { display: none; }
.mobile-ui .toolbar .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.mobile-ui .toolbar .segmented::-webkit-scrollbar { display: none; }
.mobile-ui .view-switch { display: flex; width: 100%; }
.mobile-ui .view-switch button { flex: 1; justify-content: center; }

.mobile-ui .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
.mobile-ui .stat { padding: 10px 12px; gap: 10px; }
.mobile-ui .stat .dot { width: 34px; height: 34px; border-radius: 10px; }
.mobile-ui .stat b { font-size: 16px; }
.mobile-ui .stat:first-child { grid-column: 1 / -1; }

.mobile-ui .grid-wrap { max-height: 68vh; }
.mobile-ui .grid .agent .avatar { display: none; }
.mobile-ui .legend { gap: 8px 14px; font-size: 11.5px; padding: 12px 14px; }
.mobile-ui .req-list { grid-template-columns: 1fr; }
.mobile-ui .row { gap: 10px; }
.mobile-ui .req .actions .btn { height: 44px; }

/* menus and forms rise from the bottom like phone sheets */
.mobile-ui .popover {
  left: 50% !important; top: auto !important; bottom: 0; right: auto; width: min(100%, var(--phone)); max-width: none; min-width: 0;
  border-radius: 22px 22px 0 0; padding: 10px 10px calc(14px + env(safe-area-inset-bottom)); animation: sheet .2s ease-out; transform: translateX(-50%);
  box-shadow: 0 -30px 80px 20px rgba(0, 0, 0, .65);
}
.mobile-ui .popover .opt { padding: 14px 12px; font-size: 14.5px; }
.mobile-ui .popover .shift-pick { grid-template-columns: repeat(4, 1fr); }
.mobile-ui .popover .shift-pick button { height: 44px; }
.mobile-ui .overlay { align-items: end; padding: 0; }
.mobile-ui .modal { max-width: var(--phone); max-height: 92vh; border-radius: 22px 22px 0 0; animation: sheet-up .22s cubic-bezier(.2, .8, .2, 1); }
.mobile-ui .modal footer { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.mobile-ui .modal footer .btn { flex: 1; justify-content: center; }
.mobile-ui #toasts { left: 12px; right: 12px; bottom: 84px; align-items: center; }
.mobile-ui .toast { min-width: 0; width: 100%; max-width: 420px; }

.mobile-ui .login-card { padding: 30px 22px 24px; }
.mobile-ui .login-card .btn.primary { height: 50px; }

/* ---------- desktop schedule: a roster board that fits the screen, no scrolling ---------- */
/* The table stretches to the window width; row height adapts to the window height (--rows is set per table). */
html:not(.mobile-ui) main.sched {
  --name-col: 190px;
  --extra: 0px; /* the shift-swap banner adds a row while it is shown */
  --fixed: calc(352px + var(--extra)); /* space used by everything except the table rows */
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  column-gap: 24px; row-gap: 14px; padding: 18px 28px 6px; max-width: 2000px;
}
@media (max-width: 1790px) { html[dir="rtl"]:not(.mobile-ui) main.sched { --fixed: calc(414px + var(--extra)); } }
html:not(.mobile-ui) main.sched:has(.swap-banner) { --extra: 56px; }
/* narrower desktop windows: slimmer name column and smaller labels so the month still fits across */
@media (max-width: 1200px) {
  html:not(.mobile-ui) main.sched { --name-col: 140px; padding-inline: 16px; }
  html:not(.mobile-ui) main.sched .chip { font-size: 10px; }
  html:not(.mobile-ui) main.sched .grid .agent { padding-inline-start: 12px; }
}

/* row 1: month on one side, actions on the other; row 2: team tabs and the day summary */
html:not(.mobile-ui) main.sched .page-head { display: contents; }
html:not(.mobile-ui) main.sched .page-head .spacer { display: none; }
html:not(.mobile-ui) main.sched .month-nav { grid-column: 1; grid-row: 1; justify-self: start; gap: 10px; }
html:not(.mobile-ui) main.sched .month-nav .label { min-width: 190px; font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
html:not(.mobile-ui) main.sched .month-nav .btn.icon { border-radius: 50%; width: 38px; height: 38px; }
html:not(.mobile-ui) main.sched .page-head > .toolbar { grid-column: 2; grid-row: 1; justify-content: flex-end; flex-wrap: nowrap; }
html:not(.mobile-ui) main.sched .tabs-row { grid-column: 1; grid-row: 2; justify-self: start; }
html:not(.mobile-ui) main.sched .tabs-row > .spacer, html:not(.mobile-ui) main.sched .tabs-row > span { display: none; }
html:not(.mobile-ui) main.sched .stats { grid-column: 2; grid-row: 2; display: flex; gap: 22px; justify-content: flex-end; min-width: 0; overflow: hidden; }
html:not(.mobile-ui) main.sched .swap-banner, html:not(.mobile-ui) main.sched > .card { grid-column: 1 / -1; }
html:not(.mobile-ui) main.sched .btn { height: 40px; padding: 0 16px; }
html:not(.mobile-ui) main.sched .btn.sm { height: 32px; }

/* the stat cards become a light single line of numbers */
html:not(.mobile-ui) main.sched .stat { flex: none; padding: 0; gap: 8px; background: none; border: 0; border-radius: 0; animation: none; }
html:not(.mobile-ui) main.sched .stat .dot { width: 24px; height: 24px; border-radius: 8px; }
html:not(.mobile-ui) main.sched .stat .dot svg { width: 13px; height: 13px; }
html:not(.mobile-ui) main.sched .stat > div:last-child { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
html:not(.mobile-ui) main.sched .stat b { font-size: 15px; }
html:not(.mobile-ui) main.sched .stat span { font-size: 12px; }

/* the roster */
html:not(.mobile-ui) main.sched > .card {
  /* rows grow on tall screens but never get squeezed below a comfortable size (the page then scrolls up and down) */
  --row: clamp(36px, calc((100vh - var(--fixed)) / var(--rows, 14)), 52px);
  border-radius: 20px; overflow: hidden; background: linear-gradient(180deg, #131c33, #101830);
  box-shadow: 0 30px 70px -40px rgba(0, 0, 0, .9);
}
/* columns keep a comfortable width; on narrower windows the month scrolls sideways, opening centred on today */
html:not(.mobile-ui) main.sched .grid-wrap { max-height: none; min-height: 0; overflow-x: auto; overflow-y: hidden; container: gw / inline-size; scrollbar-width: thin; }
html:not(.mobile-ui) main.sched .grid { width: 100%; min-width: calc(var(--name-col) + var(--days, 31) * 50px); table-layout: fixed; }
html:not(.mobile-ui) main.sched .chip { overflow: hidden; padding: 0; white-space: nowrap; }
html:not(.mobile-ui) main.sched .grid thead th { width: auto; min-width: 0; height: 52px; background: transparent; border-bottom: 1px solid var(--border); font-size: 10.5px; font-weight: 600; color: var(--muted); }
html:not(.mobile-ui) main.sched .grid thead th.weekend { background: rgba(255, 255, 255, .025); color: #a9b4d0; }
html:not(.mobile-ui) main.sched .grid thead th.today { background: linear-gradient(180deg, #3d6bd0, #2c5596); color: #e6eeff; border-radius: 12px 12px 0 0; }
html:not(.mobile-ui) main.sched .grid thead th .dn { font-size: 15px; font-weight: 800; margin-top: 1px; }
html:not(.mobile-ui) main.sched .grid .wd { display: block; }
html:not(.mobile-ui) main.sched .grid thead th.name-col { width: var(--name-col); min-width: var(--name-col); background: #131c33; padding-inline-start: 22px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
html:not(.mobile-ui) main.sched .grid .name-col { width: var(--name-col); min-width: var(--name-col); background: #131c33; border-right: 0; box-shadow: 8px 0 14px -10px rgba(0, 0, 0, .7); }
html:not(.mobile-ui) main.sched .grid tbody tr td { border-bottom: 0; }
html:not(.mobile-ui) main.sched .grid tbody tr:hover td { background-color: transparent; }
html:not(.mobile-ui) main.sched .grid tbody tr:hover .name-col { background: #18233f; }
html:not(.mobile-ui) main.sched .grid tr.me .name-col { background: #1a2a52; box-shadow: inset 3px 0 0 var(--brand), 8px 0 14px -10px rgba(0, 0, 0, .7); }
html:not(.mobile-ui) main.sched .grid tr.me td.cell { background-color: rgba(75, 123, 224, .06); }
html:not(.mobile-ui) main.sched .grid td.cell { height: var(--row); padding: 2px; }
html:not(.mobile-ui) main.sched .grid td.cell.today { background-color: rgba(75, 123, 224, .2); box-shadow: inset 2px 0 0 rgba(95, 150, 245, .55), inset -2px 0 0 rgba(95, 150, 245, .55); }
html:not(.mobile-ui) main.sched .grid thead th.today .dn { background: #fff; color: #2c5596; border-radius: 9px; padding: 1px 7px; display: inline-block; margin-top: 2px; }
html:not(.mobile-ui) main.sched .grid thead th.today { box-shadow: 0 0 22px -4px rgba(75, 123, 224, .9); }
html:not(.mobile-ui) main.sched .grid td.cell.weekend { background-color: rgba(255, 255, 255, .025); }

html:not(.mobile-ui) main.sched .grid tr.team-row td { height: min(var(--row), 34px); background: transparent; }
html:not(.mobile-ui) main.sched .grid tr.team-row .name-col { background: #131c33; }
html:not(.mobile-ui) main.sched .grid .team-label { padding-inline-start: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .08em; font-size: 11px; color: #c4cde4; }
html:not(.mobile-ui) main.sched .grid .team-label i { width: 10px; height: 10px; border-radius: 4px; }

html:not(.mobile-ui) main.sched .grid .agent { height: var(--row); gap: 10px; padding: 0 12px 0 20px; }
html:not(.mobile-ui) main.sched .grid .agent .avatar { width: clamp(16px, calc(var(--row) - 12px), 32px); height: clamp(16px, calc(var(--row) - 12px), 32px); font-size: 10px; }
html:not(.mobile-ui) main.sched .grid .agent .nm { font-size: 13.5px; font-weight: 600; }

/* shifts are solid colour blocks that fill their cell */
html:not(.mobile-ui) main.sched .chip { width: 100%; max-width: none; height: clamp(15px, calc(var(--row) - 4px), 44px); border-radius: 9px; font-size: 11.5px; font-weight: 800; letter-spacing: 0; border-color: transparent; }
html:not(.mobile-ui) main.sched button.chip:hover { transform: scale(1.06); z-index: 2; }
html:not(.mobile-ui) main.sched .chip.empty { border: 1px dashed var(--border); opacity: .55; }
html:not(.mobile-ui) main.sched .chip .mark { top: 3px; right: 3px; width: 8px; height: 8px; border: 0; }
html:not(.mobile-ui) main.sched .legend { padding: 10px 20px; gap: 6px 18px; font-size: 11.5px; border-top: 1px solid var(--border); background: rgba(255, 255, 255, .02); }
html:not(.mobile-ui) main.sched .legend .chip { width: 34px; height: 22px; font-size: 10px; border-radius: 7px; }
html:not(.mobile-ui) .footer { padding: 8px 16px 14px; }
@media (max-width: 1700px) { html:not(.mobile-ui) main.sched .legend .lt { display: none; } }

/* Arabic full weekday names don't fit narrow columns sideways, so they stand rotated until the window is wide */
@container gw (max-width: 1750px) {
  html[dir="rtl"] .grid thead th { height: 92px; vertical-align: bottom; padding-bottom: 5px; }
  /* name stands centred over its date, reading bottom-to-top, with its end resting just above the number */
  html[dir="rtl"]:not(.mobile-ui) main.sched .grid thead th .wd { writing-mode: vertical-rl; transform: rotate(180deg); display: block; width: 18px; height: 56px; margin: 0 auto 6px; line-height: 18px; font-size: 11.5px; text-align: start; direction: ltr; white-space: nowrap; }
}

@media (max-width: 430px) {
  .mobile-ui .brand div { display: none; }
  .mobile-ui .user-chip .who { max-width: 96px; }
}

/* ---------- Arabic (right to left) ---------- */
/* the month table and day strip keep their left-to-right order so dates always run the same way */
.grid-wrap, .day-strip { direction: ltr; }
.grid .name-col, .grid .team-label { text-align: left; }
[dir="rtl"] .grid .agent .nm, [dir="rtl"] .grid .team-label { direction: rtl; }
[dir="rtl"] *:not(.footer):not(.footer b) { letter-spacing: 0 !important; }
[dir="rtl"] .team-label { text-transform: none; }
[dir="rtl"] .day-row.me { box-shadow: inset -3px 0 0 var(--brand); }
[dir="rtl"] .req .reason { font-style: normal; }
[dir="rtl"] .user-chip .who .dash { display: none; }
[dir="rtl"] .user-chip .who span { display: block; font-size: 11px; }
[dir="rtl"] .toast { text-align: start; }
/* wider day columns so the full weekday names fit */
[dir="rtl"] .mobile-ui, [dir="rtl"] { --cell: 60px; }
[dir="rtl"] .grid thead th { font-size: 12px; font-weight: 600; }
[dir="rtl"] .day-pill { width: 66px; font-size: 12px; }
[dir="rtl"] .segmented button, [dir="rtl"] .btn { white-space: nowrap; }

@keyframes sheet { from { opacity: 0; transform: translate(-50%, 24px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes sheet-up { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
