:root {
  --brand: #0f5f8c; --brand-dark: #0b4a6e; --brand-soft: #dcecf6;
  --bg: #f4f6f8; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --red: #dc2626; --red-soft: #fee2e2; --amber: #b45309; --amber-soft: #fef3c7;
  --green: #15803d; --green-soft: #dcfce7; --blue: #1d4ed8; --blue-soft: #dbeafe;
  --purple: #6d28d9; --purple-soft: #ede9fe;
  --radius: 10px; --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .nowrap { white-space: nowrap; } .bold { font-weight: 600; }
.red-t { color: var(--red); } .green-t { color: var(--green); } .amber-t { color: var(--amber); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: .8rem; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid-lists { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; margin-top: 1rem; }
.grid-lists .card + .card { margin-top: 0; }

/* buttons & inputs */
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); padding: .5rem .9rem; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
button:hover, .btn:hover { border-color: #cbd5e1; background: #f9fafb; }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.danger { color: var(--red); border-color: #fecaca; }
.danger:hover { background: var(--red-soft); }
.danger-fill { background: var(--red); border-color: var(--red); color: #fff; }
.danger-fill:hover { background: #b91c1c; border-color: #b91c1c; }
.ok-fill { background: var(--green); border-color: var(--green); color: #fff; }
.ok-fill:hover { background: #166534; }
.wa { background: #16a34a; border-color: #16a34a; color: #fff; }
.sm { padding: .3rem .6rem; font-size: .85rem; }
.lg { padding: .75rem 1.3rem; font-size: 1.05rem; }
button:disabled { opacity: .55; cursor: default; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea { font: inherit; width: 100%; padding: .5rem .65rem; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: .75rem; }
.check { display: flex; gap: .5rem; align-items: flex-start; color: var(--text); font-size: .95rem; margin-bottom: .6rem; }
.check input, input[type=checkbox], input[type=radio] { width: auto; margin-top: .2rem; }
.err { color: var(--red); font-size: .9rem; min-height: 1.2em; }
.req::after { content: ' *'; color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 .8rem; }
.form-grid .full { grid-column: 1 / -1; }
fieldset { border: 1px dashed #cbd5e1; border-radius: 8px; padding: .8rem; margin: .2rem 0 .8rem; }
legend { font-size: .85rem; color: var(--muted); padding: 0 .3rem; }

/* cards & tables */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid + .card, .card + .grid, .grid + .grid-lists { margin-top: 1rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f9fafb; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f9fafb; }
tfoot td { font-weight: 700; background: #f9fafb; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }

/* chips & tabs */
.chip { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #f3f4f6; color: #374151; white-space: nowrap; }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.purple { background: var(--purple-soft); color: var(--purple); }
.chip.gray { background: #f3f4f6; color: #4b5563; }
.chip.brand { background: var(--brand-soft); color: var(--brand-dark); }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs button { border-radius: 999px; padding: .35rem .8rem; font-size: .9rem; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs .count { background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 .4rem; font-size: .78rem; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }

/* layout */
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: .55rem 1rem; display: flex; align-items: center; gap: 1rem; }
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; white-space: nowrap; }
.logo { width: 28px; height: 28px; border-radius: 7px; background: #fff; display: grid; place-items: center; flex: none; }
.logo svg { width: 18px; height: 18px; }
.nav { display: flex; gap: .2rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { color: #dcecf6; text-decoration: none; padding: .4rem .65rem; border-radius: 7px; white-space: nowrap; font-size: .93rem; }
.nav a.on, .nav a:hover { background: rgba(255,255,255,.16); color: #fff; }
.topbar .who { font-size: .85rem; color: #dcecf6; white-space: nowrap; }
.topbar button { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.topbar button:hover { background: rgba(255,255,255,.12); }
main { max-width: 1240px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.page-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.warn-banner { background: var(--amber-soft); color: var(--amber); padding: .6rem 1rem; text-align: center; font-size: .9rem; }
.back { text-decoration: none; font-size: .9rem; display: inline-block; margin-bottom: .5rem; }

/* dashboard */
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; text-decoration: none; color: var(--text); display: block; box-shadow: var(--shadow); }
a.tile:hover { border-color: var(--brand); }
.tile .n { font-size: 1.6rem; font-weight: 700; line-height: 1.15; }
.tile .l { color: var(--muted); font-size: .85rem; }
.tile .s { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.tile.red .n { color: var(--red); } .tile.amber .n { color: var(--amber); } .tile.green .n { color: var(--green); } .tile.brand .n { color: var(--brand); } .tile.blue .n { color: var(--blue); }
.list-row { display: flex; gap: .6rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: #f9fafb; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--brand); border-radius: 99px; }
.cat-line { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr auto; gap: .6rem; align-items: center; padding: .3rem 0; font-size: .9rem; }
.trend { display: flex; align-items: flex-end; gap: .5rem; height: 120px; padding-top: .5rem; }
.trend div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: .75rem; color: var(--muted); gap: .2rem; }
.trend span.b { width: 100%; max-width: 46px; background: var(--brand-soft); border-radius: 6px 6px 0 0; min-height: 2px; }
.trend div.cur span.b { background: var(--brand); }

/* staff */
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; font-size: .9rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.5rem; }
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.staff-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow); display: flex; gap: .7rem; text-decoration: none; color: var(--text); }
.staff-card:hover { border-color: var(--brand); }
.staff-card .nm { font-weight: 600; }
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .1rem 1rem; margin: 0; }
.details div { padding: .4rem 0; border-bottom: 1px solid #f3f4f6; }
.details dt { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.details dd { margin: 0; font-weight: 500; word-break: break-word; }
.details dd.none { color: #d1d5db; font-weight: 400; }
.section-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; flex-wrap: wrap; }
.section-head h2 { margin: 0; flex: 1; font-size: 1.1rem; }

/* attendance */
.att-row { display: flex; gap: .7rem; align-items: center; padding: .55rem .2rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.att-row:last-child { border-bottom: 0; }
.att-row .who { flex: 1; min-width: 160px; }
.att-btns { display: flex; gap: .25rem; flex-wrap: wrap; }
.att-btns button { padding: .3rem .55rem; font-size: .82rem; font-weight: 600; min-width: 40px; justify-content: center; }
.att-btns button.on.P { background: var(--green); border-color: var(--green); color: #fff; }
.att-btns button.on.A { background: var(--red); border-color: var(--red); color: #fff; }
.att-btns button.on.H { background: var(--amber); border-color: var(--amber); color: #fff; }
.att-btns button.on.PL, .att-btns button.on.UL { background: var(--purple); border-color: var(--purple); color: #fff; }
.att-btns button.on.WO, .att-btns button.on.HO { background: #64748b; border-color: #64748b; color: #fff; }
.att-times { display: flex; gap: .3rem; }
.att-times input { width: 105px; padding: .3rem .4rem; font-size: .85rem; }
.reg { font-size: .8rem; }
.reg th, .reg td { padding: .3rem .25rem; text-align: center; border: 1px solid #eef0f3; }
.reg td.nm, .reg th.nm { text-align: left; position: sticky; left: 0; background: #fff; min-width: 130px; z-index: 1; }
.reg th.nm { background: #f9fafb; }
.reg th.wk { color: #94a3b8; }
.reg td.c { cursor: pointer; font-weight: 700; min-width: 30px; }
.reg td.c:hover { outline: 2px solid var(--brand); }
.c-P { background: var(--green-soft); color: var(--green); }
.c-A { background: var(--red-soft); color: var(--red); }
.c-H { background: var(--amber-soft); color: var(--amber); }
.c-PL, .c-UL { background: var(--purple-soft); color: var(--purple); }
.c-WO, .c-HO { background: #f1f5f9; color: #64748b; }
.c-na { background: repeating-linear-gradient(45deg, #fafafa, #fafafa 3px, #f0f0f0 3px, #f0f0f0 6px); }
.legend { display: flex; gap: .4rem; flex-wrap: wrap; font-size: .8rem; margin: .6rem 0; }
.legend span { padding: .1rem .45rem; border-radius: 5px; }
.checkin { text-align: center; padding: 1.3rem 1rem; }
.checkin .time { font-size: 2.2rem; font-weight: 700; color: var(--brand); }

/* tasks */
.task-list { display: grid; gap: .6rem; }
.task { background: #fff; border: 1px solid var(--line); border-left: 4px solid #94a3b8; border-radius: var(--radius); padding: .7rem .9rem; box-shadow: var(--shadow); cursor: pointer; display: grid; gap: .3rem; }
.task:hover { border-color: var(--brand); }
.task.p-Urgent { border-left-color: var(--red); } .task.p-High { border-left-color: #f97316; } .task.p-Normal { border-left-color: var(--brand); } .task.p-Low { border-left-color: #94a3b8; }
.task.done { opacity: .7; } .task.done .t { text-decoration: line-through; }
.task .t { font-weight: 600; }
.task .m { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; font-size: .84rem; color: var(--muted); }
.updates { border-left: 2px solid var(--line); margin-left: .4rem; padding-left: .9rem; }
.updates div { margin-bottom: .7rem; font-size: .9rem; }
.updates .when { font-size: .78rem; color: var(--muted); }

/* business picker */
.biz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.biz { border: 2px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; cursor: pointer; background: #fff; display: flex; gap: .6rem; align-items: flex-start; text-align: left; white-space: normal; }
.biz:hover { border-color: #9cc3dd; background: #fff; }
.biz.on { border-color: var(--brand); background: #f0f7fc; }
.biz .ic { font-size: 1.6rem; line-height: 1; }
.biz b { display: block; font-size: .93rem; }
.biz small { color: var(--muted); font-size: .8rem; }
.setup-wrap { max-width: 860px; margin: 4vh auto; padding: 0 1rem; }
.login-wrap { max-width: 400px; margin: 8vh auto; padding: 0 1rem; }
.logo-big { width: 56px; height: 56px; border-radius: 14px; background: var(--brand); display: grid; place-items: center; margin: 0 auto 1rem; }
.logo-big svg { width: 32px; height: 32px; }
.hero-title { text-align: center; margin-bottom: 1.2rem; }
.hero-title h1 { font-size: 1.8rem; }
.mods { display: flex; gap: .4rem; flex-wrap: wrap; }

/* documents */
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.doc { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fafafa; }
.doc a.thumb { display: grid; place-items: center; height: 90px; background: #f3f4f6; text-decoration: none; font-size: 2rem; }
.doc img { width: 100%; height: 90px; object-fit: cover; display: block; }
.doc .cap { padding: .3rem .45rem; font-size: .78rem; display: flex; gap: .3rem; align-items: center; }
.doc .cap span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .cap button { padding: 0 .35rem; border: 0; background: none; color: var(--red); font-size: 1rem; }
.doc-add { border: 2px dashed #cbd5e1; border-radius: 8px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: .85rem; min-height: 115px; cursor: pointer; background: #fff; }
.doc-add:hover { border-color: var(--brand); color: var(--brand); }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); gap: .5rem; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-head .x { border: 0; font-size: 1.4rem; line-height: 1; padding: .2rem .5rem; }
.modal-body { padding: 1.1rem; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .8rem 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
#toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 60; }
#toast div { background: #111827; color: #fff; padding: .6rem 1rem; border-radius: 8px; margin-top: .4rem; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
#toast div.bad { background: var(--red); }

/* salary slip */
.slip { max-width: 720px; margin: 0 auto; }
.slip h2 { text-align: center; margin-bottom: .2rem; }
.slip table td { padding: .4rem .6rem; }
.slip .net { font-size: 1.3rem; font-weight: 700; color: var(--brand-dark); text-align: right; padding: .6rem 0; }
.print-only { display: none; }

@media (max-width: 760px) {
  .topbar-in { flex-wrap: wrap; gap: .5rem; }
  .nav { order: 3; flex-basis: 100%; }
  .topbar .who { display: none; }
  .toolbar input, .toolbar select { flex: 1; min-width: 0; }
  .details { grid-template-columns: 1fr 1fr; }
  .grid-lists { grid-template-columns: 1fr; }
  .page-head > button, .page-head > .btn { font-size: .85rem; padding: .4rem .6rem; }
  .hide-sm { display: none; }
  .att-row .who { flex-basis: 100%; }
}
@media print {
  .topbar, .no-print, #toast, .warn-banner { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
  .print-only { display: block !important; }
  .modal-bg { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; max-width: none; }
  .modal-head, .modal-foot { display: none; }
}
