/* Employee portal (pages under /ess/). One small sheet for every page:
   no Bootstrap, no icon font. Phone first; the side menu appears from 900px. */
:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --ink: #171a2b;
  --muted: #646a82;
  --line: #e3e5ef;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --ok: #0f7a4d;
  --ok-soft: #e3f6ec;
  --warn: #9a5b00;
  --warn-soft: #fff3d9;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --info: #1d5fbf;
  --info-soft: #e6f0ff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(23, 26, 43, .06), 0 6px 20px rgba(23, 26, 43, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f111a;
    --card: #191c29;
    --ink: #eceef8;
    --muted: #9aa0b8;
    --line: #2a2e42;
    --accent: #8b85ff;
    --accent-ink: #0f111a;
    --accent-soft: #23254a;
    --ok: #5fd39a;
    --ok-soft: #153526;
    --warn: #f2b84b;
    --warn-soft: #3a2c0e;
    --bad: #ff8a80;
    --bad-soft: #401a17;
    --info: #8ab8ff;
    --info-soft: #162a4a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, dl, dd { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- cards, buttons, notices ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn[disabled] { opacity: .6; cursor: default; }
.btn.block { width: 100%; }
.btn.quiet { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.small svg { width: 18px; height: 18px; }
.btn.quiet.danger { background: transparent; color: var(--bad); }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); cursor: pointer; }
.iconbtn[disabled] { opacity: .4; cursor: default; }

.notice { border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--info-soft); color: var(--info); }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.plain { background: var(--line); color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.toast.bad { background: var(--bad); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 36px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- fields ---------- */
.field { margin-bottom: 14px; }
.field label, .field .label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field .control { position: relative; }
.field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea {
  width: 100%; min-height: 50px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink); /* 16px text: iOS does not zoom */
}
.field textarea { padding: 12px 14px; min-height: 92px; resize: vertical; }
.field input[type=file] { width: 100%; font-size: 14px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.field .peek { position: absolute; right: 4px; top: 4px; width: 42px; height: 42px; border: 0; background: none; color: var(--muted); border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.field .has-peek { padding-right: 50px !important; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 40px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

/* 1-5 rating: five large touch targets in a row */
.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: grid; place-items: center; height: 44px; border: 1px solid var(--line); border-radius: 10px; font-weight: 700; cursor: pointer; background: var(--card); }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- sign-in ---------- */
.signin { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.signin-box { width: 100%; max-width: 400px; }
.signin-brand { text-align: center; margin-bottom: 20px; }
.signin-brand img { height: 56px; max-width: 180px; object-fit: contain; }
.signin-brand h1 { font-size: 24px; margin-top: 12px; letter-spacing: -.01em; }
.signin-brand p { color: var(--muted); margin-top: 4px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 16px; font-size: 14px; }
.signin-foot { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }
.signin .notice { margin-bottom: 14px; }
.signin .notice .btn { margin-top: 10px; min-height: 42px; }

/* ---------- app shell ---------- */
.app { max-width: 1040px; margin: 0 auto; padding: 16px 16px 92px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; min-height: 48px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.big { width: 72px; height: 72px; font-size: 24px; }
.topbar h1 { font-size: 22px; line-height: 1.2; letter-spacing: -.01em; }
.topbar .grow { flex: 1; min-width: 0; }
.topbar .grow p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav a, .nav button { flex: 1; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; }
.nav a:hover { text-decoration: none; }
.nav .on { color: var(--accent); }
.nav .brand { display: none; }

.sheet-back { position: fixed; inset: 0; z-index: 30; background: rgba(10, 12, 24, .45); display: flex; align-items: flex-end; }
.sheet { width: 100%; background: var(--card); border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 92vh; max-height: 92dvh; overflow: auto; }
.sheet h2 { font-size: 18px; padding: 14px 0 12px; }
.sheet .notice { margin-bottom: 12px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: sticky; bottom: 0; background: var(--card); padding-top: 8px; }
.sheet-actions .btn:only-child { grid-column: 1 / -1; }
.sheet.menu { padding-left: 12px; padding-right: 12px; }
.sheet.menu h2 { font-size: 15px; padding: 12px 8px 6px; }
.sheet.menu a, .sheet.menu button { width: 100%; min-height: 50px; display: flex; align-items: center; gap: 14px; padding: 0 8px; border: 0; background: none; color: var(--ink); border-radius: 10px; cursor: pointer; text-align: left; }
.sheet.menu a:hover, .sheet.menu button:hover, .sheet.menu [aria-current] { background: var(--accent-soft); text-decoration: none; }
.sheet.menu .danger { color: var(--bad); }
.sheet img.receipt { display: block; max-width: 100%; border-radius: 12px; margin: 0 auto 12px; }

/* ---------- home ---------- */
.stack { display: grid; gap: 14px; }
.cols { display: grid; gap: 14px; }
.today { background: var(--accent); color: var(--accent-ink); border: 0; }
.today .label { font-size: 13px; opacity: .85; }
.today .state { font-size: 24px; font-weight: 700; letter-spacing: -.01em; margin: 2px 0 6px; }
.today .line { font-size: 14px; opacity: .9; }
.today .btn { margin-top: 14px; background: var(--accent-ink); color: var(--accent); min-height: 52px; font-size: 17px; }
.today .note { font-size: 13px; opacity: .85; margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .18); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat .k { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .k svg { width: 18px; height: 18px; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 6px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.stat .v.text { font-size: 16px; }
.stat .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
a.stat { color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--accent); }

.section-title { font-size: 14px; font-weight: 700; color: var(--muted); margin: 6px 2px -4px; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px; text-align: center; font-size: 13px; font-weight: 600; color: var(--ink); }
.action:hover { text-decoration: none; border-color: var(--accent); }
.action span.ico { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }

.skeleton { border-radius: var(--radius); background: var(--line); opacity: .6; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ---------- lists of requests ---------- */
.headrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.item .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.item .title { font-weight: 700; overflow-wrap: anywhere; }
.item .meta { font-size: 14px; color: var(--muted); margin-top: 2px; }
.item .text { font-size: 14px; margin-top: 8px; overflow-wrap: anywhere; white-space: pre-line; }
.item .amount { font-size: 18px; font-weight: 700; }
.item .foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.item .reply { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 14px; }

.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 10px 12px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 600; overflow-wrap: anywhere; }
.card > h2 { font-size: 15px; margin-bottom: 12px; }

/* ---------- attendance calendar ---------- */
.monthbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.monthbar h2 { font-size: 17px; text-align: center; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.tag b { font-size: 15px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal .d { aspect-ratio: 1; min-height: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 1px solid transparent; border-radius: 10px; background: none; font-weight: 600; font-size: 14px; cursor: pointer; padding: 0; }
.cal .d i { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.cal .d.present { background: var(--ok-soft); color: var(--ok); }
.cal .d.leave { background: var(--warn-soft); color: var(--warn); }
.cal .d.leave.asked { background: none; border: 1px dashed var(--warn); }
.cal .d.holiday { background: var(--info-soft); color: var(--info); }
.cal .d.open i { background: var(--bad); }
.cal .d.open.fixing i { background: var(--warn); }
.cal .d.today { border-color: var(--accent); }
.cal .d.sel { box-shadow: 0 0 0 2px var(--accent); }
.cal .d.later { color: var(--muted); font-weight: 400; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; }

/* ---------- payslip ---------- */
.slip-net { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.slip-net strong { font-size: 26px; letter-spacing: -.01em; }
.lines { display: grid; gap: 8px; font-size: 15px; }
.lines div { display: flex; justify-content: space-between; gap: 12px; }
.lines .total { border-top: 1px solid var(--line); padding-top: 8px; font-weight: 700; }
.payrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: inherit; width: 100%; text-align: left; cursor: pointer; }
.payrow:hover { border-color: var(--accent); text-decoration: none; }

@media (min-width: 620px) {
  .grid2 { grid-template-columns: repeat(4, 1fr); }
  .actions { grid-template-columns: repeat(6, 1fr); }
  .cols { grid-template-columns: 1fr 1fr; align-items: start; }
}

/* ---------- desktop: the bottom bar becomes a side menu ---------- */
@media (min-width: 900px) {
  .app { padding: 28px 28px 28px 248px; max-width: 1240px; }
  .nav { top: 0; right: auto; width: 220px; flex-direction: column; justify-content: flex-start; gap: 2px; padding: 18px 12px; border-top: 0; border-right: 1px solid var(--line); }
  .nav a, .nav button { flex: none; min-height: 46px; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
  .nav a:hover, .nav button:hover { background: var(--accent-soft); }
  .nav .on { background: var(--accent-soft); }
  .nav .brand { display: block; font-size: 16px; font-weight: 700; color: var(--ink); padding: 4px 12px 16px; }
  .sheet-back { align-items: center; justify-content: center; padding: 24px; }
  .sheet { max-width: 520px; border-radius: 20px; padding-bottom: 16px; }
  .sheet.menu { max-width: 380px; }
  .toast { bottom: 32px; }
  .cal .d { aspect-ratio: auto; height: 56px; }
}

/* ---------- a payslip on paper ---------- */
@media print {
  :root { --bg: #fff; --card: #fff; --ink: #000; --muted: #444; --line: #bbb; --shadow: none; }
  .nav, .noprint, .toast { display: none !important; }
  .app { padding: 0; max-width: none; }
  .card { break-inside: avoid; }
}
