/*
  คลาสที่ใช้ร่วมกันทุกหน้าจอ — ported from kku_supply/src/assets/design-system.css (2026-09-22)
  as-is (component classes only) so dent-lab shares the same visual language as the rest of the
  censoft product family. See context.md §7 before adding a new class here — check kku_supply's
  copy first; a class dent-lab needs that kku_supply doesn't have yet goes in the
  "dent-lab-specific additions" section at the bottom of this file, not mixed into the ported part.

  หลักการ: คลาสคุมองค์ประกอบมาตรฐาน (ปุ่ม/ตาราง/สถานะ) ส่วน layout ของแต่ละหน้าใช้
  inline flex/grid ในไฟล์ view นั้น ๆ เพื่อให้ปรับได้อิสระโดยไม่กระทบหน้าอื่น

  Everything below is in the "design-system" cascade layer (see tokens.css's @layer order
  declaration) so it always wins over static/css/style.css's still-unconverted "legacy" layer —
  do not remove this wrapper until every page has migrated off style.css.
*/
@layer design-system {

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ---------------------------------------------------------------- โครงหน้า */
.side {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  transition: width var(--dur) var(--ease);
}
.side--collapsed { width: 64px; }
.side--collapsed .brand { align-items: center; padding-left: 0; padding-right: 0; }
.side--collapsed .nav__i { justify-content: center; padding-left: 0; padding-right: 0; }
.side--collapsed .nav__i--on::before { left: 0; }
.side--collapsed .nav__sec { height: 13px; padding: 12px 0 4px; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 16px 12px; }
.brand__logo { height: 30px; width: auto; max-width: 100%; object-fit: contain; }
.brand__m {
  width: 32px; height: 32px; border-radius: var(--r-md);
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  color: var(--primary); font-weight: 700; font-size: 0.72rem; flex-shrink: 0;
}
.brand__t { color: var(--sidebar-ink); font-weight: 700; font-size: 0.92rem; line-height: 1.25; }
.brand__s { color: var(--sidebar-ink-muted); font-size: 0.66rem; line-height: 1.3; }
.sfind {
  margin: 0 12px 6px; display: flex; align-items: center; gap: 7px;
  background: color-mix(in oklch, var(--sidebar-bg-active) 55%, transparent);
  border: 1px solid var(--sidebar-border); border-radius: var(--r-md);
  padding: 7px 9px; color: var(--sidebar-ink-muted); font-size: 0.76rem;
}
.nav { padding: 6px 12px 16px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }
.nav__sec {
  font-size: 0.63rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: color-mix(in oklch, var(--sidebar-ink-muted) 48%, transparent);
  padding: 12px 8px 4px; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.nav__sec--btn { cursor: pointer; user-select: none; border-radius: var(--r-sm); }
.nav__sec--btn:hover { color: var(--sidebar-ink-muted); }
.nav__sec-chev { flex-shrink: 0; transition: transform var(--dur-fast) var(--ease); }
.nav__sec-chev--closed { transform: rotate(-90deg); }
.nav__i {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 8px 9px; border-radius: var(--r-md);
  color: var(--sidebar-ink-muted); font-size: 0.83rem; font-weight: 500;
  cursor: pointer; transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav__i:hover { background: var(--sidebar-bg-active); color: var(--sidebar-ink); }
.nav__i--on { background: var(--sidebar-bg-active); color: var(--sidebar-ink); font-weight: 600; }
.nav__i--on::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav__b {
  margin-left: auto; background: var(--danger); color: var(--primary-ink);
  font-size: 0.65rem; font-weight: 700; border-radius: 999px; padding: 1px 6px;
}
.nav__b--q { background: var(--sidebar-bg-active); color: var(--sidebar-ink-muted); }

.side__collapse {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 4px 12px 12px; padding: 8px 9px; border-radius: var(--r-md);
  background: transparent; border: 1px solid var(--sidebar-border);
  color: var(--sidebar-ink-muted); font-size: 0.78rem; font-family: inherit;
  cursor: pointer; flex-shrink: 0;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.side__collapse:hover { background: var(--sidebar-bg-active); color: var(--sidebar-ink); }
.side--collapsed .side__collapse { margin-left: 12px; margin-right: 12px; }

.top {
  height: var(--topbar-h); display: flex; align-items: center; gap: 14px;
  padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}
.crumb { font-size: 0.78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.crumb b { color: var(--ink); font-weight: 600; }
.gfind {
  display: flex; align-items: center; gap: 8px; width: 300px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 7px 10px; color: var(--muted); font-size: 0.78rem;
}
.icnbtn {
  width: 34px; height: 34px; border-radius: var(--r-md); display: flex;
  align-items: center; justify-content: center; color: var(--muted); position: relative; cursor: pointer;
}
.icnbtn:hover { background: var(--bg); }
.icnbtn__dot {
  position: absolute; top: 7px; right: 8px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--danger); border: 1.5px solid var(--surface);
}
.av {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-subtle);
  color: var(--primary); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.72rem;
}

.userbox__trigger {
  display: flex; align-items: center; gap: 9px; background: transparent; border: none;
  padding: 4px 6px; border-radius: var(--r-md); cursor: pointer; color: var(--muted);
}
.userbox__trigger:hover { background: var(--bg); }
.userbox__menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 50;
  width: 260px; padding: 10px; box-shadow: 0 8px 24px oklch(0.15 0 0 / 0.12);
}
.userbox__row { display: flex; align-items: center; gap: 8px; padding: 7px 4px; }
.userbox__row + .userbox__row { border-top: 1px solid var(--border); }

.content { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.phead {
  padding: 16px 20px 12px; display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.ttl { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.005em; }
.sub { margin: 4px 0 0; font-size: 0.79rem; color: var(--muted); }
.body { flex: 1; min-height: 0; padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }

/* ------------------------------------------------------------------ พิมพ์เอกสาร */
.print-only { display: none; }
@media print {
  .side, .top, .phead, .print-hide { display: none !important; }
  .print-only { display: block !important; }
  .body { overflow: visible; padding: 0; }
}

/* ------------------------------------------------------------ ปุ่ม/ช่องกรอก */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--r-md); border: 1px solid transparent; font-weight: 600;
  font-size: 0.82rem; font-family: inherit; height: 36px; padding: 0 14px;
  white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn--p { background: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow-btn); }
.btn--p:hover { background: var(--primary-hover); }
.btn--s { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn--s:hover { background: var(--bg); }
.btn--g { background: transparent; color: var(--muted); }
.btn--g:hover { background: var(--bg); color: var(--ink); }
.btn--d { background: var(--danger); color: var(--primary-ink); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 0.76rem; border-radius: var(--r-sm); }
.btn--lg { height: 42px; padding: 0 18px; font-size: 0.88rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.inp {
  height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); font-size: 0.8rem; font-family: inherit; color: var(--ink);
}
.inp:focus-visible { outline: 2px solid color-mix(in oklch, var(--primary) 45%, transparent); outline-offset: 1px; }
.inp--ta { height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.lbl { display: block; margin-bottom: 5px; font-size: 0.76rem; font-weight: 600; color: var(--ink-soft); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: 0.76rem; font-weight: 600; color: var(--muted); cursor: pointer;
}
.chip--on { background: var(--primary-subtle); border-color: color-mix(in oklch, var(--primary) 30%, transparent); color: var(--primary); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg__i { padding: 5px 12px; border-radius: 7px; font-size: 0.78rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg__i--on { background: var(--surface); color: var(--primary); box-shadow: 0 1px 2px oklch(0.15 0 0 / 0.06); }
.sw { width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; flex-shrink: 0; cursor: pointer; }
.sw--on { background: var(--primary); }
.sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); }
.sw--on::after { left: auto; right: 2px; }

/* ---------------------------------------------------------------- การ์ด */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-card); }
.card__h { padding: 11px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card__hn { padding: 11px 14px; background: var(--primary); color: var(--primary-ink); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card__t { margin: 0; font-size: 0.88rem; font-weight: 700; }
.card__f { padding: 11px 14px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tile__l { font-size: 0.73rem; color: var(--muted); font-weight: 600; }
.tile__v { font-size: 1.45rem; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tile__d { font-size: 0.72rem; color: var(--muted); }

/* --------------------------------------------------------------- ตาราง */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.81rem; }
.tbl thead th {
  background: var(--bg); color: var(--muted); font-weight: 700; font-size: 0.69rem;
  text-transform: uppercase; letter-spacing: 0.04em; text-align: left;
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl tbody td { padding: 9px 12px; border-bottom: 1px solid oklch(0.93 0.006 258); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--bg); }
.tr--on { background: color-mix(in oklch, var(--primary-subtle) 45%, transparent); }
.tbl thead th.num, .tbl th.num, .num { text-align: right; font-variant-numeric: tabular-nums; }
.mut { color: var(--muted); }
.strong { font-weight: 600; }
.sub2 { font-size: 0.72rem; color: var(--muted); font-weight: 400; }
.ck { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid oklch(0.78 0.01 258); display: inline-block; }
.ck--on { background: var(--primary); border-color: var(--primary); }

/* --------------------------------------------------------------- สถานะ */
.bdg { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; line-height: 1.55; white-space: nowrap; }
.bdg--su { background: var(--success-subtle); color: var(--success-text); }
.bdg--wa { background: var(--warning-subtle); color: var(--warning-text); }
.bdg--da { background: var(--danger-subtle); color: var(--danger-text); }
.bdg--in { background: var(--info-subtle); color: var(--info-text); }
.bdg--ne { background: var(--surface-2); color: var(--muted); }
.bdg--ac { background: var(--accent-subtle); color: var(--accent-text); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------------ ขั้นตอน/ไทม์ไลน์ */
.stp { display: flex; align-items: center; gap: 8px; font-size: 0.76rem; color: var(--muted); }
.stp--on { color: var(--ink); font-weight: 600; }
.stp__n { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.68rem; font-weight: 700; background: var(--surface-2); color: var(--muted); flex-shrink: 0; }
.stp__n--on { background: var(--primary); color: var(--primary-ink); }
.stp__n--dn { background: var(--success); color: var(--primary-ink); }
.stp__l { flex: 1; height: 1px; background: var(--border); min-width: 18px; }
.tl { display: flex; gap: 10px; }
.tl__r { display: flex; flex-direction: column; align-items: center; }
.tl__b { width: 1px; flex: 1; background: var(--border); }

/* ---------------------------------------------------------------- อื่น ๆ */
.bar { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar__f { height: 100%; border-radius: 999px; background: var(--primary); }
.note { border-radius: var(--r-lg); padding: 10px 12px; font-size: 0.78rem; line-height: 1.55; }
.note--wa { background: var(--warning-subtle); border: 1px solid color-mix(in oklch, var(--warning) 40%, transparent); }
.note--in { background: var(--info-subtle); border: 1px solid color-mix(in oklch, var(--info) 25%, transparent); }
.note--su { background: var(--success-subtle); border: 1px solid color-mix(in oklch, var(--success) 30%, transparent); }
.note--da { background: var(--danger-subtle); border: 1px solid color-mix(in oklch, var(--danger) 30%, transparent); }
.qr {
  width: 96px; height: 96px; border-radius: var(--r-sm);
  background: repeating-conic-gradient(var(--ink) 0% 25%, var(--surface) 0% 50%) 0 0 / 16px 16px;
  border: 6px solid var(--surface); box-shadow: 0 0 0 1px var(--border);
}
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 0.8rem; padding: 5px 0; }
.kv + .kv { border-top: 1px solid oklch(0.95 0.004 258); }
.rowline { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid oklch(0.93 0.006 258); }
.rpt { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: var(--r-md); font-size: 0.79rem; cursor: pointer; }
.rpt:hover { background: var(--bg); }
.rpt__n { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.71rem; width: 34px; flex-shrink: 0; }

.icnbtn--menu { display: none; background: none; border: none; font-family: inherit; }

/* --------------------------------------------------------- จอเล็ก (mobile) */
@media (max-width: 1024px) {
  .icnbtn--menu { display: flex; }
  .side { position: fixed; z-index: 40; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform var(--dur) var(--ease); width: var(--sidebar-w) !important; }
  .side--open { transform: none; }
  .side__collapse { display: none; }
  .gfind { display: none; }
  .body { padding: 12px; }
  .phead { padding: 12px; flex-direction: column; align-items: stretch; }
}

/* ==================================================================
   dent-lab-specific additions — kku_supply does not have these yet.
   Keep the same token/naming conventions (BEM-ish, --r-* radii, oklch
   color-mix) as the ported section above; do not invent an unrelated
   visual language here. See context.md §7.
   ================================================================== */

/* Login split-screen (adapted from kku_supply's LoginView.vue scoped styles,
   which aren't in its shared design-system.css — ported here instead since
   dent-lab has no per-page <style scoped> equivalent). */
.login { min-height: 100vh; display: flex; background: var(--surface); }
.login__brand {
  display: none; width: 46%; background: var(--sidebar-bg); position: relative; overflow: hidden;
  flex-direction: column; justify-content: space-between; padding: 48px 56px;
}
.login__pattern { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.login__pitch { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 18px; max-width: 440px; margin: auto 0; padding: 48px 0; }
.login__pitch h1 { margin: 0; font-size: 2.1rem; font-weight: 700; line-height: 1.3; color: #fff; }
.login__pitch p { margin: 0; font-size: 0.95rem; line-height: 1.65; color: var(--sidebar-ink-muted); }
.login__badges { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.login__badges .chip { background: color-mix(in oklch, white 12%, transparent); border-color: color-mix(in oklch, white 18%, transparent); color: #fff; }
.login__foot { font-size: 0.74rem; color: var(--sidebar-ink-muted); font-weight: 500; }
.login__panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login__form { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.login__brand-mobile { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login__field { position: relative; }
.login__field-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.login__input { width: 100%; height: 44px; padding-left: 38px; }
.login__input--pw { padding-right: 40px; }
.login__eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--muted); cursor: pointer; border-radius: var(--r-sm);
}
.login__eye:hover { color: var(--ink); background: var(--bg); }
.login__foot-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.76rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 14px; }
.login__foot-row a { color: var(--primary); font-weight: 600; }
.login__spin { animation: login-spin 0.9s linear infinite; }
@keyframes login-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .login__spin { animation: none; } }
@media (min-width: 1024px) { .login__brand { display: flex; } }

/* App shell root (`.app-shell`, templates/index.html) — display:flex/min-height:100vh come from
   the still-untouched legacy layer (static/css/style.css); this pins the shell to the viewport
   and clips it so `.body`'s own overflow:auto (not the whole page) scrolls tall tab content,
   matching the fixed sidebar/topbar pattern ported from kku_supply. */
.app-shell { height: 100vh; overflow: hidden; }

/* Brand monogram (tooth icon) — dent-lab has no institution logo image to port (kku_supply's
   logo-brand.png is Faculty of Dentistry KKU-specific; do not reuse it here). */
.brand__icon {
  width: 30px; height: 30px; border-radius: var(--r-md); background: var(--surface);
  display: flex; align-items: center; justify-content: center; color: var(--primary); flex-shrink: 0;
}

/* static/css/style.css sets `body { font-family: 'Inter','Sarabun' !important }` for pages not
   yet migrated. !important declarations invert cascade-layer precedence (a lower layer's
   !important beats a higher layer's normal declaration), so without this, the new shell would
   inherit the legacy font despite living in the higher-priority design-system layer. Force it
   back explicitly on every new-shell root instead of relying on inheritance from <body>. */
.side, .top, .phead, .body, .login { font-family: var(--font-sans) !important; }

} /* end @layer design-system */
