/* TadbirHub: calm management-system look.
   Soft lavender canvas, white surfaces, violet→teal accent, light type (400–500). */
:root {
  --bg: #f6f6fb; --card: #fff; --ink: #14162b; --soft: #3d4159; --mute: #6b6f86; --line: #ebeaf3; --line2: #dedcec;
  --acc: #6d4dff; --acc2: #14b8a6; --accbg: #f1edff; --accink: #4b32c9;
  --grad: linear-gradient(100deg, #7c5cff 0%, #4f8bff 50%, #14b8a6 100%);
  --warn: #b45309; --warnbg: #fff4e0; --bad: #c0263b; --badbg: #ffe9ec; --ok: #0f8a5f; --okbg: #e3f7ee;
  --side: #ffffff; --r: 16px;
  --sh: 0 1px 2px rgba(20, 22, 43, .04), 0 10px 30px -18px rgba(48, 38, 120, .18);
  --sh-lg: 0 30px 70px -24px rgba(30, 24, 90, .35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); display: flex; min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--acc); cursor: pointer; }
h1 { font-size: 26px; font-weight: 400; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 15px; font-weight: 500; margin: 0 0 12px; letter-spacing: -.005em; }
h3 { font-weight: 500; }
b, strong { font-weight: 500; }
.mute { color: var(--mute); }
small { color: var(--mute); }

/* icons */
.ic { width: 1.15em; height: 1.15em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }

/* sidebar */
.side { width: 248px; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; gap: 11px; align-items: center; padding: 20px 18px 18px; }
.brand b { color: var(--ink); display: block; font-weight: 500; font-size: 15px; letter-spacing: -.01em; }
.logo.app { background: none; overflow: hidden; box-shadow: 0 8px 18px -10px #1e3a8a80; }
.logo.app img { width: 100%; height: 100%; display: block; }
.logo.img { background: #fff; border: 1px solid var(--line); overflow: hidden; padding: 2px; }
.logo.img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.logo-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-row .btn { margin-right: 6px; }
.logo-box { width: 96px; height: 96px; border: 1px dashed var(--line2); border-radius: 12px; display: grid; place-items: center; background: #fff; font-size: 11px; overflow: hidden; }
.logo-box img { max-width: 88px; max-height: 88px; object-fit: contain; }
.brand small { color: var(--mute); font-size: 12px; display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { width: 36px; height: 36px; border-radius: 11px; background: var(--grad); color: #fff; font-weight: 500; font-size: 13px; letter-spacing: .02em; display: grid; place-items: center; flex-shrink: 0; box-shadow: 0 8px 18px -8px #7c5cff; }
nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
nav a { display: flex; align-items: center; gap: 11px; color: var(--soft); text-decoration: none; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; position: relative; transition: background .15s, color .15s; }
nav a .ic { color: #9a9db3; transition: color .15s; }
nav a:hover { background: #f5f4fb; color: var(--ink); }
nav a:hover .ic { color: var(--soft); }
nav a.on { background: var(--accbg); color: var(--accink); font-weight: 500; }
nav a.on .ic { color: var(--acc); }
nav a.on::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad); }
.side-foot { margin-top: auto; padding: 14px; font-size: 12px; color: var(--mute); }

main { flex: 1; padding: 28px 32px 64px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin-bottom: 18px; box-shadow: var(--sh); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--sh); position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; left: 18px; right: 18px; top: 0; height: 2px; border-radius: 0 0 2px 2px; background: var(--grad); opacity: .55; }
.stat b { font-size: 28px; font-weight: 400; letter-spacing: -.02em; display: block; line-height: 1.2; }
.stat .mute { font-size: 12.5px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* controls */
button, .btn { font: inherit; font-size: 13.5px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line2); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s, box-shadow .15s, transform .15s; }
button:hover, .btn:hover { border-color: #c9c5e0; background: #fcfbff; }
button:active { transform: translateY(1px); }
button.pri { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 500; box-shadow: 0 10px 24px -12px #7c5cffbb, 0 0 0 1px #ffffff14 inset; }
button.pri:hover { background: #23264a; border-color: #23264a; box-shadow: 0 14px 30px -12px #7c5cffdd; }
button.danger { color: var(--bad); }
button.danger:hover { border-color: #f3b6bf; background: #fff7f8; }
button.sm { padding: 4px 10px; font-size: 12px; border-radius: 8px; gap: 5px; }
button:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }
input, select, textarea { font: inherit; border: 1px solid var(--line2); border-radius: 10px; padding: 8px 11px; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #b9a8ff; box-shadow: 0 0 0 4px #7c5cff1f; }
input[type=checkbox], input[type=radio] { accent-color: var(--acc); }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--mute); }
label.f > span { font-weight: 500; color: var(--soft); }
label.chk { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.multi { max-height: 160px; overflow: auto; border: 1px solid var(--line2); border-radius: 10px; padding: 8px 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 2px 8px; color: var(--ink); }
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: #efedf8; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; text-decoration: none; color: var(--mute); border-radius: 9px; font-size: 13px; transition: background .15s, color .15s; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { background: #fff; color: var(--ink); font-weight: 500; box-shadow: 0 4px 12px -6px #3026784d; }

/* tables */
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-size: 11px; color: var(--mute); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; background: #faf9fd; }
table.t tr:first-child th:first-child { border-top-left-radius: 10px; }
table.t tr:first-child th:last-child { border-top-right-radius: 10px; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: #fbfaff; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; background: #f0eff6; color: var(--soft); margin: 1px 2px 1px 0; white-space: nowrap; }
.tag .ic { width: 1em; height: 1em; }
.tag.ok { background: var(--okbg); color: var(--ok); }
.tag.warn { background: var(--warnbg); color: var(--warn); }
.tag.bad { background: var(--badbg); color: var(--bad); }
.tag.acc { background: var(--accbg); color: var(--accink); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.bar { height: 8px; background: var(--grad); border-radius: 99px; }
.notice { display: block; padding: 11px 14px; border-radius: 12px; background: var(--warnbg); color: #7a3e06; border: 1px solid #fde3b6; margin-bottom: 12px; font-size: 13px; }
.notice.info { background: linear-gradient(100deg, #f3efff, #e9fbf7); color: #3b2f8f; border-color: #ddd3ff; }
.notice .ic { margin-right: 4px; }
.ppki-frame { width: 100%; height: calc(100vh - 190px); min-height: 560px; border: 1px solid var(--line, #e7e6f2); border-radius: var(--r); background: #fff; }
.empty { padding: 34px; text-align: center; color: var(--mute); }

/* timetable grid */
.tt-wrap { overflow-x: auto; }
table.tt { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 760px; table-layout: fixed; }
table.tt th { font-size: 11px; color: var(--mute); font-weight: 500; padding: 4px; }
table.tt th.day { width: 70px; text-align: left; font-size: 13px; color: var(--ink); }
table.tt th small { display: block; font-weight: 400; }
table.tt td { height: 56px; background: #f6f5fb; border-radius: 10px; padding: 0; vertical-align: top; }
table.tt td.brk { background: repeating-linear-gradient(45deg, #efeef6, #efeef6 5px, #f7f6fb 5px, #f7f6fb 10px); width: 26px; }
table.tt col.brk { width: 26px; }
table.tt td.ok { background: var(--okbg); outline: 2px dashed #34c38f; }
table.tt td.no { background: #fafafa; }
.chip { height: 100%; min-height: 56px; border-radius: 10px; padding: 6px 8px; color: #fff; cursor: grab; position: relative; font-size: 12px; line-height: 1.25; overflow: hidden; box-shadow: inset 0 0 0 1px #ffffff26, 0 6px 14px -10px #000a; }
.chip b { font-size: 13px; display: block; }
.chip .lk { position: absolute; right: 4px; top: 4px; background: #00000026; border: 0; color: #fff; padding: 2px; border-radius: 6px; cursor: pointer; }
.chip .lk .ic { width: 12px; height: 12px; display: block; }
.chip.locked { box-shadow: inset 0 0 0 2px #0008; }
.chip.dragging { opacity: .4; }
.pool { display: flex; flex-wrap: wrap; gap: 6px; min-height: 60px; padding: 10px; border: 2px dashed var(--line2); border-radius: 14px; }
.pool.over { border-color: var(--acc); background: var(--accbg); }
.pool .chip { min-height: 44px; width: 120px; height: auto; }
table.master { border-collapse: collapse; font-size: 11px; }
table.master th, table.master td { border: 1px solid var(--line); padding: 2px 3px; text-align: center; min-width: 34px; }
table.master td.cl { text-align: left; font-weight: 500; white-space: nowrap; }
table.master th.dsep, table.master td.dsep { border-left: 2px solid #b4b1cc; }

/* teacher day grid */
table.td { border-collapse: separate; border-spacing: 3px; font-size: 11px; width: 100%; }
table.td th { color: var(--mute); font-weight: 500; padding: 3px; }
table.td td { padding: 4px 5px; border-radius: 6px; height: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
table.td td.nm { font-weight: 500; font-size: 12px; background: none; max-width: 170px; }
.c-free { background: var(--okbg); color: var(--ok); }
.c-teach { background: #efeef6; color: var(--soft); }
.c-relief { background: var(--accbg); color: var(--accink); font-weight: 500; }
.c-absent { background: var(--badbg); color: var(--bad); }
.c-break { background: none; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .dh { font-size: 11px; color: var(--mute); text-align: center; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.cal .d { min-height: 66px; background: #f6f5fb; border-radius: 10px; padding: 5px 7px; font-size: 11px; cursor: pointer; border: 1.5px solid transparent; transition: border-color .15s, background .15s; }
.cal .d:hover { background: #f0eefa; }
.cal .d.we { background: #f1f1f5; color: #a3a6b8; }
.cal .d.sel { border-color: var(--acc); background: #fff; }
.cal .d.today b { color: var(--acc); }
.cal .d .tag { font-size: 10px; padding: 0 6px; }

pre.wa { background: #effaf4; border: 1px solid #cdeedb; padding: 14px; border-radius: 14px; white-space: pre-wrap; font: 13px/1.55 ui-sans-serif, system-ui, sans-serif; max-height: 420px; overflow: auto; }
.why { font-size: 11px; color: var(--mute); }

/* modal & toast */
.modal { position: fixed; inset: 0; background: #14162b59; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-box { background: #fff; border-radius: 22px; padding: 24px; width: min(640px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--sh-lg); border: 1px solid #ffffffcc; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 99px; z-index: 60; font-size: 13px; box-shadow: 0 16px 36px -14px #14162bcc; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid #fff6; border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* signed-in user box */
.side-foot { display: flex; flex-direction: column; gap: 10px; }
.side-foot .who { padding: 12px; border-radius: 14px; background: #f7f6fc; border: 1px solid var(--line); }
.side-foot .who b { color: var(--ink); display: block; font-size: 13px; font-weight: 500; }
.side-foot .who small { color: var(--mute); font-size: 11.5px; }
.side-foot button { align-self: stretch; color: var(--soft); }
.bar-bg { height: 8px; background: #efedf6; border-radius: 99px; margin-top: 10px; overflow: hidden; }
tr.off td, .rph-row.off { opacity: .5; }

/* auth screen (restyled further in auth.css) */
body.auth .side, body.auth main { display: none; }
#authView:empty { display: none; }
body.auth #authView { flex: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-wrap { display: grid; grid-template-columns: 1fr 440px; gap: 48px; align-items: center; width: min(1000px, 100%); }
.auth-side .brand { padding: 0; border: 0; margin-bottom: 28px; }
.auth-side h1 { font-size: 34px; font-weight: 300; line-height: 1.2; margin-bottom: 12px; }
.auth-side ul { padding-left: 18px; line-height: 1.9; }
.auth-card { margin: 0; padding: 22px; }
.auth-form { display: grid; gap: 12px; }
.auth-form > button.pri { padding: 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.seg label { border: 1px solid var(--line2); border-radius: 12px; padding: 9px 10px; cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--ink); font-size: 13px; }
.seg label small { flex-basis: 100%; padding-left: 22px; }
.seg label:has(input:checked) { border-color: var(--acc); background: var(--accbg); }
.demo-box { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.demo-box p { font-size: 12px; margin: 4px 0 10px; }
.demo-list { display: grid; gap: 6px; }
.demo-list button { text-align: left; display: flex; flex-direction: column; align-items: flex-start; }
.demo-list small { font-size: 11px; }
.join-code { font: 500 24px/1 ui-monospace, Consolas, monospace; letter-spacing: .18em; padding: 10px 16px; background: var(--accbg); color: var(--accink); border-radius: 12px; border: 1px dashed #c9bcff; }

/* RPH & RPT */
.rph-day { padding: 16px 18px; }
.rph-row { display: grid; grid-template-columns: 190px 1fr auto auto; gap: 12px; align-items: center; padding: 11px 10px; border-top: 1px solid var(--line); cursor: pointer; border-radius: 10px; transition: background .15s; }
.rph-row:hover { background: #faf9ff; }
.rph-row .tm { font-size: 12px; color: var(--mute); }
.rph-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.modal-box textarea, .modal-box input { width: 100%; }
.modal-box textarea:disabled, .modal-box input:disabled { background: #f8f7fc; color: var(--ink); }
.modal-box { width: min(760px, 100%); }
.rpt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.rpt-card { cursor: pointer; margin: 0; transition: border-color .15s, transform .15s, box-shadow .15s; }
.rpt-card:hover { border-color: #cfc4ff; transform: translateY(-2px); box-shadow: 0 18px 40px -22px #6d4dff66; }
.rpt-table td { padding: 4px; }
.rpt-table textarea { width: 100%; min-width: 130px; font-size: 13px; resize: vertical; }
.rpt-table tr.now td { background: var(--accbg); }

@media (max-width: 800px) {
  .auth-wrap { grid-template-columns: 1fr; gap: 20px; }
  .auth-side ul, .auth-side p { display: none; }
  .rph-row { grid-template-columns: 1fr auto; }
  .rph-row .tm { grid-column: 1 / -1; }
  body { flex-direction: column; }
  .side { width: 100%; height: auto; position: sticky; z-index: 20; border-right: 0; border-bottom: 1px solid var(--line); background: #ffffffe6; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
  .brand { padding: 12px 16px 6px; }
  nav { flex-direction: row; overflow-x: auto; padding: 4px 10px 8px; scrollbar-width: none; }
  nav a { padding: 9px 11px; }
  nav a .ic { width: 20px; height: 20px; }
  nav a span { display: none; }
  nav a.on::before { left: 10px; right: 10px; top: auto; bottom: 0; width: auto; height: 2px; border-radius: 2px; }
  .side-foot { position: absolute; top: 10px; right: 12px; padding: 0; flex-direction: row; align-items: center; }
  .side-foot .who { display: none; }
  .side-foot button { padding: 4px 10px; }
  main { padding: 18px 16px 48px; }
  h1 { font-size: 22px; }
}
@media print {
  .side, .noprint, .tabs, button { display: none !important; }
  main { padding: 0; }
  .card { border: 0; padding: 0; box-shadow: none; }
  table.tt td { border: 1px solid #ccc; }
  .chip { color: #000 !important; background: #fff !important; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Google Classroom (js/ui-gc.js) ---------- */
.gc-steps { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.gc-steps span { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--mute); padding: 4px 12px 4px 4px; border-radius: 99px; background: #f3f2f8; }
.gc-steps i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #fff; font-size: 11px; }
.gc-steps i .ic { width: 12px; height: 12px; }
.gc-steps span.on { background: var(--accbg); color: var(--accink); font-weight: 500; }
.gc-steps span.on i { background: var(--grad); color: #fff; }
.gc-steps span.done { color: var(--ok); }
.gc-box { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; font-size: 14px; line-height: 1.55; background: #fcfbff; }
.gc-howto { margin: 14px 0 10px; padding-left: 20px; font-size: 13px; line-height: 1.75; color: var(--soft); }
.gc-sim { border: 1px dashed #a9c4ff; background: #f2f6ff; border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.gc-done { text-align: center; padding: 10px 0 6px; }
.gc-done h3 { margin: 10px 0 4px; }
.gc-tick { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center; background: var(--okbg); color: var(--ok); }
.gc-tick .ic { width: 28px; height: 28px; }
.gc-list { display: grid; gap: 6px; max-height: 360px; overflow: auto; }
.gc-list button { text-align: left; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 11px 14px; }
.gc-list small { color: var(--mute); }
.gc-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 13px; }
.gc-pick > span { width: 110px; color: var(--mute); }
.gc-pick > b { flex: 1; min-width: 200px; font-weight: 500; }
