:root {
  --bg: #f7f3f0; --card: #ffffff; --ink: #2b2226; --muted: #7d7177; --line: #e8e0db;
  --brand: #5b3a48; --brand-ink: #ffffff; --brand-soft: #efe5ea;
  --ok: #2f7d4f; --ok-soft: #e3f3e8; --bad: #b3364a; --bad-soft: #fbe6e9; --wait: #9a6a00; --wait-soft: #fbf1d9;
  --radius: 14px; --shadow: 0 1px 2px rgba(43, 34, 38, .06), 0 4px 16px rgba(43, 34, 38, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18141a; --card: #231d24; --ink: #f1eaee; --muted: #a99ca4; --line: #362d37;
    --brand: #c69ab0; --brand-ink: #1c1418; --brand-soft: #3a2a33;
    --ok: #7fd3a0; --ok-soft: #1f3a2a; --bad: #f08c9b; --bad-soft: #43242a; --wait: #f0c66b; --wait-soft: #3d3220;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; margin: .5rem 0; }
h3 { font-size: 1rem; margin: 0 0 .75rem; }
a { color: var(--brand); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.bad { color: var(--bad); }
.r { text-align: right; }
.pad { padding: 24px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }

/* Butang */
.btn { appearance: none; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); border-radius: 10px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; display: inline-block; text-align: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.ghost.bad { color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 5px 11px; font-size: .85rem; }
.btn.big { padding: 14px 22px; font-size: 1.05rem; flex: 1; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.full { grid-column: 1 / -1; }
.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; font-size: .9rem; }
.link.bad { color: var(--bad); }

/* Brand */
.brand { font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; letter-spacing: .18em; font-weight: 700; color: var(--brand); }
.brand span { font-family: inherit; letter-spacing: .05em; font-size: .8em; color: var(--muted); font-weight: 400; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border-radius: var(--radius); padding: 28px 24px; box-shadow: var(--shadow); }
.auth-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.auth-links { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; font-size: .9rem; }
.notice { background: var(--brand-soft); padding: 10px 12px; border-radius: 10px; font-size: .9rem; }

/* Rangka */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--card); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; }
.side .brand { padding: 0 10px 18px; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink); }
.side nav a i { font-style: normal; width: 20px; text-align: center; color: var(--muted); }
.side nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side nav a.on i { color: var(--brand); }
.badge { margin-left: auto; background: var(--bad); color: #fff; border-radius: 999px; font-size: .75rem; padding: 0 7px; }
.badge:empty { display: none; }
.side-foot { border-top: 1px solid var(--line); padding: 12px 10px 0; display: flex; flex-direction: column; gap: 8px; }
.who { font-size: .85rem; color: var(--muted); }
.topbar, .bottom { display: none; }
main { padding: 28px 32px 48px; max-width: 1100px; width: 100%; }

/* Kad & susun atur */
.card { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin: 16px 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 16px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.head h3 { margin: 0; }
.card .head { margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--ink); display: flex; flex-direction: column; }
.stat b { font-size: 1.6rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.warn b { color: var(--bad); }
.warnbox { border-left: 4px solid var(--bad); }
.clock { display: flex; flex-direction: column; gap: 14px; }
.clock .row { flex-wrap: wrap; }

/* Jadual & senarai */
.table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
th.r, td.r { text-align: right; }
table.mini td { padding: 6px 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--brand-soft); }
.list { list-style: none; margin: 0 0 8px; padding: 0; }
.list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list li .muted { font-size: .85rem; }
.appr > div:first-child { flex: 1; min-width: 220px; }
.docs { list-style: none; margin: 0; padding: 0; }
.docs li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.docs li:last-child { border-bottom: 0; }
.ann { padding: 10px 0; border-bottom: 1px solid var(--line); }
.ann:last-child { border-bottom: 0; }
.ann p { margin: 4px 0; white-space: pre-wrap; }
.sched { padding: 8px 0; border-bottom: 1px solid var(--line); }
dl { display: grid; grid-template-columns: 42% 1fr; gap: 6px 12px; margin: 0; }
dt { color: var(--muted); font-size: .88rem; }
dd { margin: 0; word-break: break-word; }

.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.pill.pending { background: var(--wait-soft); color: var(--wait); }
.pill.approved { background: var(--ok-soft); color: var(--ok); }
.pill.rejected { background: var(--bad-soft); color: var(--bad); }
.pill.cancelled { background: var(--line); color: var(--muted); }

/* Kalendar */
.calhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.legend { display: flex; gap: 8px; margin-bottom: 10px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dow { font-size: .75rem; color: var(--muted); text-align: center; padding: 4px 0; }
.day { min-height: 78px; border: 1px solid var(--line); border-radius: 8px; padding: 4px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.day span { font-size: .8rem; color: var(--muted); }
.day.today { border-color: var(--brand); }
.day.today span { color: var(--brand); font-weight: 700; }
.day.empty { border: 0; }
.ev { font-style: normal; font-size: .7rem; border-radius: 4px; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.hol { background: var(--bad-soft); color: var(--bad); }
.ev.evt { background: var(--brand-soft); color: var(--brand); }
.ev.lv { background: var(--wait-soft); color: var(--wait); }

/* Borang & modal */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: .88rem; }
.field span { color: var(--muted); }
.field.full, .check.full { grid-column: 1 / -1; }
input, select, textarea { font: inherit; font-size: 16px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { width: auto; }
.head input { width: auto; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: .92rem; }
.modal-bg { position: fixed; inset: 0; background: rgba(20, 14, 18, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--card); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; }
.modal .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: calc(100% - 32px); font-size: .92rem; }
.toast.bad { background: var(--bad); color: #fff; }

/* Telefon */
@media (max-width: 760px) {
  .shell { display: block; }
  .side { display: none; position: fixed; inset: 0; z-index: 40; height: auto; width: 100%; }
  .shell.menu-open .side { display: flex; }
  .topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .topbar .brand { font-size: 1.1rem; }
  main { padding: 16px 16px 96px; }
  .bottom { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); z-index: 30; }
  .bottom a { display: flex; flex-direction: column; align-items: center; font-size: .7rem; color: var(--muted); }
  .bottom a i { font-style: normal; font-size: 1.15rem; }
  .bottom a.on { color: var(--brand); font-weight: 600; }
  .stats { grid-template-columns: 1fr 1fr; }
  .card { padding: 16px; }
  .modal .grid { grid-template-columns: 1fr; }
  .day { min-height: 54px; }
  .ev { font-size: .6rem; }
  dl { grid-template-columns: 1fr; gap: 0; }
  dd { margin-bottom: 8px; }
}

/* Slip gaji */
.payslip { max-width: 760px; }
.ps-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--brand); padding-bottom: 12px; margin-bottom: 12px; }
.ps-info { grid-template-columns: 30% 1fr; margin-bottom: 16px; font-size: .9rem; }
.ps-cols { gap: 0 24px; }
tr.tot td { font-weight: 700; border-top: 2px solid var(--line); }
.ps-net { display: flex; justify-content: space-between; align-items: center; background: var(--brand-soft); color: var(--brand); border-radius: 10px; padding: 12px 16px; margin: 16px 0; font-size: 1.1rem; }
.ps-net b { font-size: 1.4rem; }
@media print {
  .side, .topbar, .bottom, .noprint, .toast { display: none !important; }
  .shell { display: block; }
  main { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { box-shadow: none; margin: 0; }
  .payslip { max-width: none; }
}
.reminder { display: block; background: var(--wait-soft); color: var(--wait); border-left: 4px solid var(--wait); font-weight: 600; }
.ok { color: var(--ok); }
