:root {
  --pink: #ff3d8a;
  --pink-dark: #d8186a;
  --pink-light: #ffe3ef;
  --black: #111111;
  --gray-900: #1f1f1f;
  --gray-700: #444;
  --gray-500: #777;
  --gray-300: #d9d9d9;
  --gray-100: #f4f4f6;
  --white: #fff;
  --green: #1aa65b;
  --red: #e53935;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(0,0,0,.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--gray-100); color: var(--black); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 17px; line-height: 1.4; }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; border: none; }
input, select { font-family: inherit; font-size: 18px; }
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }

/* Layout */
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: var(--black); color: var(--white); padding: calc(10px + var(--safe-top)) 16px 10px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.topbar .brand { font-weight: 800; font-size: 20px; letter-spacing: .5px; }
.topbar .brand span { color: var(--pink); }
.topbar .who { font-size: 14px; color: #ccc; }
.topbar .who b { color: var(--white); }
.topbar button { background: transparent; color: var(--pink); font-weight: 700; padding: 8px 10px; border-radius: 10px; }
.topbar button:active { background: rgba(255,255,255,.1); }
.page { padding: 14px 16px calc(90px + var(--safe-bottom)); flex: 1; }
.page.no-nav { padding-bottom: 24px; }

.card { background: var(--white); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h2 { font-size: 17px; font-weight: 700; margin-bottom: 10px; color: var(--gray-700); display: flex; justify-content: space-between; align-items: center; }
.card h2 .sub { font-size: 14px; font-weight: 500; color: var(--gray-500); }
.muted { color: var(--gray-500); font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.money { font-weight: 700; color: var(--pink-dark); white-space: nowrap; }
.big { font-size: 24px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 18px; border-radius: 14px; font-weight: 700; font-size: 17px; background: var(--pink); color: var(--white); min-height: 52px; transition: transform .05s, opacity .2s; width: 100%; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.black { background: var(--black); }
.btn.outline { background: var(--white); color: var(--black); border: 2px solid var(--gray-300); }
.btn.outline.pink { color: var(--pink-dark); border-color: var(--pink); }
.btn.ghost { background: transparent; color: var(--gray-700); }
.btn.sm { min-height: 40px; padding: 8px 14px; font-size: 15px; border-radius: 10px; width: auto; }
.btn.danger { background: var(--red); }
.btn.green { background: var(--green); }
.btn-icon { background: transparent; color: var(--gray-500); padding: 8px; font-size: 20px; line-height: 1; border-radius: 10px; }
.btn-icon.red { color: var(--red); }

/* Attendance */
.att-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.att-btn { padding: 18px 10px; border-radius: 16px; font-size: 20px; font-weight: 800; background: var(--white); color: var(--gray-700); border: 2px solid var(--gray-300); min-height: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.att-btn .ic { font-size: 30px; }
.att-btn.on-work { background: var(--green); color: var(--white); border-color: var(--green); }
.att-btn.on-off { background: var(--gray-700); color: var(--white); border-color: var(--gray-700); }

/* Group tabs */
.tabs { display: flex; background: var(--white); border-radius: 14px; padding: 4px; box-shadow: var(--shadow); margin-bottom: 12px; }
.tabs button { flex: 1; padding: 12px 6px; border-radius: 11px; font-weight: 700; background: transparent; color: var(--gray-700); font-size: 15px; }
.tabs button.active { background: var(--black); color: var(--white); }

/* Service grid */
.svc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.svc-btn { background: var(--white); border: 2px solid var(--pink-light); border-radius: 16px; padding: 16px 12px; min-height: 96px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; box-shadow: var(--shadow); }
.svc-btn:active { background: var(--pink-light); }
.svc-btn .name { font-weight: 800; font-size: 17px; color: var(--black); }
.svc-btn .hh { font-size: 14px; color: var(--pink-dark); margin-top: 6px; font-weight: 600; }
.svc-btn .price { font-size: 13px; color: var(--gray-500); }

/* Entry list */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.item:last-child { border-bottom: none; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 700; }
.item .s { font-size: 14px; color: var(--gray-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .r { text-align: right; }
.item .r .money { font-size: 17px; }
.item .r .p { font-size: 13px; color: var(--gray-500); }
.empty { text-align: center; color: var(--gray-500); padding: 20px 0; }

/* Bottom nav */
.nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--white); border-top: 1px solid var(--gray-300); display: flex; padding-bottom: var(--safe-bottom); z-index: 10; }
.nav-inner { max-width: 560px; margin: 0 auto; display: flex; width: 100%; }
.nav button { flex: 1; background: transparent; padding: 10px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--gray-500); font-size: 12px; font-weight: 600; }
.nav button .ic { font-size: 22px; }
.nav button.active { color: var(--pink-dark); }

/* Login */
.login { padding: calc(40px + var(--safe-top)) 20px 30px; text-align: center; }
.logo { width: 92px; height: 92px; border-radius: 26px; background: var(--black); color: var(--white); display: inline-flex; align-items: center; justify-content: center; font-size: 42px; font-weight: 900; margin-bottom: 10px; box-shadow: 0 6px 20px rgba(255,61,138,.35); }
.logo span { color: var(--pink); }
.login h1 { font-size: 26px; font-weight: 900; margin-bottom: 4px; }
.login .muted { margin-bottom: 24px; }
.staff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.staff-btn { background: var(--white); border: 2px solid var(--gray-300); border-radius: 16px; padding: 18px 10px; font-size: 18px; font-weight: 700; min-height: 70px; box-shadow: var(--shadow); }
.staff-btn:active { border-color: var(--pink); background: var(--pink-light); }
.staff-btn.admin { border-color: var(--black); background: var(--black); color: var(--white); grid-column: 1 / -1; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 20px 0 24px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--gray-300); background: var(--white); }
.pin-dots span.on { background: var(--pink); border-color: var(--pink); }
.pin-dots.err span { border-color: var(--red); background: #fde3e3; }
.pad { display: grid; grid-template-columns: repeat(3, 76px); justify-content: center; gap: 14px 22px; margin: 0 auto; }
.pad button { width: 76px; height: 76px; aspect-ratio: 1 / 1; padding: 0; border-radius: 50%; background: var(--white); font-size: 28px; font-weight: 700; box-shadow: var(--shadow); color: var(--black); display: flex; align-items: center; justify-content: center; }
.pad button:active { background: var(--pink-light); }
.pad button.fn { background: transparent; box-shadow: none; font-size: 16px; color: var(--gray-700); font-weight: 600; }

/* Sheet / modal */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--white); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 18px 18px calc(20px + var(--safe-bottom)); max-height: 92vh; overflow-y: auto; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h3 { font-size: 21px; font-weight: 800; margin-bottom: 4px; }
.sheet .close { position: absolute; right: 14px; top: 10px; }
.field { margin: 14px 0; }
.field label { display: block; font-size: 14px; font-weight: 700; color: var(--gray-700); margin-bottom: 6px; }
.field input, .field select { width: 100%; padding: 14px; border: 2px solid var(--gray-300); border-radius: 12px; background: var(--white); outline: none; min-height: 54px; }
.field input:focus, .field select:focus { border-color: var(--pink); }
.field .hint { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
.field.inline { display: flex; gap: 10px; }
.field.inline > div { flex: 1; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.suggest button { background: var(--pink-light); color: var(--pink-dark); font-weight: 700; padding: 8px 12px; border-radius: 999px; font-size: 15px; }
.commission-box { background: var(--black); color: var(--white); border-radius: 14px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; margin: 16px 0; }
.commission-box .lbl { font-size: 14px; color: #bbb; }
.commission-box .val { font-size: 26px; font-weight: 900; color: var(--pink); }
.seg { display: flex; border: 2px solid var(--gray-300); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; padding: 12px 6px; background: var(--white); font-weight: 700; color: var(--gray-700); font-size: 15px; }
.seg button.active { background: var(--black); color: var(--white); }

/* Month picker */
.month-pick { display: flex; align-items: center; justify-content: space-between; background: var(--white); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); margin-bottom: 14px; }
.month-pick button { background: transparent; font-size: 24px; padding: 6px 18px; color: var(--pink-dark); font-weight: 800; }
.month-pick .m { font-weight: 800; font-size: 18px; }

/* Stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--white); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.stat .l { font-size: 13px; color: var(--gray-500); font-weight: 600; }
.stat .v { font-size: 22px; font-weight: 900; margin-top: 2px; }
.stat.pink { background: var(--black); color: var(--white); }
.stat.pink .l { color: #bbb; }
.stat.pink .v { color: var(--pink); }
.stat.wide { grid-column: 1 / -1; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dh { text-align: center; font-size: 12px; color: var(--gray-500); font-weight: 700; }
.cal .d { aspect-ratio: 1; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; background: var(--gray-100); color: var(--gray-700); border: none; }
.cal .d.work { background: var(--green); color: var(--white); }
.cal .d.off { background: var(--gray-700); color: var(--white); }
.cal .d.today { outline: 2px solid var(--pink); outline-offset: 1px; }
.cal .d.future { opacity: .35; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--gray-500); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }

/* Admin table */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 10px 6px; text-align: right; border-bottom: 1px solid var(--gray-100); }
.table th { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .3px; }
.table th:first-child, .table td:first-child { text-align: left; }
.table tr.click:active { background: var(--pink-light); }
.table tfoot td { font-weight: 800; border-top: 2px solid var(--gray-300); }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--gray-100); color: var(--gray-700); }
.tag.pink { background: var(--pink-light); color: var(--pink-dark); }
.tag.dark { background: var(--black); color: var(--white); }
.tag.red { background: #fde3e3; color: var(--red); }
.section-title { font-size: 14px; font-weight: 800; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; margin: 18px 0 8px; }

#toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom)); transform: translateX(-50%); background: var(--black); color: var(--white); padding: 12px 18px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }
#toast.err { background: var(--red); }
#toast.ok { background: var(--green); }

.install-tip { background: var(--pink-light); color: var(--pink-dark); border-radius: 14px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; }
.install-tip b { display: block; margin-bottom: 2px; }

/* Chấm công thu gọn */
.att-bar { display: flex; align-items: center; gap: 8px; background: var(--white); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); margin-bottom: 12px; }
.att-info { flex: 1; min-width: 0; }
.att-info .l { font-size: 12px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: .3px; }
.att-info .d { font-size: 14px; font-weight: 700; color: var(--black); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-sm { min-height: 44px; padding: 0 14px; border-radius: 12px; font-weight: 800; font-size: 15px; background: var(--gray-100); color: var(--gray-700); border: 2px solid var(--gray-300); white-space: nowrap; }
.att-sm.on-work { background: var(--green); border-color: var(--green); color: var(--white); }
.att-sm.on-off { background: var(--gray-700); border-color: var(--gray-700); color: var(--white); }
.svc-btn.tall { min-height: 120px; }
.svc-btn.tall .name { font-size: 19px; }
.svc-btn.tall .hh { font-size: 16px; }

/* Ghi bù ngày trước */
.backfill { display: flex; align-items: center; gap: 10px; background: #fff4d6; border: 1px solid #f5d98b; color: #7a5200; border-radius: 14px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.backfill .muted { color: #9a7a2a; font-size: 12px; }
.backfill > div { flex: 1; }
.backfill .btn.sm { min-height: 38px; }
button.att-info { background: transparent; text-align: left; padding: 0; color: inherit; }
.att-info .chev { color: var(--pink-dark); font-size: 12px; }
.date-hidden { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.cal button.d { cursor: pointer; }
.cal button.d:active { outline: 2px solid var(--pink); }

/* Giờ nhập */
.item .s { white-space: normal; }
.tt { font-weight: 700; color: var(--gray-700); }
.tt.late { color: #b26a00; }
.tt.edited { color: var(--gray-500); font-weight: 600; font-size: 12px; }

/* Sổ chủ */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; -webkit-overflow-scrolling: touch; }
.chip { flex: 0 0 auto; padding: 10px 16px; border-radius: 999px; background: var(--white); border: 2px solid var(--gray-300); font-weight: 700; font-size: 15px; color: var(--gray-700); }
.chip.active { background: var(--pink); border-color: var(--pink); color: var(--white); }
.svc-btn:disabled { opacity: .4; }
.nav button { font-size: 11px; }
