/* Sakura Công việc — giao diện đơn giản, chữ to, dễ bấm */
:root {
  --pink: #d6336c; --pink-d: #b02a5b; --pink-l: #fdeef4;
  --bg: #f5f6f8; --card: #fff; --line: #e2e5ea; --line-d: #c9ced6;
  --text: #1f2937; --muted: #6b7280; --ok: #15803d; --warn: #b45309; --bad: #c62828;
  --blue: #1d4ed8; --radius: 10px; --shadow: 0 1px 3px rgba(0,0,0,.06);
  --name-w: 190px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", "Hiragino Sans", Arial, sans-serif; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.2rem; margin: 0 0 .8rem; }
h3 { font-size: 1.05rem; margin: 0 0 .6rem; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .mono { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; word-break: break-all; }
.right { text-align: right; } .nowrap { white-space: nowrap; } .spacer { flex: 1; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .red { color: var(--bad); } .green { color: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 2rem !important; }
.hint { color: var(--muted); font-size: .85rem; font-weight: normal; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

/* ---------- Thanh trên ---------- */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 1rem; background: #fff; border-bottom: 1px solid var(--line); padding: .5rem 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .4rem; font-weight: 700; color: var(--pink); font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.logo { font-size: 1.4rem; }
.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.mainnav a { padding: .5rem .8rem; border-radius: 8px; color: var(--text); font-weight: 500; }
.mainnav a:hover { background: var(--pink-l); text-decoration: none; }
.mainnav a.active { background: var(--pink); color: #fff; }
.mainnav .ico { margin-right: .3rem; }
.userbox { display: flex; align-items: center; gap: .6rem; }
.userbox .me { color: var(--text); font-weight: 600; }
.langform select { padding: .3rem .4rem; min-height: 0; font-size: .9rem; }

.container { max-width: 1280px; margin: 0 auto; padding: 1rem; }
.page-schedule .container { max-width: none; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: .4rem 0 1rem; flex-wrap: wrap; }
.btnrow, .monthnav, .toolbar, .daynav, .formbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.card.narrow { max-width: 560px; }
.table-wrap { padding: 0; overflow-x: auto; }

/* ---------- Nút ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 42px; padding: .5rem 1rem; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn-primary { background: var(--pink); color: #fff; }
.btn-primary:hover { background: var(--pink-d); }
.btn-light { background: #fff; border-color: var(--line-d); color: var(--text); }
.btn-light:hover { background: #f1f3f6; }
.btn-danger-light { background: #fff; border-color: #f3c0c0; color: var(--bad); }
.btn-danger-light:hover { background: #fdecec; }
.btn-google { background: #fff; border-color: var(--line-d); color: var(--text); width: 100%; min-height: 50px; }
.btn-sm { min-height: 32px; padding: .25rem .6rem; font-size: .875rem; }
.btn-lg { min-height: 50px; padding: .6rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.linkbtn { background: none; border: 0; color: var(--blue); cursor: pointer; font: inherit; padding: 0; }
.linkbtn.on { font-weight: 700; color: var(--text); }

/* ---------- Form ---------- */
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line-d); border-radius: 8px; padding: .5rem .7rem; min-height: 42px; background: #fff; max-width: 100%; }
textarea { min-height: 80px; resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pink); outline-offset: -1px; border-color: var(--pink); }
input[type=checkbox], input[type=radio] { min-height: 0; width: 20px; height: 20px; accent-color: var(--pink); vertical-align: middle; }
input[type=color] { padding: 2px; width: 46px; }
.form label { display: block; font-weight: 600; margin-bottom: .9rem; }
.form label > input:not([type=checkbox]):not([type=radio]), .form label > select, .form label > textarea { display: block; width: 100%; margin-top: .3rem; font-weight: normal; }
.form label.check, label.check { display: inline-flex; align-items: center; gap: .45rem; font-weight: normal; cursor: pointer; margin-bottom: .5rem; }
.inline { display: inline-flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters input[name=q] { flex: 1; min-width: 200px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.span2 { grid-column: span 2; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.checkgrid, .perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .2rem 1rem; }
.roles { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.rolechip { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line-d); border-radius: 999px; padding: .45rem 1rem; cursor: pointer; font-weight: 600; }
.rolechip:has(input:checked) { background: var(--pink-l); border-color: var(--pink); color: var(--pink-d); }
.formbar { position: sticky; bottom: 0; background: rgba(245,246,248,.95); padding: .8rem 0; border-top: 1px solid var(--line); margin-top: 1rem; z-index: 5; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

/* ---------- Thông báo ---------- */
.alert { padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.alert-success { background: #ecfdf3; border-color: #a7e3bd; color: #14532d; }
.alert-error { background: #fdecec; border-color: #f3b4b4; color: #7f1d1d; }
.alert-warning { background: #fff7e6; border-color: #f5d18a; color: #78350f; }
.alert-info { background: #eef4ff; border-color: #bcd0f7; color: #1e3a8a; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #111827; color: #fff; padding: .7rem 1.2rem; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 200; font-weight: 600; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--bad); }

/* ---------- Bảng chung ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { background: #f8f9fb; font-size: .85rem; color: var(--muted); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
.table tr.inactive td { opacity: .5; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #fff7fa; }
.table input, .table select { min-height: 36px; padding: .3rem .5rem; }
.table tr.newrow td { background: #fbfcfd; }
.tag { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: #eef0f3; font-size: .8rem; font-weight: 600; }
.tag-admin { background: #fde2e2; color: #991b1b; } .tag-hr { background: #e0ecff; color: #1e40af; }
.tag-doctor { background: #dcfce7; color: #166534; } .tag-staff { background: #f1f5f9; color: #334155; }
.kv { display: inline-block; margin-right: .9rem; }
.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; flex-wrap: wrap; border-bottom: 2px solid var(--line); }
.tabs a { padding: .6rem 1rem; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.on { color: var(--pink); border-color: var(--pink); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* ---------- Đăng nhập ---------- */
.auth-wrap { min-height: 90vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 420px; padding: 2rem; }
.auth-logo { text-align: center; font-size: 3rem; }
.auth-card h1 { text-align: center; color: var(--pink); }
.auth-card .or, .auth-card .divider-or { text-align: center; color: var(--muted); margin: 1rem 0; }
.auth-lang { text-align: center; margin-top: 1rem; display: flex; justify-content: center; gap: .8rem; }

/* ---------- Trang chủ ---------- */
.hello { margin: .5rem 0 1rem; }
.bigbtns { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.bigbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.4rem 1rem; font-size: 1.15rem; font-weight: 700; color: var(--text); box-shadow: var(--shadow); text-align: center; }
.bigbtn span { font-size: 2.2rem; color: var(--pink); }
.bigbtn em { font-style: normal; font-size: .9rem; color: var(--muted); font-weight: 500; }
.bigbtn:hover { border-color: var(--pink); text-decoration: none; }
.bigbtn.primary { background: var(--pink); color: #fff; border-color: var(--pink); }
.bigbtn.primary span, .bigbtn.primary em { color: #fff; }
.weekstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: .5rem; }
.wday { border: 1px solid var(--line); border-radius: 8px; padding: .4rem; text-align: center; min-height: 86px; }
.wday.today { border: 2px solid var(--pink); }
.wday.sun .wd { color: var(--bad); }
.wday .wd { font-size: .8rem; color: var(--muted); font-weight: 600; }
.wday .ws { border-radius: 6px; padding: .3rem .2rem; margin-top: .3rem; display: flex; flex-direction: column; }
.wday .ws.none { color: var(--line-d); }
.wday .ws small { font-size: .72rem; }
.wday .wn { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.applist { list-style: none; margin: 0; padding: 0; }
.applist li { border-bottom: 1px solid var(--line); }
.applist li a { display: block; padding: .6rem .2rem; color: var(--text); }

/* ---------- Lịch làm việc (giống Google Sheet) ---------- */
.toolbar select { min-width: 180px; }
.monthpick { min-width: 160px; }
.palette { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; position: sticky; top: 58px; z-index: 30; }
.palette-title { width: 100%; font-weight: 600; }
.palette-hint { width: 100%; }
.chip { border: 2px solid transparent; border-radius: 8px; padding: .35rem .7rem; font: inherit; font-weight: 700; cursor: pointer; min-width: 48px; background: #eef0f3; }
.chip.active { border-color: #111827; box-shadow: 0 0 0 2px #fff inset; transform: scale(1.06); }
.chip-none { background: #fff; border-color: var(--line-d); font-weight: 600; }
.chip-erase { background: #fff; border-color: #f3c0c0; color: var(--bad); }
.sched-wrap { padding: 0; overflow: auto; max-height: calc(100vh - 140px); }
.sched { border-collapse: separate; border-spacing: 0; font-size: .85rem; min-width: 100%; }
.sched th, .sched td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; text-align: center; }
.sched thead th { position: sticky; background: #f3f4f6; z-index: 3; font-weight: 600; padding: .25rem .1rem; }
.sched thead tr.wd th { top: 0; height: 28px; }
.sched thead tr.dn th { top: 28px; }
.sched th.sun, .sched td.sun { background-color: #fff1f1; }
.sched thead th.sun { color: var(--bad); background: #fde4e4; }
.sched thead th.sat { color: var(--blue); }
.sched thead th.today { background: var(--pink); color: #fff; }
.sched .c-no { width: 34px; color: var(--muted); position: sticky; left: 0; background: #fff; z-index: 2; }
.sched .c-name { width: var(--name-w); min-width: var(--name-w); max-width: var(--name-w); text-align: left; padding: .25rem .5rem; position: sticky; left: 34px; background: #fff; z-index: 2; box-shadow: 2px 0 0 var(--line-d); }
.sched thead .c-no, .sched thead .c-name { z-index: 5; background: #f3f4f6; }
.sched .c-name .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched .c-name .tt { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched .pt { background: #fef3c7; color: #92400e; font-size: .65rem; border-radius: 4px; padding: 0 .25rem; }
.sched .c-sum { min-width: 42px; font-weight: 700; background: #fafafa; }
.sched tr.deptrow td { background: #1f2937; color: #fff; text-align: left; font-weight: 700; padding: .3rem .6rem; position: sticky; left: 0; letter-spacing: .02em; }
.sched td.cell { min-width: 44px; height: 38px; font-weight: 700; font-size: .8rem; user-select: none; position: relative; }
.sched[data-edit="1"] td.cell { cursor: pointer; }
.sched[data-edit="1"] td.cell:hover { outline: 2px solid var(--pink); outline-offset: -2px; }
.sched td.cell.today { box-shadow: inset 2px 0 0 var(--pink), inset -2px 0 0 var(--pink); }
.sched td.cell.hasnote::after { content: ""; position: absolute; top: 0; right: 0; border: 5px solid transparent; border-top-color: #f59e0b; border-right-color: #f59e0b; }
.sched td.cell.syncerr::before { content: "!"; position: absolute; top: 0; left: 2px; color: var(--bad); font-size: .65rem; }
.sched td.cell.busy { opacity: .45; }
.sched tbody tr:hover td.c-name, .sched tbody tr:hover td.c-no { background: #fff7fa; }
.legend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .4rem 1rem; }
.lg { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.sw { display: inline-block; min-width: 52px; text-align: center; font-weight: 700; border-radius: 6px; padding: .15rem .3rem; border: 1px solid rgba(0,0,0,.06); }

/* ---------- Hộp thoại ---------- */
.dlg { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.dlg[hidden] { display: none; }
.dlg-box { background: #fff; border-radius: 14px; padding: 1.2rem; width: 100%; max-width: 620px; max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; font-size: 1.1rem; }
.dlg-foot { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.x { background: none; border: 0; font-size: 1.3rem; cursor: pointer; color: var(--muted); padding: .2rem .5rem; }
.shiftpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.pick { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; border: 2px solid rgba(0,0,0,.06); border-radius: 10px; padding: .5rem .6rem; cursor: pointer; font: inherit; text-align: left; min-height: 64px; }
.pick b { font-size: 1.05rem; } .pick span { font-size: .8rem; line-height: 1.2; } .pick small { font-size: .75rem; opacity: .85; }
.pick.current { border-color: #111827; }
.pick:hover { filter: brightness(.95); }

/* ---------- Lịch hẹn ---------- */
.daynav .dayname { font-weight: 700; font-size: 1.1rem; margin: 0 .5rem; }
.datepick { min-width: 170px; }
.daynav input[name=q] { min-width: 220px; }
.onduty { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.dutychip { border-radius: 999px; padding: .25rem .7rem; font-size: .85rem; font-weight: 600; border: 1px solid rgba(0,0,0,.06); }
.dutychip.off { opacity: .6; text-decoration: line-through; }
.summary { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.sumchip { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .2rem .8rem; font-size: .9rem; }
.appts td { font-size: .92rem; }
.appts .c-time { white-space: nowrap; width: 70px; }
.appts tr.tgroup td { border-top: 2px solid var(--line-d); }
.appts .c-reason { min-width: 220px; }
.appts .cust { font-weight: 700; color: var(--text); }
.appts tr[class*="st-cancel"] td, .appts tr[class*="st-huy"] td { opacity: .5; text-decoration: line-through; }
.status { display: inline-block; padding: .1rem .6rem; border-radius: 999px; background: #eef0f3; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.sync { font-weight: 700; margin-left: .2rem; cursor: help; }
.s-pending { color: var(--warn); } .s-error { color: var(--bad); } .s-conflict { color: #7c3aed; }
.apptform .grid3, .apptform .grid2 { align-items: start; }
.conflict { border-color: #c4b5fd; background: #faf7ff; }
.conflict td.diff, .conflict tr.diff td { background: #fff3c4; }
.history { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.history li { padding: .4rem 0; border-bottom: 1px dashed var(--line); }

/* ---------- Đồng bộ ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .big, .stat b.big { display: block; font-size: 1.6rem; font-weight: 700; }
.stat.warn { border-color: #f5d18a; background: #fffaf0; }
.stat.bad { border-color: #f3b4b4; background: #fff5f5; }
.switch { display: flex; align-items: center; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--line); cursor: pointer; font-weight: 500; }
.switch input { width: 46px; height: 26px; appearance: none; -webkit-appearance: none; background: #cbd5e1; border-radius: 999px; position: relative; cursor: pointer; transition: .15s; flex: none; border: 0; padding: 0; min-height: 0; }
.switch input::after { content: ""; position: absolute; width: 20px; height: 20px; top: 3px; left: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { left: 23px; }
.switch input:disabled { opacity: .5; }
.res.ok { color: var(--ok); } .res.bad { color: var(--bad); }
.log-error td { color: var(--bad); } .log-warning td { color: var(--warn); }
.problems td { font-size: .9rem; }
.shifts-edit input[name*=code] { width: 80px; }
.shifts-edit input[type=time] { width: 110px; }
.shifts-edit input[type=number] { width: 70px; }
details > summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }

/* ---------- Điện thoại ---------- */
@media (max-width: 900px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .weekstrip { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 700px) {
  :root { --name-w: 120px; }
  .topbar { padding: .4rem .6rem; gap: .4rem; }
  .brand span:last-child { display: none; }
  .mainnav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .mainnav a { white-space: nowrap; padding: .45rem .6rem; }
  .userbox .me { display: none; }
  .container { padding: .6rem; }
  h1 { font-size: 1.3rem; }
  .grid2, .grid3, .row2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .weekstrip { grid-template-columns: repeat(3, 1fr); }
  .palette { top: 96px; }
  .daynav input[name=q] { min-width: 0; width: 100%; }
  /* Bảng lịch hẹn thành dạng thẻ */
  .appts thead { display: none; }
  .appts, .appts tbody, .appts tr, .appts td { display: block; width: 100%; }
  .appts tr { border-bottom: 6px solid var(--bg); padding: .4rem .2rem; }
  .appts tr.tgroup td { border-top: 0; }
  .appts td { border: 0; padding: .2rem .7rem; }
  .appts td:empty { display: none; }
  .appts td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .8rem; }
  .appts td.c-time::before, .appts td.empty::before { content: none; }
  .appts .c-time b { font-size: 1.1rem; }
}

/* ---------- In ---------- */
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: #fff; font-size: 10px; }
  .topbar, .noprint, .palette, .btn, #toast, .dlg, .formbar, .alert { display: none !important; }
  .container { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .sched-wrap { max-height: none; overflow: visible; }
  .sched thead th, .sched .c-no, .sched .c-name { position: static; }
  .sched td.cell { min-width: 0; height: auto; padding: 2px 0; font-size: 9px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- v1.1: phòng ban, ảnh đại diện, cài đặt, nhật ký ---------- */
.depts-card { max-width: 820px; }
.depts-table td { vertical-align: middle; }
.depts-table input[name=name] { width: 100%; min-width: 200px; }
.depts-table input.num { width: 80px; }
.depts-table td:last-child { width: 1%; white-space: nowrap; text-align: right; }
.center { text-align: center; }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; object-fit: cover; flex: none; font-weight: 700; vertical-align: middle; background: #eef0f3; }
.userbox .me { display: inline-flex; align-items: center; gap: .45rem; }
.usercell { display: inline-flex; align-items: center; gap: .55rem; color: inherit; }
.avatar-edit { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.avatar-edit label { margin-bottom: .3rem; }
.linkbtn.danger { color: var(--bad); font-size: .875rem; }
.big { font-size: 1.1rem; }
.resetbox { border: 1px dashed var(--line-d); border-radius: 8px; padding: .7rem .8rem; margin: .2rem 0 1rem; }
.resetbox .btnrow { margin: .5rem 0 .3rem; }
.permlist { list-style: none; padding: 0; margin: 0 0 .8rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .25rem 1rem; }
.permlist li.no { color: var(--muted); }
.permlist li.yes { color: #14532d; }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; background: #eef0f3; color: var(--muted); font-size: .8rem; font-weight: 600; vertical-align: middle; }
.badge.ok { background: #ecfdf3; color: #14532d; }
.steps { margin: 0 0 1rem 1.2rem; padding: 0; color: var(--muted); }
.steps li { margin-bottom: .25rem; }
.copyrow { display: flex; gap: .4rem; margin-top: .3rem; }
.copyrow input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; font-weight: normal; background: #f8f9fb; }
.inline-form { display: flex; align-items: flex-end; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.inline-form label { flex: 1; min-width: 240px; margin-bottom: 0; }
.filters label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); font-weight: 600; gap: .2rem; }
.filters label select, .filters label input { min-width: 160px; color: var(--text); }
.filters { align-items: flex-end; }
.logs .logdetail { max-width: 520px; }
.logs .kv { display: inline-block; margin: 0 .6rem .15rem 0; }
.logs .kv b { color: var(--muted); font-weight: 600; }
.pager { display: flex; align-items: center; justify-content: center; gap: .8rem; margin: 1rem 0; }
.monthpick-wrap { position: relative; overflow: hidden; }
.monthpick-wrap .monthpick { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-width: 0; width: 100%; }
.auth-card .center, p.center { text-align: center; margin-top: 1rem; }

/* ---------- v1.2: giao diện chuyên nghiệp hơn ---------- */
:root {
  --bg: #f4f5f8; --line: #e5e7ec; --line-d: #cfd4dc; --text: #1d2433; --muted: #667085;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.04);
  --shadow-md: 0 4px 14px rgba(16,24,40,.08); --focus: 0 0 0 3px rgba(214,51,108,.18);
}
body { font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: -.005em; }

/* Thanh trên */
.topbar { padding: .45rem 1.2rem; box-shadow: 0 1px 0 var(--line); border-bottom: 0; backdrop-filter: saturate(1.4) blur(6px); background: rgba(255,255,255,.94); }
.brand { font-size: 1.05rem; letter-spacing: -.01em; }
.mainnav a { padding: .45rem .8rem; color: #3f4756; border-radius: 9px; transition: background .12s, color .12s; }
.mainnav a.active { background: var(--pink-l); color: var(--pink-d); font-weight: 600; box-shadow: inset 0 0 0 1px #f6c9da; }
.mainnav a:hover { background: #f3f4f7; }
.mainnav a.active:hover { background: var(--pink-l); }

/* Trang, thẻ */
.container { padding: 1.2rem 1.2rem 2.5rem; }
.pagehead { margin: .2rem 0 1.1rem; }
.card { border-color: var(--line); box-shadow: var(--shadow); padding: 1.15rem 1.25rem; }
.card > h2:first-child, .cardhead { margin-bottom: .9rem; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.cardhead h2 { margin: 0; }
.mt { margin-top: .8rem; }

/* Nút, ô nhập */
.btn { border-radius: 9px; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn-primary { box-shadow: 0 1px 2px rgba(176,42,91,.25); }
.btn-light { box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.btn:focus-visible { outline: 0; box-shadow: var(--focus); }
input, select, textarea { border-radius: 9px; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--pink); box-shadow: var(--focus); }
input[readonly] { background: #f8f9fb; }
.form label small, .form label .hint { display: block; font-weight: normal; color: var(--muted); font-size: .82rem; margin-top: .25rem; }

/* Bảng */
.table th { background: #f8f9fb; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; padding: .6rem .75rem; }
.table td { padding: .65rem .75rem; }
.table tbody tr:hover td { background: #fafbfc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-wrap.card { overflow: hidden; overflow-x: auto; }
.tag { font-weight: 600; font-size: .76rem; padding: .12rem .55rem; }
.tag-new { background: #e0f2fe; color: #075985; }

/* Thẻ số liệu */
.stat { box-shadow: var(--shadow); border-radius: var(--radius); }
.stat .big, .stat b.big { font-size: 1.55rem; letter-spacing: -.02em; }
.stat.good { border-color: #a7e3bd; background: #f3fcf6; }
.stat.good .big { color: var(--ok); }

/* Tab trong trang (Đồng bộ MediCRM) */
.tabbar { display: flex; gap: .25rem; padding: .3rem; margin: 0 0 1rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow-x: auto; position: sticky; top: 58px; z-index: 20; scrollbar-width: thin; }
.tabbar a { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .85rem; border-radius: 9px; color: #3f4756; font-weight: 600; white-space: nowrap; font-size: .95rem; }
.tabbar a:hover { background: #f3f4f7; text-decoration: none; }
.tabbar a.on { background: var(--pink); color: #fff; }
.tabbar .ico { font-size: 1rem; line-height: 1; }
.tabbar .dot { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .72rem; display: inline-flex; align-items: center; justify-content: center; }
.tabbar a.on .dot { background: #fff; color: var(--pink-d); }
.tabpane[hidden] { display: none; }
.tabpane:not([hidden]) { animation: paneIn .14s ease-out; }
@keyframes paneIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* Ghép nhân viên */
.empmap select.empsel { min-width: 260px; width: 100%; }
.empmap tr.linked td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.empmap tr.linked select { border-color: #a7e3bd; background: #f6fdf8; }

/* Sửa nhân viên */
#loginFields { transition: opacity .15s; }
#loginFields.dim { opacity: .45; }
.mergebox { border-style: dashed; }
.mergebox > summary { list-style: none; display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.mergebox > summary::-webkit-details-marker { display: none; }
.mergebox > summary::before { content: "▸"; color: var(--muted); }
.mergebox[open] > summary::before { content: "▾"; }

/* Bước hướng dẫn */
.steps { counter-reset: st; list-style: none; margin: 0 0 1rem; }
.steps li { counter-increment: st; position: relative; padding-left: 2rem; margin-bottom: .45rem; color: #4b5565; }
.steps li::before { content: counter(st); position: absolute; left: 0; top: .05rem; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--pink-l); color: var(--pink-d); font-size: .78rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* Hộp thoại */
.dlg { backdrop-filter: blur(2px); }
.dlg-box { border-radius: 16px; padding: 1.3rem 1.4rem; }

/* Thông báo */
.alert { border-radius: 10px; box-shadow: var(--shadow); }

@media (max-width: 700px) {
  .container { padding: .7rem .7rem 2rem; }
  .card { padding: .9rem; }
  .tabbar { top: 96px; }
  .empmap select.empsel { min-width: 180px; }
}
