:root {
  --bg: #f7f3ec; --paper: #fffdf9; --ink: #1d2a2c; --muted: #6b7a7c; --line: #e6dfd2;
  --teal: #1d6b6b; --teal-d: #14504f; --gold: #b88a3b; --amber: #c98a1b; --red: #b3453a; --green: #2f7d52;
  --c0: #1d6b6b; --c1: #7a4e9c; --c2: #b3643a; --c3: #2f6fa5; --c4: #8a7a1d; --c5: #a2456e;
  --r: 14px; --shadow: 0 1px 2px rgba(29, 42, 44, .06), 0 6px 20px rgba(29, 42, 44, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 'Tajawal', system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.3; }
h3 { font-size: 1rem; color: var(--teal-d); }
.h { font-size: 1.4rem; margin: .4rem 0 1rem; }
.muted { color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem 0; }
[hidden] { display: none !important; }

/* shell */
header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .6rem 1rem; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: .6rem; } .brand small { display: block; color: var(--muted); font-size: .75rem; line-height: 1.2; }
.logo { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--teal); color: #fff; font-weight: 700; font-size: 1.5rem; margin: 0 auto .6rem; }
.logo.sm { width: 38px; height: 38px; border-radius: 11px; font-size: 1.05rem; margin: 0; }
nav { display: flex; gap: .2rem; flex: 1; overflow-x: auto; }
nav button { position: relative; border: 0; background: none; padding: .5rem .9rem; border-radius: 10px; color: var(--muted); white-space: nowrap; }
nav button.on { background: #e6f0ee; color: var(--teal-d); font-weight: 700; }
.dot { position: absolute; top: 6px; inset-inline-end: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); }
.who { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: var(--muted); }
main { max-width: 1280px; margin: 0 auto; padding: 1rem; }

/* controls */
.btn { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: .45rem 1rem; transition: .15s; }
.btn:hover { border-color: var(--teal); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 500; }
.btn.primary:hover { background: var(--teal-d); }
.btn.primary.ghost { background: #e6f0ee; color: var(--teal-d); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger.ghost { background: none; color: var(--red); border-color: #e3c3bf; }
.btn.small { padding: .2rem .7rem; font-size: .85rem; } .btn.wide { width: 100%; margin-top: .6rem; }
.icon { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; width: 36px; height: 36px; font-size: 1.3rem; line-height: 1; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: .5rem .7rem; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .7rem; } label input, label select, label textarea { margin-top: .25rem; color: var(--ink); }
label.check { display: flex; gap: .5rem; align-items: center; color: var(--ink); } label.check input { width: auto; margin: 0; }
.err { color: var(--red); margin: .4rem 0; } .hint { margin: -.3rem 0 .6rem; color: var(--muted); font-size: .85rem; } .hint.bad { color: var(--red); }
.actions { display: flex; gap: .5rem; margin-top: .8rem; } .actions.wrap { flex-wrap: wrap; }
.row3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: .6rem; } .row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--paper); }
.seg button { border: 0; background: none; padding: .4rem .9rem; } .seg button.on { background: var(--teal); color: #fff; }

/* login */
.login { display: grid; place-items: center; min-height: 100vh; }
.login .panel { width: min(380px, 92vw); text-align: center; padding: 2rem; } .login label { text-align: start; }
.panel, .card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 1rem 1.2rem; }
.panel.narrow { max-width: 420px; }

/* dashboard */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin-bottom: .8rem; }
.card { text-align: start; } .card small { display: block; color: var(--muted); } .card b { font-size: 2rem; color: var(--teal-d); }
.card.alert { border-color: var(--amber); background: #fff7e8; } .card.alert b { color: var(--amber); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: .8rem; }
.bars { display: flex; gap: .6rem; align-items: flex-end; height: 190px; padding-top: 1.4rem; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: .8rem; }
.bar i { display: block; width: 70%; background: linear-gradient(var(--teal), #4f9a95); border-radius: 8px 8px 0 0; min-height: 2px; } .bar .v { font-weight: 700; } .bar small { color: var(--muted); font-size: .7rem; }
.list, .log { list-style: none; margin: 0; padding: 0; }
.list button { display: grid; width: 100%; text-align: start; border: 0; background: none; padding: .5rem .2rem; border-bottom: 1px solid var(--line); } .list span, .list small { color: var(--muted); font-size: .85rem; }
.log li { padding: .35rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; } .log small { display: block; color: var(--muted); }
table { width: 100%; border-collapse: collapse; } td, th { padding: .55rem .6rem; text-align: start; border-bottom: 1px solid var(--line); }
table.rows { background: var(--paper); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); } .rows th { background: #efe9dd; font-size: .85rem; color: var(--muted); }
.rows tr[data-id] { cursor: pointer; } .rows tr[data-id]:hover { background: #f4efe4; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .8rem; } .filters select { width: auto; }
.add-user { margin-bottom: 1rem; } .add-user .btn { margin-top: .2rem; }
.pw { font: 700 1.8rem/1 ui-monospace, monospace; background: #f1ece0; border-radius: 10px; padding: .8rem; text-align: center; letter-spacing: .1em; }

/* requests */
.reqs { display: grid; gap: .7rem; } .req { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; background: var(--paper); border: 1px solid var(--line); border-inline-start: 5px solid var(--amber); border-radius: var(--r); padding: .8rem 1rem; }
.req.rejected { border-inline-start-color: var(--red); } .req p { margin: .1rem 0; }
.badge { display: inline-block; font-size: .75rem; padding: .05rem .6rem; border-radius: 99px; background: #e6f0ee; color: var(--teal-d); }
.badge.pending { background: #fdf0d4; color: #8a5a00; } .badge.rejected, .badge.cancelled { background: #f6dcd8; color: var(--red); } .badge.block { background: #e8e8e8; color: #555; }

/* calendar */
.cal-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .6rem; } .cal-title { min-width: 220px; text-align: center; } .cal-nav input[type=date] { width: auto; } .cal-nav .primary { margin-inline-start: auto; }
.legend { display: flex; gap: .8rem; align-items: center; font-size: .8rem; color: var(--muted); margin-bottom: .5rem; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; margin-inline-end: -.4rem; background: var(--teal); }
.legend i.pending { background: repeating-linear-gradient(45deg, #fdf0d4, #fdf0d4 4px, #f5d58b 4px, #f5d58b 8px); border: 1px dashed var(--amber); }
.legend i.block { background: repeating-linear-gradient(45deg, #ddd, #ddd 4px, #ccc 4px, #ccc 8px); }
.grid-wrap { overflow: auto; max-height: calc(100vh - 220px); min-height: 360px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: 70px repeat(6, minmax(120px, 1fr)); min-width: 860px; }
.col { border-inline-start: 1px solid var(--line); } .col.times { position: sticky; inset-inline-start: 0; z-index: 6; background: var(--paper); border: 0; }
.dh { position: sticky; top: 0; z-index: 5; height: 48px; background: #efe9dd; text-align: center; font-weight: 700; padding-top: .3rem; line-height: 1.2; } .dh small { display: block; font-weight: 400; color: var(--muted); }
.col.today .dh { background: var(--teal); color: #fff; } .col.today .dh small { color: #dff; }
.col .body { position: relative; } .tl { font-size: .72rem; color: var(--muted); text-align: center; padding-top: 2px; }
.cell { border-top: 1px dashed #efe9dd; cursor: cell; } .cell.hr { border-top: 1px solid var(--line); } .cell:hover { background: #e6f0ee; }
.col.past .cell { background: #f4f0e8; cursor: default; }
.bk { position: absolute; inset-inline: 3px; border: 0; border-inline-start: 4px solid var(--tc); background: color-mix(in srgb, var(--tc) 16%, #fff); border-radius: 8px; padding: 2px 6px; text-align: start; overflow: hidden; z-index: 2; font-size: .8rem; line-height: 1.25; }
.bk b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .bk small { display: block; color: var(--muted); font-size: .72rem; }
.bk.pending, .chip.pending { background: repeating-linear-gradient(45deg, #fff8e6, #fff8e6 6px, #fbe6b0 6px, #fbe6b0 12px); border: 1px dashed var(--amber); border-inline-start: 4px solid var(--amber); }
.bk.block, .chip.block { background: repeating-linear-gradient(45deg, #eee, #eee 6px, #d9d9d9 6px, #d9d9d9 12px); border-inline-start-color: #888; color: #444; }
.month { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.mh { background: #efe9dd; text-align: center; padding: .4rem; font-weight: 700; font-size: .9rem; } .mc { background: var(--paper); min-height: 110px; padding: .3rem; } .mc.off { background: #f4f0e8; opacity: .65; } .mc.today { box-shadow: inset 0 0 0 2px var(--teal); }
.dn { border: 0; background: none; font-weight: 700; color: var(--teal-d); } .chip { display: block; width: 100%; text-align: start; border: 0; border-inline-start: 3px solid var(--tc); background: color-mix(in srgb, var(--tc) 15%, #fff); border-radius: 6px; padding: 0 5px; margin-top: 2px; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more { border: 0; background: none; color: var(--teal); font-size: .75rem; }

/* dialogs */
.modal { border: 0; border-radius: 18px; padding: 1.3rem; width: min(520px, 94vw); max-height: 92vh; background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal::backdrop { background: rgba(20, 30, 30, .45); }
.conflicts { background: #fdecea; border-radius: 10px; padding: .6rem .9rem; font-size: .9rem; } .conflicts ul { margin: .3rem 0; padding-inline-start: 1.2rem; }
.details dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: .6rem 0; } .details dt { color: var(--muted); } .details dd { margin: 0; }
#toast { position: fixed; bottom: 1.2rem; inset-inline: 0; margin: 0 auto; width: fit-content; max-width: 92vw; background: var(--ink); color: #fff; padding: .6rem 1.2rem; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s; z-index: 100; transform: translateY(10px); }
#toast.show { opacity: 1; transform: none; } #toast.bad { background: var(--red); }

@media (max-width: 760px) {
  .two, .row4 { grid-template-columns: 1fr; } .row3 { grid-template-columns: 1fr 1fr; } .row3 label:first-child { grid-column: 1 / -1; }
  .who { margin-inline-start: auto; } .cal-title { min-width: 0; flex: 1 0 100%; order: -1; } .cal-nav .primary { margin: 0; }
  table.rows { font-size: .85rem; } .rows th:nth-child(4), .rows td:nth-child(4) { display: none; }
  .mc { min-height: 70px; } .chip { font-size: .62rem; } main { padding: .6rem; }
}

/* multi-day pattern */
.pattern { background: #f4efe4; border-radius: 12px; padding: .7rem .8rem .2rem; margin-bottom: .7rem; }
.days { display: flex; flex-wrap: wrap; gap: .2rem .9rem; margin-bottom: .6rem; }
.addrow { display: flex; gap: .5rem; margin-bottom: .6rem; align-items: center; } .addrow input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .4rem; max-height: 150px; overflow: auto; }
.chip2 { display: inline-flex; align-items: center; gap: .3rem; background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: .05rem .2rem .05rem .7rem; font-size: .82rem; }
.chip2 button { border: 0; background: #ecdcd9; color: var(--red); border-radius: 50%; width: 20px; height: 20px; line-height: 1; }
.grid, .cell { user-select: none; -webkit-user-select: none; } .cell.sel { background: #b7dad5; }

@media print {
  header, .cal-nav, .legend, #toast, nav { display: none !important; }
  body { background: #fff; } main { max-width: none; padding: 0; }
  .grid-wrap { max-height: none; overflow: visible; box-shadow: none; border: 0; }
  .bk { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.opt { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 12px; margin-top: .5rem; background: #fff; } .opt p { margin: 0; }
.results { margin-top: .6rem; max-height: 40vh; overflow: auto; } details { margin: .4rem 0 .6rem; } summary { cursor: pointer; color: var(--teal-d); }
a.btn { text-decoration: none; display: inline-block; }
