/* Kintai — 和紙 nền ấm + 藍 (chàm) chủ đạo, cùng tinh thần với BaitoClock */
:root {
  --ink: #23305e;
  --ink-soft: #3d4f8f;
  --bg: #f6f3ec;
  --surface: #ffffff;
  --muted: #efebe2;
  --line: #e3ded3;
  --text: #1c1f26;
  --text-2: #6b6f7a;
  --working: #1e9e6a;
  --break: #d9811a;
  --out: #c8473a;
  --warn: #b85f14;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 31, 38, .05), 0 4px 16px rgba(28, 31, 38, .05);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); }
a { color: var(--ink-soft); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; margin-bottom: 12px; }
h3 { font-size: 15px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ===== Khung quản trị ===== */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #dfe4f7; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 8px 16px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #3a4b95, #1a2350); border: 1.5px solid rgba(255,255,255,.35); display: grid; place-items: center; }
.brand-mark::after { content: ""; width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; box-shadow: inset 3px -1px 0 -1px #f2a33a; }
.side-label { font-size: 11px; letter-spacing: .08em; color: #9aa6d6; padding: 14px 10px 4px; }
.store-switch select { width: 100%; background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.18); border-radius: 10px; padding: 8px 10px; font: inherit; }
.store-switch select option { color: var(--text); }
.nav a { display: flex; align-items: center; gap: 10px; color: #dfe4f7; padding: 9px 12px; border-radius: 10px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.on { background: rgba(255,255,255,.16); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.side-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.side-foot form button { width: 100%; }
.side-foot .who { font-size: 12px; color: #9aa6d6; padding: 0 10px; word-break: break-all; }
.main { padding: 28px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== Thành phần chung ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 18px; }
.grid > .card, .grid > div > .card:first-child { margin-top: 0; }
.person { white-space: nowrap; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat .label { color: var(--text-2); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .cap { color: var(--text-2); font-size: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--muted); text-decoration: none; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--ink-soft); }
.btn.danger { color: var(--out); border-color: #efc9c4; }
.btn.danger:hover { background: #fbeeec; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.2); color: #dfe4f7; }
.btn.ghost:hover { background: rgba(255,255,255,.08); }
.btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--ink-soft); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger { color: var(--out); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--muted); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.working { color: var(--working); background: #e3f4ec; }
.badge.break { color: var(--break); background: #fbf0e1; }
.badge.done { color: var(--ink-soft); background: #e8ebf6; }
.badge.warn { color: var(--warn); background: #fbeee0; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--muted); color: var(--text-2); margin-left: 4px; }
.tag.ot { background: #fbf0e1; color: var(--break); }
.tag.night { background: #e8ebf6; color: var(--ink-soft); }

.alert { border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; font-weight: 500; }
.alert.ok { background: #e3f4ec; color: #146b48; }
.alert.err { background: #fbeeec; color: #9c3227; }
.alert.warn { background: #fbf0e1; color: #8a4a0c; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 700; color: var(--text-2); background: #faf8f3; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfbf8; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; background: #faf8f3; border-top: 2px solid var(--line); }
.table-wrap { overflow-x: auto; }
.day-row td { background: #faf8f3; font-weight: 700; font-size: 13px; color: var(--text-2); }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex: none; }
.person { display: flex; align-items: center; gap: 10px; }
.c0 { background: #3d5a98; } .c1 { background: #c2554a; } .c2 { background: #2f8f6f; } .c3 { background: #b07a2a; }
.c4 { background: #7a4e9e; } .c5 { background: #2b7fa6; } .c6 { background: #a34771; } .c7 { background: #5c6b2e; }

/* ===== Form ===== */
.form { display: grid; gap: 16px; max-width: 640px; }
.field label, .field .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .hint { color: var(--text-2); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #d6d0c3; border-radius: 10px; background: #fff; color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(61, 79, 143, .35); border-color: var(--ink-soft); }
textarea { min-height: 70px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.inline { display: inline; }
.form-actions { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 16px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
.break-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 8px; }

/* Thanh chọn kỳ */
.period { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.period a, .period span.disabled { padding: 6px 12px; border-radius: 8px; color: var(--text); font-weight: 700; }
.period a:hover { background: var(--muted); text-decoration: none; }
.period span.disabled { opacity: .3; }
.period .cur { text-align: center; padding: 0 10px; min-width: 150px; }
.period .cur b { display: block; }
.period .cur small { color: var(--text-2); }

.empty { text-align: center; color: var(--text-2); padding: 40px 20px; }

/* ===== Đăng nhập ===== */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: 100%; max-width: 400px; padding: 32px; }
.auth .brand { color: var(--ink); justify-content: center; font-size: 22px; padding-bottom: 6px; }
.auth .brand-mark { width: 40px; height: 40px; }
.auth .lead { text-align: center; color: var(--text-2); margin: 0 0 22px; }
.auth .btn { width: 100%; padding: 11px; }

/* ===== Phiếu lương / 金種 ===== */
.slip-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; margin-top: 8px; border-top: 2px solid var(--text); }
.slip-total .value { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv .sub { font-size: 12px; color: var(--text-2); display: block; }
.cash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.cash-cell { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; }
.cash-cell .d { font-size: 12px; color: var(--text-2); }
.cash-cell .n { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cash-cell .n small { font-size: 13px; font-weight: 600; color: var(--text-2); margin-left: 2px; }
.cash-cell.note { border-color: #c9d0ea; background: #f5f7fd; }
.cash-cell.zero { opacity: .4; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 6px; }
  .brand { padding: 4px 8px; }
  .side-label { display: none; }
  .store-switch { order: 2; flex: 1 1 160px; }
  .nav { order: 3; display: flex; flex-wrap: wrap; width: 100%; gap: 2px; }
  .nav a { padding: 6px 10px; font-size: 14px; }
  .side-foot { order: 4; margin: 0 0 0 auto; flex-direction: row; padding: 0; align-items: center; }
  .side-foot .who { display: none; }
  .main { padding: 20px 16px 48px; }
  .g3, .g2, .row, .row3 { grid-template-columns: 1fr; }
}

@media print {
  .side, .page-head .actions, .no-print, .alert { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
.mt { margin-top: 18px; }
.grow { flex: 1 1 240px; width: auto; }
.slip-total-inline .value { font-size: 28px; font-weight: 800; }
/* 2段階認証 */
.auth .card.wide { max-width: 520px; }
.code-input { font-size: 24px !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.qr { display: flex; justify-content: center; margin: 14px 0; }
.qr img { border: 1px solid var(--line); border-radius: 12px; padding: 24px; background: #fff; image-rendering: pixelated; }
.steps { padding-left: 20px; margin: 10px 0; }
.steps li { margin-bottom: 4px; }
code.secret { font-size: 15px; font-weight: 700; letter-spacing: .05em; user-select: all; }
details summary { cursor: pointer; color: var(--ink-soft); font-weight: 600; }
.codes { columns: 2; font-size: 18px; font-weight: 700; padding-left: 28px; margin: 16px 0; font-variant-numeric: tabular-nums; }
.codes li { margin-bottom: 8px; }
@media print { .auth { min-height: 0; } .card { border: 0; } }
.code-short { width: 160px; letter-spacing: .2em; text-align: center; }
