/* ============================================================
   ENDOFFICE v1.0.0 — design system
   โทนเดียวกับ All Good Office: deep-navy command center + neon
   ============================================================ */
:root {
  --bg-0: oklch(0.15 0.028 268);
  --bg-1: oklch(0.185 0.03 268);
  --panel: oklch(0.215 0.032 268);
  --panel-2: oklch(0.255 0.036 268);
  --panel-3: oklch(0.30 0.04 268);
  --hairline: oklch(0.42 0.04 268 / 0.35);
  --hairline-soft: oklch(0.42 0.04 268 / 0.18);
  --tx: oklch(0.96 0.008 268);
  --tx-dim: oklch(0.74 0.02 268);
  --tx-faint: oklch(0.58 0.025 268);
  --accent: oklch(0.66 0.2 290);
  --accent-bright: oklch(0.74 0.18 290);
  --accent-dim: oklch(0.66 0.2 290 / 0.16);
  --cyan: oklch(0.78 0.14 210);
  --fb: oklch(0.64 0.18 256);
  --tiktok: oklch(0.72 0.16 200);
  --tiktok-pink: oklch(0.68 0.21 350);
  --ig: oklch(0.64 0.22 342);
  --yt: oklch(0.62 0.21 26);
  --ok: oklch(0.74 0.16 152);
  --warn: oklch(0.80 0.15 78);
  --danger: oklch(0.66 0.2 27);
  --info: oklch(0.74 0.13 220);
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px;
  --shadow: 0 8px 30px -12px oklch(0.1 0.03 268 / 0.8);
  --shadow-lg: 0 24px 60px -20px oklch(0.08 0.03 268 / 0.9);
  --sans: "IBM Plex Sans Thai", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
:root[data-theme="light"] {
  --bg-0: oklch(0.93 0.012 264); --bg-1: oklch(0.96 0.008 264);
  --panel: oklch(0.995 0.003 264); --panel-2: oklch(0.965 0.008 264); --panel-3: oklch(0.93 0.012 264);
  --hairline: oklch(0.55 0.03 264 / 0.26); --hairline-soft: oklch(0.55 0.03 264 / 0.13);
  --tx: oklch(0.26 0.03 268); --tx-dim: oklch(0.42 0.03 268); --tx-faint: oklch(0.55 0.03 268);
  --accent: oklch(0.55 0.21 290); --accent-bright: oklch(0.5 0.23 290); --accent-dim: oklch(0.55 0.21 290 / 0.13);
  --shadow: 0 8px 26px -14px oklch(0.4 0.03 264 / 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); background: var(--bg-1); color: var(--tx); font-size: 14px; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------- shell ---------- */
.app-shell { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 0 16px; height: 54px;
  background: var(--bg-0); border-bottom: 1px solid var(--hairline); position: relative; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .4px; }
.brand-cube { width: 16px; height: 16px; border-radius: 4px; background: linear-gradient(135deg, var(--accent-bright), var(--cyan)); box-shadow: 0 0 12px var(--accent-dim); }
.brand-name b { color: var(--accent-bright); }
.brand-ver { font-family: var(--mono); font-size: 10px; color: var(--tx-faint); border: 1px solid var(--hairline); padding: 2px 6px; border-radius: 20px; }
.nav-toggle { display: none; background: none; border: 1px solid var(--hairline); color: var(--tx); border-radius: 8px; padding: 4px 10px; font-size: 15px; }

.office-switch { display: flex; gap: 6px; overflow-x: auto; flex: 1; padding: 4px 2px; scrollbar-width: none; }
.office-switch::-webkit-scrollbar { display: none; }
.office-chip {
  white-space: nowrap; font-size: 11.5px; font-weight: 600; padding: 5px 11px; border-radius: 20px;
  border: 1px solid var(--hairline); color: var(--tx-dim); background: var(--panel); transition: .18s;
}
.office-chip.on { border-color: var(--oc); color: var(--tx); background: color-mix(in oklab, var(--oc) 18%, var(--panel)); box-shadow: 0 0 14px color-mix(in oklab, var(--oc) 40%, transparent); }
.office-chip.soon { opacity: .5; }
.office-chip:hover { border-color: var(--oc); }

.top-right { display: flex; align-items: center; gap: 8px; }
.chip { font-size: 12px; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--hairline); background: var(--panel); color: var(--tx-dim); }
.chip:hover { border-color: var(--accent); color: var(--tx); }
.chip.danger:hover { border-color: var(--danger); color: var(--danger); }
.user-pill { display: flex; align-items: center; gap: 7px; font-size: 12px; padding: 5px 12px; border: 1px solid var(--hairline); border-radius: 20px; background: var(--panel); }
.udot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.urole { font-size: 10px; color: var(--accent-bright); font-weight: 700; text-transform: uppercase; }

.body-split { display: flex; flex: 1; min-height: 0; }

/* ---------- sidebar ---------- */
.sidebar { width: 246px; background: var(--bg-0); border-right: 1px solid var(--hairline); overflow-y: auto; padding: 12px 10px 24px; flex-shrink: 0; }
.side-sec { font-size: 10.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--tx-faint); padding: 14px 10px 7px; }
.side-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r); margin-bottom: 2px; border: 1px solid transparent; transition: .15s; }
.side-item:hover { background: var(--panel); border-color: var(--hairline-soft); }
.side-item.on { background: color-mix(in oklab, var(--dc) 14%, var(--panel)); border-color: color-mix(in oklab, var(--dc) 45%, transparent); }
.side-ic { width: 30px; height: 30px; display: grid; place-items: center; font-size: 15px; border-radius: 9px; background: var(--panel-2); flex-shrink: 0; }
.side-item.on .side-ic { background: color-mix(in oklab, var(--dc) 25%, var(--panel-2)); }
.side-tx { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.side-tx b { font-size: 12.5px; font-weight: 600; }
.side-tx i { font-style: normal; font-size: 10.5px; color: var(--tx-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- main ---------- */
.main { flex: 1; overflow-y: auto; padding: 22px 26px 60px; }
.hub-screen { flex: 1; overflow: hidden; position: relative; }

.flash { margin: 0 0 16px; padding: 11px 16px; border-radius: var(--r); font-size: 13px; border: 1px solid; animation: fadein .3s; }
.flash.ok { background: color-mix(in oklab, var(--ok) 12%, var(--panel)); border-color: var(--ok); }
.flash.err { background: color-mix(in oklab, var(--danger) 12%, var(--panel)); border-color: var(--danger); }
@keyframes fadein { from { opacity: 0; transform: translateY(-6px); } }

.page-head { margin-bottom: 18px; }
.page-head .crumbs { font-size: 11.5px; color: var(--tx-faint); margin-bottom: 5px; }
.page-head .crumbs a { color: var(--accent-bright); }
.page-head h1 { margin: 0; font-size: 21px; display: flex; align-items: center; gap: 10px; }
.page-head h1 small { font-size: 12px; font-weight: 400; color: var(--tx-faint); }

/* ---------- panels / stats ---------- */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.panel { background: var(--panel); border: 1px solid var(--hairline-soft); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.panel-h { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--hairline-soft); }
.panel-h b { font-size: 13.5px; } .panel-h span { font-size: 11px; color: var(--tx-faint); }
.panel-pad { padding: 16px; }
.stat { background: var(--panel); border: 1px solid var(--hairline-soft); border-radius: var(--r-lg); padding: 14px 16px; }
.stat .k { font-size: 11px; color: var(--tx-faint); margin-bottom: 5px; }
.stat .v { font-size: 22px; font-weight: 700; font-family: var(--mono); }
.stat .v.ok { color: var(--ok); } .stat .v.warn { color: var(--warn); } .stat .v.danger { color: var(--danger); } .stat .v.info { color: var(--info); }

/* ---------- table ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--tx-faint); padding: 10px 12px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--hairline-soft); vertical-align: middle; }
.tbl tr:hover td { background: var(--panel-2); }
.tbl .mono { font-family: var(--mono); font-size: 11.5px; }

.badge { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px; border: 1px solid; }
.badge.ok { color: var(--ok); border-color: var(--ok); background: color-mix(in oklab, var(--ok) 12%, transparent); }
.badge.warn { color: var(--warn); border-color: var(--warn); background: color-mix(in oklab, var(--warn) 12%, transparent); }
.badge.danger { color: var(--danger); border-color: var(--danger); background: color-mix(in oklab, var(--danger) 12%, transparent); }
.badge.info { color: var(--info); border-color: var(--info); background: color-mix(in oklab, var(--info) 12%, transparent); }
.badge.neutral { color: var(--tx-faint); border-color: var(--hairline); }

/* ---------- forms / buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; padding: 8px 15px; border-radius: 10px; border: 1px solid var(--hairline); background: var(--panel-2); color: var(--tx); transition: .15s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 60%, var(--cyan))); border-color: transparent; color: #fff; box-shadow: 0 4px 16px var(--accent-dim); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); } .btn.danger:hover { border-color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 11.5px; border-radius: 8px; }

.frm { display: grid; gap: 12px; }
.frm label { font-size: 11.5px; font-weight: 600; color: var(--tx-dim); display: block; margin-bottom: 5px; }
.frm input, .frm select, .frm textarea {
  width: 100%; background: var(--bg-1); border: 1px solid var(--hairline); color: var(--tx);
  border-radius: 10px; padding: 9px 12px; font-size: 13px; outline: none; transition: .15s;
}
.frm input:focus, .frm select:focus, .frm textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.frm-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { font-size: 12px; font-weight: 600; padding: 7px 14px; border-radius: 20px; border: 1px solid var(--hairline); background: var(--panel); color: var(--tx-dim); }
.tab.on { color: #fff; background: var(--accent); border-color: var(--accent); box-shadow: 0 0 14px var(--accent-dim); }
.tab:hover:not(.on) { border-color: var(--accent); }

/* ============================================================
   LOGIN — หน้าเข้าสู่ระบบธีมตึกแมว
   ============================================================ */
.login-scene {
  min-height: 100vh; display: grid; place-items: center; position: relative; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, oklch(0.24 0.06 290) 0%, var(--bg-0) 55%);
}
.login-bg { position: absolute; inset: 0; background-size: cover; background-position: center 30%; opacity: .16; filter: saturate(1.2); pointer-events: none; }
.login-stars i { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; opacity: .5; animation: tw 3s infinite; }
@keyframes tw { 50% { opacity: .1; } }
.login-card {
  position: relative; width: min(400px, 92vw); background: color-mix(in oklab, var(--panel) 88%, transparent);
  backdrop-filter: blur(14px); border: 1px solid var(--hairline); border-radius: var(--r-xl);
  padding: 32px 30px 26px; box-shadow: var(--shadow-lg); animation: rise .5s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.97); } }
.login-logo { font-size: 24px; font-weight: 800; letter-spacing: 1px; }
.login-logo b { color: var(--accent-bright); }
.login-sub { font-size: 12px; color: var(--tx-faint); margin: 4px 0 22px; }
.login-cat { position: absolute; top: -46px; right: 22px; font-size: 44px; filter: drop-shadow(0 6px 12px rgb(0 0 0 / .4)); animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-7px); } }
.login-err { background: color-mix(in oklab, var(--danger) 14%, transparent); border: 1px solid var(--danger); border-radius: 10px; padding: 9px 13px; font-size: 12.5px; margin-bottom: 14px; }
.login-foot { text-align: center; font-size: 10.5px; color: var(--tx-faint); margin-top: 20px; }

/* ============================================================
   HUB — ตึกออฟฟิศ (ภาพพื้นหลัง + hotspot ชั้น)
   ============================================================ */
.hub-stage {
  position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden;
  background:
    radial-gradient(90% 60% at 50% 0%, oklch(0.26 0.07 290 / .5) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 70%);
  cursor: grab;
}
.hub-stage.grabbing { cursor: grabbing; }
.hub-inner { position: relative; height: min(92%, 1080px); aspect-ratio: 1 / 1; transition: transform .18s ease-out; will-change: transform; }
.hub-img { width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; filter: drop-shadow(0 30px 60px rgb(0 0 0 / .55)); }
.hub-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hub-floor { fill: transparent; stroke: transparent; stroke-width: .6; cursor: pointer; transition: .2s; }
.hub-floor:hover, .hub-floor.hot { fill: color-mix(in oklab, var(--fc) 22%, transparent); stroke: var(--fc); filter: drop-shadow(0 0 10px var(--fc)); }
.hub-label {
  position: absolute; transform: translate(-50%, -50%); z-index: 5; pointer-events: none;
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 12px;
  background: color-mix(in oklab, var(--bg-0) 82%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--hairline); font-size: 11.5px; font-weight: 700; white-space: nowrap;
  opacity: .88; transition: .2s; box-shadow: var(--shadow);
}
.hub-label i { font-style: normal; font-size: 14px; }
.hub-label small { display: block; font-size: 9.5px; font-weight: 500; color: var(--tx-faint); }
.hub-label.hot { opacity: 1; border-color: var(--fc); box-shadow: 0 0 18px color-mix(in oklab, var(--fc) 55%, transparent); transform: translate(-50%, -50%) scale(1.08); }
.hub-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 11px; color: var(--tx-faint); background: color-mix(in oklab, var(--bg-0) 75%, transparent); border: 1px solid var(--hairline-soft); padding: 6px 14px; border-radius: 20px; backdrop-filter: blur(6px); z-index: 6; }
.hub-zoom { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 7; }
.hub-zoom button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--hairline); background: var(--panel); color: var(--tx); font-size: 16px; }
.hub-welcome { position: absolute; top: 16px; left: 18px; z-index: 6; background: color-mix(in oklab, var(--bg-0) 80%, transparent); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 12px 16px; backdrop-filter: blur(8px); max-width: 300px; }
.hub-welcome b { font-size: 14px; }
.hub-welcome p { margin: 4px 0 0; font-size: 11px; color: var(--tx-faint); line-height: 1.5; }

/* ---------- mascot ---------- */
.mascot { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.mascot-bubble { background: var(--panel); border: 1px solid var(--hairline); border-radius: 14px 14px 3px 14px; padding: 9px 13px; font-size: 12px; max-width: 220px; box-shadow: var(--shadow); animation: fadein .3s; }
.mascot-cat { width: 52px; height: 52px; font-size: 27px; border-radius: 50%; border: 2px solid var(--accent); background: var(--panel-2); box-shadow: 0 0 20px var(--accent-dim); transition: .15s; }
.mascot-cat:hover { transform: scale(1.08) rotate(-6deg); }
.mascot-close { position: absolute; top: -8px; right: -4px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--hairline); background: var(--panel); color: var(--tx-faint); font-size: 11px; line-height: 1; z-index: 2; }
.mascot.min .mascot-bubble { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .sidebar { position: fixed; left: 0; top: 54px; bottom: 0; z-index: 40; transform: translateX(-100%); transition: .22s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .main { padding: 16px 14px 70px; }
  .user-pill { display: none; }
}
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .office-switch { max-width: 40vw; } }
