/* ============================================================
   Cosmetica ERP — main.css
   Hospital-grade UI · Rose/Slate · Light + Dark + TH/EN toggle
   ============================================================ */

/* ---------- Tokens: Light (default) ---------- */
:root,
:root[data-theme="light"] {
    --color-bg: #f5f6fb;
    --color-surface: #ffffff;
    --color-surface-2: #fafbff;
    --color-surface-3: #f0f2f9;
    --color-border: #e5e7f0;
    --color-border-strong: #d6d9e6;

    --color-text: #45464a;           /* เทาถ่าน (ไม่ใช้ดำสนิท) */
    --color-text-muted: #7a7c82;
    --color-text-subtle: #a2a4ab;

    /* Cosmetica CI — ทอง (deep = อ่านบนขาวได้) + แดงเลือดหมู */
    --color-primary: #9c7a1a;        /* deep gold — ลิงก์/active/accent */
    --color-primary-soft: #f6edd6;   /* pale gold — พื้น soft */
    --color-primary-dark: #856518;
    --color-gold-bright: #d8ab48;    /* ทองสด — ปุ่ม/ตกแต่ง (ไม่ใช้เป็นตัวอักษร) */

    --color-accent: #58595b;         /* เทาเข้ม CI */
    --color-accent-soft: #ececed;

    --color-success: #10b981;
    --color-success-soft: #d5f5e7;
    --color-warning: #f59e0b;
    --color-warning-soft: #fef0d2;
    --color-danger: #a70010;         /* CI red */
    --color-danger-soft: #f7dede;
    --color-info: #3b82f6;
    --color-info-soft: #dbeafe;

    --overlay: rgba(17, 24, 39, 0.55);

    --sidebar-width: 272px;
    --sidebar-collapsed: 72px;
    --topbar-height: 60px;
    --breadcrumb-height: 40px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04);
    --shadow-md: 0 4px 12px rgba(17, 24, 39, 0.06);
    --shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.10);

    --font-sans: 'Sarabun', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --ring: 0 0 0 3px rgba(156, 122, 26, 0.22);
    --focus-ring: 0 0 0 3px rgba(156, 122, 26, 0.24);
}

/* ---------- Tokens: Dark ----------
   Redesigned dark palette (variables only; light mode untouched):
   • bg lifted out of crushed-black into the #0F1117–#1E2030 range
   • surface ramp ~8–12% lighter per step for depth
   • text tiers softened (no pure white) + higher-contrast muted/subtle
   • borders = subtle translucent white (0.09 / 0.16)
   • shadows = depth + a 1px light "glow ring" (border-on-dark approach)
   • CI gold + status hues kept — already dark-adapted and pass WCAG AA
   All pairs verified ≥4.5:1 (text) / ≥3:1 (large). See summary. */
:root[data-theme="dark"] {
    --color-bg: #0f1220;              /* near-black navy, not crushed */
    --color-surface: #171b2b;         /* ~+card depth over bg */
    --color-surface-2: #1e2336;
    --color-surface-3: #272d45;
    --color-border: rgba(255, 255, 255, 0.09);
    --color-border-strong: rgba(255, 255, 255, 0.16);

    --color-text: #f1f5f9;            /* soft white */
    --color-text-muted: #cbd5e1;      /* secondary — 12.5:1 on bg */
    --color-text-subtle: #94a3b8;     /* tertiary — 7.3:1 on bg */

    --color-primary: #e0b968;         /* ทองสว่าง (อ่านบนพื้นเข้ม) */
    --color-primary-soft: #3a2f14;
    --color-primary-dark: #c9a24a;
    --color-gold-bright: #e0b968;

    --color-accent: #b8bac0;          /* เทาอ่อน */
    --color-accent-soft: #222839;

    --color-success: #34d399;
    --color-success-soft: #1b3a2d;
    --color-warning: #fbbf24;
    --color-warning-soft: #3b2c12;
    --color-danger: #e05a5f;          /* แดง CI โทนสว่างขึ้นสำหรับ dark */
    --color-danger-soft: #3a1618;
    --color-info: #60a5fa;
    --color-info-soft: #17283f;

    --overlay: rgba(0, 0, 0, 0.66);

    /* Depth + hairline light ring so cards read as raised on dark bg */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40), 0 0 0 1px rgba(255, 255, 255, 0.04);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.50), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.60), 0 0 0 1px rgba(255, 255, 255, 0.06);

    --ring: 0 0 0 3px rgba(224, 185, 104, 0.30);
    --focus-ring: 0 0 0 3px rgba(224, 185, 104, 0.32);
}

/* ---------- Group color tokens ---------- */
.group--rose,     .group-accent--rose     { --gc-1:#9c7a1a; --gc-2:#d8ab48; --gc-soft:#f6edd6; }
.group--pink,     .group-accent--pink     { --gc-1:#9c7a1a; --gc-2:#d8ab48; --gc-soft:#f6edd6; }
.group--indigo,   .group-accent--indigo   { --gc-1:#4f46e5; --gc-2:#6366f1; --gc-soft:#eef0ff; }
.group--amber,    .group-accent--amber    { --gc-1:#d97706; --gc-2:#f59e0b; --gc-soft:#fef3c7; }
.group--green,    .group-accent--green    { --gc-1:#059669; --gc-2:#10b981; --gc-soft:#d1fae5; }
.group--emerald,  .group-accent--emerald  { --gc-1:#0d9488; --gc-2:#14b8a6; --gc-soft:#ccfbf1; }
.group--blue,     .group-accent--blue     { --gc-1:#2563eb; --gc-2:#3b82f6; --gc-soft:#dbeafe; }
.group--purple,   .group-accent--purple   { --gc-1:#7c3aed; --gc-2:#a855f7; --gc-soft:#ede9fe; }
.group--orange,   .group-accent--orange   { --gc-1:#ea580c; --gc-2:#fb923c; --gc-soft:#ffedd5; }
.group--cyan,     .group-accent--cyan     { --gc-1:#0891b2; --gc-2:#22d3ee; --gc-soft:#cffafe; }
.group--slate,    .group-accent--slate    { --gc-1:#475569; --gc-2:#64748b; --gc-soft:#e2e8f0; }

:root[data-theme="dark"] .group-accent--rose,    :root[data-theme="dark"] .group--rose     { --gc-soft:#3a2f14; }
:root[data-theme="dark"] .group-accent--pink,    :root[data-theme="dark"] .group--pink     { --gc-soft:#3a2f14; }
:root[data-theme="dark"] .group-accent--indigo,  :root[data-theme="dark"] .group--indigo   { --gc-soft:#1e2148; }
:root[data-theme="dark"] .group-accent--amber,   :root[data-theme="dark"] .group--amber    { --gc-soft:#3b2c12; }
:root[data-theme="dark"] .group-accent--green,   :root[data-theme="dark"] .group--green    { --gc-soft:#1b3a2d; }
:root[data-theme="dark"] .group-accent--emerald, :root[data-theme="dark"] .group--emerald  { --gc-soft:#173a36; }
:root[data-theme="dark"] .group-accent--blue,    :root[data-theme="dark"] .group--blue     { --gc-soft:#17283f; }
:root[data-theme="dark"] .group-accent--purple,  :root[data-theme="dark"] .group--purple   { --gc-soft:#2a1f45; }
:root[data-theme="dark"] .group-accent--orange,  :root[data-theme="dark"] .group--orange   { --gc-soft:#3b2a1a; }
:root[data-theme="dark"] .group-accent--cyan,    :root[data-theme="dark"] .group--cyan     { --gc-soft:#123a44; }
:root[data-theme="dark"] .group-accent--slate,   :root[data-theme="dark"] .group--slate    { --gc-soft:#2a3348; }

/* Role colors — alias for role cards/chips */
.role-card--rose,   .topbar-role--rose    { --rc-1:#9c7a1a; --rc-2:#d8ab48; --rc-soft:#f6edd6; }
.role-card--indigo, .topbar-role--indigo  { --rc-1:#4f46e5; --rc-2:#6366f1; --rc-soft:#eef0ff; }
.role-card--pink,   .topbar-role--pink    { --rc-1:#9c7a1a; --rc-2:#d8ab48; --rc-soft:#f6edd6; }
.role-card--amber,  .topbar-role--amber   { --rc-1:#d97706; --rc-2:#f59e0b; --rc-soft:#fef3c7; }
.role-card--green,  .topbar-role--green   { --rc-1:#059669; --rc-2:#10b981; --rc-soft:#d1fae5; }
.role-card--blue,   .topbar-role--blue    { --rc-1:#2563eb; --rc-2:#3b82f6; --rc-soft:#dbeafe; }
.role-card--purple, .topbar-role--purple  { --rc-1:#7c3aed; --rc-2:#a855f7; --rc-soft:#ede9fe; }
.role-card--teal,   .topbar-role--teal    { --rc-1:#0d9488; --rc-2:#14b8a6; --rc-soft:#ccfbf1; }
:root[data-theme="dark"] .role-card--rose,   :root[data-theme="dark"] .topbar-role--rose    { --rc-soft:#3a2f14; }
:root[data-theme="dark"] .role-card--indigo, :root[data-theme="dark"] .topbar-role--indigo  { --rc-soft:#1e2148; }
:root[data-theme="dark"] .role-card--pink,   :root[data-theme="dark"] .topbar-role--pink    { --rc-soft:#3a2f14; }
:root[data-theme="dark"] .role-card--amber,  :root[data-theme="dark"] .topbar-role--amber   { --rc-soft:#3b2c12; }
:root[data-theme="dark"] .role-card--green,  :root[data-theme="dark"] .topbar-role--green   { --rc-soft:#1b3a2d; }
:root[data-theme="dark"] .role-card--blue,   :root[data-theme="dark"] .topbar-role--blue    { --rc-soft:#17283f; }
:root[data-theme="dark"] .role-card--purple, :root[data-theme="dark"] .topbar-role--purple  { --rc-soft:#2a1f45; }
:root[data-theme="dark"] .role-card--teal,   :root[data-theme="dark"] .topbar-role--teal    { --rc-soft:#173a36; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color .15s, color .15s;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
body.no-scroll { overflow: hidden; }
[data-lucide] { width: 18px; height: 18px; stroke-width: 2; }

/* Language toggle — single source of truth */
html[data-lang="th"] .label-en { display: none !important; }
html[data-lang="en"] .label-th { display: none !important; }

/* No-transitions guard — set in head, removed after first paint by main.js */
html.no-transitions,
html.no-transitions *,
html.no-transitions *::before,
html.no-transitions *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
}

/* Accessibility */
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 8px; }
.skip-link {
    position: absolute; top: -40px; left: 12px;
    background: var(--color-primary); color: white;
    padding: 8px 14px; border-radius: 8px;
    z-index: 2000; transition: top .2s;
}
.skip-link:focus { top: 12px; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex; flex-direction: column;
    min-width: 0;
    transition: margin-left .2s ease;
}
html.is-sidebar-collapsed .main-area { margin-left: var(--sidebar-collapsed); }
.content { padding: 20px 28px 56px; flex: 1; min-width: 0; outline: none; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    position: fixed; top: 0; bottom: 0; left: 0;
    display: flex; flex-direction: column;
    z-index: 40;
    transition: width .2s ease, transform .2s ease;
}
html.is-sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }

.sidebar-header {
    padding: 12px 16px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--color-border);
    height: var(--topbar-height);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon {
    width: 34px; height: 34px;
    border-radius: 10px; display: grid; place-items: center;
    background: linear-gradient(135deg, #a5811c, #8c6b15);
    color: white; flex-shrink: 0;
}
.brand-icon [data-lucide] { width: 19px; height: 19px; }
.brand-icon.lg { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 12px; }
.brand-icon.lg [data-lucide] { width: 30px; height: 30px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 14.5px; letter-spacing: -0.01em; }
.brand-tag { font-size: 10.5px; color: var(--color-text-subtle); }

html.is-sidebar-collapsed .brand-text,
html.is-sidebar-collapsed .nav-label,
html.is-sidebar-collapsed .nav-group-labels,
html.is-sidebar-collapsed .nav-group-chev,
html.is-sidebar-collapsed .sidebar-footer { display: none; }
html.is-sidebar-collapsed .nav-link { justify-content: center; padding: 10px; }
html.is-sidebar-collapsed .nav-group-title { justify-content: center; padding: 8px; }
html.is-sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 12px 8px;
    flex-direction: column;
    gap: 8px;
    height: auto;
    min-height: var(--topbar-height);
}
html.is-sidebar-collapsed .brand { gap: 0; }
html.is-sidebar-collapsed .sidebar-toggle { width: 36px; height: 32px; }

.sidebar-toggle {
    background: transparent; border: none; color: var(--color-text-muted);
    border-radius: 8px; width: 32px; height: 32px;
    display: grid; place-items: center;
}
.sidebar-toggle:hover { background: var(--color-surface-3); color: var(--color-text); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 10px 16px; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 10px; }

.nav-group { margin-top: 2px; padding-bottom: 2px; }
.nav-group-title {
    width: 100%;
    background: transparent; border: none;
    padding: 10px 10px 6px;
    display: flex; align-items: center; gap: 10px;
    color: var(--color-text-subtle);
    font-family: inherit;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
}
.nav-group-title:hover { color: var(--color-text); background: var(--color-surface-3); }
.nav-group-icon {
    width: 22px; height: 22px;
    display: grid; place-items: center;
    border-radius: 6px;
    background: var(--gc-soft);
    color: var(--gc-1);
    flex-shrink: 0;
}
.nav-group-icon [data-lucide] { width: 14px; height: 14px; stroke-width: 2.25; }
.nav-group-labels { flex: 1; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--gc-1); }
:root[data-theme="dark"] .nav-group-labels { color: var(--gc-2); }
.nav-group-chev { width: 14px; height: 14px; transition: transform .2s; color: var(--color-text-subtle); }
.nav-group.is-collapsed .nav-group-chev { transform: rotate(-90deg); }
.nav-group.is-collapsed .nav-list { max-height: 0; overflow: hidden; opacity: 0; pointer-events: none; }
.nav-list {
    list-style: none; margin: 0; padding: 0 0 0 4px;
    display: flex; flex-direction: column; gap: 1px;
    max-height: 800px; overflow: hidden;
    transition: max-height .25s ease, opacity .2s;
    opacity: 1;
}

.nav-item { position: relative; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--color-text-muted);
    font-size: 13px; font-weight: 500;
    transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--color-surface-3); color: var(--color-text); }
.nav-item.is-active .nav-link {
    background: linear-gradient(135deg, var(--color-primary-soft), rgba(236, 72, 153, 0.08));
    color: var(--color-primary-dark);
}
:root[data-theme="dark"] .nav-item.is-active .nav-link { color: #ffd1e0; }
.nav-item.is-active .nav-link::before {
    content: ""; position: absolute;
    left: -4px; top: 6px; bottom: 6px; width: 3px;
    background: var(--color-primary); border-radius: 4px;
}
.nav-icon { width: 20px; display: grid; place-items: center; flex-shrink: 0; }
.nav-icon [data-lucide] { width: 17px; height: 17px; }
.nav-label { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.nav-item.is-active .nav-label { font-weight: 600; }

/* Collapsed sidebar tooltips */
html.is-sidebar-collapsed .nav-item::after {
    content: attr(data-tooltip-th);
    position: absolute;
    left: calc(100% + 10px); top: 50%;
    transform: translateY(-50%);
    background: var(--color-text);
    color: var(--color-surface);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0; pointer-events: none;
    transition: opacity .15s;
    z-index: 100;
    box-shadow: var(--shadow-md);
}
html[data-lang="en"].is-sidebar-collapsed .nav-item::after { content: attr(data-tooltip-en); }
html.is-sidebar-collapsed .nav-item:hover::after { opacity: 1; }

.sidebar-empty {
    margin: 24px 12px; padding: 18px;
    text-align: center; color: var(--color-text-subtle);
    border: 1px dashed var(--color-border-strong);
    border-radius: 12px;
}
.sidebar-empty [data-lucide] { width: 24px; height: 24px; color: var(--color-border-strong); }
.sidebar-empty p { margin: 8px 0; font-size: 12.5px; }

.sidebar-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--color-border);
    font-size: 11px;
    color: var(--color-text-subtle);
    display: flex; justify-content: flex-end;
}

/* ---------- Topbar ---------- */
.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    position: sticky; top: 0; z-index: 30;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: transparent; border: 1px solid transparent;
    display: grid; place-items: center; position: relative;
    color: var(--color-text-muted); transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--color-surface-3); color: var(--color-text); }
.icon-btn .dot {
    position: absolute; width: 7px; height: 7px; border-radius: 50%;
    background: var(--color-primary); top: 8px; right: 9px;
    box-shadow: 0 0 0 2px var(--color-surface);
}

.search {
    display: flex; align-items: center; gap: 10px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0 12px;
    height: 36px;
    min-width: 340px;
    color: var(--color-text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: background .12s, border-color .12s;
}
.search:hover { background: var(--color-surface-3); border-color: var(--color-border-strong); }
.search-placeholder { flex: 1; text-align: left; font-size: 13px; color: var(--color-text-subtle); }
.search kbd {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px; font-size: 11px;
    padding: 2px 6px; color: var(--color-text-muted);
    font-family: inherit;
}

.divider { width: 1px; height: 22px; background: var(--color-border); }

/* Topbar role chip */
.topbar-role {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 12px; border-radius: 999px;
    font-size: 12.5px; font-weight: 700;
    background: var(--rc-soft); color: var(--rc-1);
    transition: transform .15s;
}
.topbar-role:hover { transform: translateY(-1px); }
.topbar-role [data-lucide] { width: 14px; height: 14px; }

/* User chip / avatar button */
.user-chip {
    display: flex; align-items: center; gap: 8px;
    padding: 3px 10px 3px 3px;
    border-radius: 999px;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-family: inherit;
}
.user-chip:hover { background: var(--color-surface-3); }
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, #a5811c, #8c6b15);
    color: white; font-weight: 700; font-size: 11.5px;
    display: grid; place-items: center;
}
.avatar.lg { width: 44px; height: 44px; font-size: 14px; }
.user-info { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.user-name { font-weight: 600; font-size: 12.5px; }
.user-role { font-size: 10.5px; color: var(--color-text-subtle); }

/* ---------- User dropdown menu ---------- */
.user-menu {
    position: fixed;
    top: calc(var(--topbar-height) + 6px);
    right: 20px;
    width: 280px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .15s, transform .15s;
}
.user-menu.is-open { opacity: 1; transform: translateY(0); }
.user-menu-header {
    display: flex; gap: 12px; align-items: center;
    padding: 16px; border-bottom: 1px solid var(--color-border);
}
.user-menu-name { font-weight: 700; font-size: 14px; }
.user-menu-email { font-size: 11.5px; color: var(--color-text-subtle); }
.user-menu-role {
    margin: 10px 14px;
    padding: 7px 10px;
    border-radius: 10px;
    background: var(--rc-soft); color: var(--rc-1);
    font-size: 12px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}
.user-menu-role [data-lucide] { width: 14px; height: 14px; }
.user-menu-section { padding: 6px; border-top: 1px solid var(--color-border); }
.user-menu-section:first-of-type { border-top: none; }
.user-menu-item {
    width: 100%; text-align: left; background: transparent; border: none;
    padding: 9px 12px; display: flex; align-items: center; gap: 10px;
    color: var(--color-text); font-size: 13px; font-family: inherit;
    border-radius: 8px; cursor: pointer;
}
.user-menu-item:hover { background: var(--color-surface-3); }
.user-menu-item [data-lucide] { width: 16px; height: 16px; color: var(--color-text-muted); }
.user-menu-danger { color: var(--color-danger); }
.user-menu-danger [data-lucide] { color: var(--color-danger); }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
    height: var(--breadcrumb-height);
    padding: 0 28px;
    display: flex; align-items: center;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}
.breadcrumb ol {
    list-style: none; margin: 0; padding: 0;
    display: flex; align-items: center; gap: 8px;
    font-size: 12.5px; color: var(--color-text-subtle);
}
.breadcrumb a { color: var(--color-text-muted); display: grid; place-items: center; }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb .sep { display: grid; place-items: center; color: var(--color-text-subtle); }
.breadcrumb .sep [data-lucide] { width: 13px; height: 13px; }
.crumb-group {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px;
    background: var(--gc-soft); color: var(--gc-1);
    font-weight: 600;
}
.crumb-group [data-lucide] { width: 13px; height: 13px; }
.crumb-current { color: var(--color-text); font-weight: 600; }

/* ---------- Page header ---------- */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 18px; gap: 16px; flex-wrap: wrap;
}
.page-head { display: flex; align-items: center; gap: 14px; }
.page-head-icon {
    width: 46px; height: 46px; border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--gc-1), var(--gc-2));
    color: white; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}
.page-head-icon [data-lucide] { width: 22px; height: 22px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.page-subtitle { color: var(--color-text-muted); margin: 2px 0 0; font-size: 13px; }
.header-actions { display: flex; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 14px; border-radius: 10px;
    font-size: 13px; font-weight: 600;
    border: 1px solid transparent;
    transition: all .15s; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn [data-lucide] { width: 16px; height: 16px; }
/* ปุ่มหลัก = ทองเข้ม + ตัวอักษรขาว (อ่านชัด) */
.btn-primary { background: linear-gradient(135deg, #a5811c, #8c6b15); color: #fff; font-weight: 600; }
.btn-primary:not(:disabled):hover { background: linear-gradient(135deg, #8c6b15, #755912); color: #fff; }
.btn-outline {
    background: var(--color-surface);
    border-color: var(--color-border-strong);
    color: var(--color-text);
}
.btn-outline:hover { background: var(--color-surface-3); }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Placeholder / Module skeleton ---------- */
.placeholder-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    max-width: 960px; margin: 0 auto;
    position: relative; overflow: hidden;
}
.placeholder-card::before {
    content: ""; position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--gc-1), var(--gc-2));
}
.placeholder-icon {
    width: 68px; height: 68px; border-radius: 18px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--gc-soft), var(--color-accent-soft));
    color: var(--gc-1);
    margin: 0 auto 14px;
}
.placeholder-icon [data-lucide] { width: 32px; height: 32px; stroke-width: 1.75; }
.placeholder-title { font-size: 20px; margin: 0 0 6px; font-weight: 700; letter-spacing: -0.01em; }
.placeholder-desc {
    color: var(--color-text-muted);
    max-width: 620px; margin: 0 auto 20px;
    line-height: 1.55; font-size: 13.5px;
}
.feature-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px; text-align: left; margin-top: 10px;
}
.feature-chip {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border-radius: 10px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    font-size: 13px; line-height: 1.4;
}
.feature-chip [data-lucide] { color: var(--color-success); width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }

.placeholder-meta { display: flex; gap: 8px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600;
}
.badge [data-lucide] { width: 13px; height: 13px; }
.badge-warn    { background: var(--color-warning-soft); color: #a15b00; }
.badge-muted   { background: var(--color-surface-3); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.badge-success { background: var(--color-success-soft); color: #0a6c4b; }
.badge-danger  { background: var(--color-danger-soft);  color: #9b1c1c; }
:root[data-theme="dark"] .badge-warn    { color: #fbbf24; }
:root[data-theme="dark"] .badge-success { color: #86efac; }
:root[data-theme="dark"] .badge-danger  { color: #fca5a5; }

/* ---------- Dashboard stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 18px;
    display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow-sm);
}
.stat-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: white; flex-shrink: 0; }
.stat-icon [data-lucide] { width: 22px; height: 22px; }
.stat-icon.bg-blue  { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.stat-icon.bg-pink  { background: linear-gradient(135deg, #e0b968, #c69a3f); }
.stat-icon.bg-green { background: linear-gradient(135deg, #10b981, #34d399); }
.stat-icon.bg-amber { background: linear-gradient(135deg, #f59e0b, #fb923c); }
.stat-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { color: var(--color-text-muted); font-size: 12px; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.stat-delta { font-size: 11.5px; color: var(--color-text-subtle); display: flex; align-items: center; gap: 4px; }
.stat-delta [data-lucide] { width: 13px; height: 13px; }
.stat-delta.up   { color: var(--color-success); }
.stat-delta.down { color: var(--color-danger); }

/* ---------- Rows / cards ---------- */
.row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; margin-top: 14px; }
.col-4  { grid-column: span 4; }
.col-6  { grid-column: span 6; }
.col-8  { grid-column: span 8; }
.col-12 { grid-column: span 12; }
@media (max-width: 1100px) { .col-4, .col-6, .col-8 { grid-column: span 12; } }

.card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden;
    display: flex; flex-direction: column;
}
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: center; }
.card-header h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.card-body { padding: 18px; flex: 1; }
.link { color: var(--color-primary); font-weight: 600; font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }
.link [data-lucide] { width: 14px; height: 14px; }
.link:hover { text-decoration: underline; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 28px 16px; color: var(--color-text-subtle); text-align: center; }
.empty-state [data-lucide] { width: 32px; height: 32px; color: var(--color-border-strong); }
.empty-state p { margin: 0; font-size: 13px; }

/* ---------- Command palette (⌘K) ---------- */
.cmdk { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; padding-top: 12vh; }
.cmdk[hidden] { display: none; }
.cmdk-backdrop { position: absolute; inset: 0; background: var(--overlay); backdrop-filter: blur(2px); }
.cmdk-panel {
    position: relative;
    background: var(--color-surface);
    width: min(640px, 92vw);
    border-radius: 16px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    align-self: flex-start;
    animation: cmdk-in .15s ease-out;
}
@keyframes cmdk-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.cmdk-search { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--color-border); }
.cmdk-search [data-lucide] { color: var(--color-text-subtle); }
.cmdk-search input { flex: 1; border: none; outline: none; background: transparent; color: var(--color-text); font-family: inherit; font-size: 15px; }
.cmdk-search kbd { background: var(--color-surface-3); border: 1px solid var(--color-border); border-radius: 6px; font-size: 10.5px; padding: 3px 7px; color: var(--color-text-muted); font-family: inherit; }
.cmdk-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.cmdk-item.is-selected { background: var(--color-surface-3); }
.cmdk-item-icon {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--gc-soft); color: var(--gc-1);
    flex-shrink: 0;
}
.cmdk-item-icon [data-lucide] { width: 17px; height: 17px; }
.cmdk-item-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cmdk-item-title { font-weight: 600; font-size: 13.5px; color: var(--color-text); }
.cmdk-item-group { font-size: 11.5px; color: var(--color-text-subtle); margin-top: 1px; }
.cmdk-item-go { color: var(--color-text-subtle); opacity: 0; transition: opacity .15s; }
.cmdk-item.is-selected .cmdk-item-go { opacity: 1; }
.cmdk-item-go [data-lucide] { width: 16px; height: 16px; }
.cmdk-empty { padding: 28px 18px; text-align: center; color: var(--color-text-subtle); font-size: 13px; }
.cmdk-footer {
    display: flex; justify-content: flex-end; gap: 16px;
    padding: 10px 16px; border-top: 1px solid var(--color-border);
    font-size: 11px; color: var(--color-text-subtle);
}
.cmdk-footer kbd { background: var(--color-surface-3); border: 1px solid var(--color-border); border-radius: 5px; font-size: 10px; padding: 2px 6px; margin-right: 3px; color: var(--color-text-muted); font-family: inherit; }

/* ---------- Toast ---------- */
.toast-container {
    position: fixed; bottom: 20px; right: 20px;
    display: flex; flex-direction: column; gap: 10px;
    z-index: 200; pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    min-width: 260px; max-width: 400px;
    animation: toast-in .2s ease-out;
    font-size: 13px;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast.is-leaving { opacity: 0; transform: translateX(20px); transition: all .2s; }
.toast-icon { width: 22px; height: 22px; display: grid; place-items: center; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-close { background: transparent; border: none; color: var(--color-text-subtle); padding: 4px; border-radius: 6px; display: grid; place-items: center; }
.toast-close:hover { color: var(--color-text); background: var(--color-surface-3); }
.toast-close [data-lucide] { width: 14px; height: 14px; }
.toast-action {
    background: transparent; border: 1px solid var(--color-border-strong);
    color: var(--color-text); cursor: pointer;
    padding: 4px 12px; border-radius: 6px; font: inherit; font-size: 12.5px;
    font-weight: 600; flex-shrink: 0;
}
.toast-action:hover { background: var(--color-surface-3); }

/* ---------- Generic "is-loading" state for icon buttons ----------
   When a click triggers async work, JS adds .is-loading; the icon child
   is hidden and a spinning border replaces it. Restores when done. */
.is-loading {
    pointer-events: none;
    position: relative;
    color: transparent !important;
}
.is-loading > [data-lucide], .is-loading > svg { visibility: hidden; }
.is-loading::after {
    content: "";
    position: absolute;
    inset: 50% auto auto 50%;
    width: 14px; height: 14px;
    margin: -7px 0 0 -7px;
    border-radius: 50%;
    border: 2px solid var(--color-border-strong);
    border-top-color: var(--color-text);
    animation: cx-spin .7s linear infinite;
}
@keyframes cx-spin { to { transform: rotate(360deg); } }

/* ---------- Global "ask for a note" modal (window.openNoteDrawer) ---------- */
.note-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 90;
}
.note-modal {
    position: fixed;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: min(440px, calc(100vw - 32px));
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    z-index: 91;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,.30);
}
.note-modal[hidden], .note-modal-backdrop[hidden] { display: none !important; }
.note-modal header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-border);
}
.note-modal header h3 { margin: 0; font-size: 15px; font-weight: 700; }
.note-modal-body { padding: 16px 18px; }
.note-modal-body textarea {
    width: 100%; min-height: 80px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit; font-size: 13.5px; resize: vertical;
}
.note-modal footer {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 12px 18px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-2);
}

/* ---------- 🔥 Incoming taunt overlay (TauntReceiver) ---------- */
.is-being-taunted {
    animation: cx-page-shake .15s infinite;
}
@keyframes cx-page-shake {
    0%,100% { transform: translate(0, 0); }
    25%     { transform: translate(-6px, -3px); }
    75%     { transform: translate(6px, 3px); }
}
.taunt-incoming {
    position: fixed; inset: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(245,158,11,.4), transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(220,38,38,.5), transparent 50%),
        rgba(15, 15, 20, .92);
    z-index: 9998;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px;
    color: #fff; text-align: center;
    padding: 20px;
    cursor: pointer;
    animation: cx-taunt-in .25s ease-out;
}
.taunt-incoming.is-leaving { animation: cx-taunt-out .25s ease-in forwards; }
@keyframes cx-taunt-in {
    0%   { opacity: 0; transform: scale(.6); }
    60%  { opacity: 1; transform: scale(1.08); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes cx-taunt-out {
    0%   { opacity: 1; }
    100% { opacity: 0; }
}
.taunt-incoming .ti-emoji {
    font-size: clamp(90px, 18vw, 160px);
    line-height: 1;
    filter: drop-shadow(0 8px 24px rgba(220,38,38,.7));
    animation: cx-emoji-rotate 1.5s ease-out;
}
@keyframes cx-emoji-rotate {
    0%   { transform: scale(0) rotate(-180deg); }
    60%  { transform: scale(1.2) rotate(20deg); }
    100% { transform: scale(1) rotate(0); }
}
.taunt-incoming .ti-badge {
    background: #fcd34d; color: #7c2d12;
    font-size: clamp(18px, 3vw, 28px); font-weight: 900;
    padding: 6px 22px; border-radius: 8px;
    letter-spacing: .04em;
    transform: rotate(-3deg);
    box-shadow: 0 6px 24px rgba(252,211,77,.5);
}
.taunt-incoming .ti-from {
    font-size: 14px; opacity: .85;
    background: rgba(0,0,0,.4); padding: 4px 14px; border-radius: 999px;
}
.taunt-incoming .ti-text {
    font-size: clamp(20px, 3.5vw, 32px); font-weight: 800;
    max-width: 90vw; line-height: 1.35;
    text-shadow: 0 2px 12px rgba(0,0,0,.5);
    padding: 12px 24px;
}
.taunt-incoming .ti-skip {
    font-size: 11px; opacity: .55; margin-top: 18px;
    text-transform: uppercase; letter-spacing: .15em;
}

/* ---------- Confetti (window.fireConfetti) ---------- */
.confetti-layer {
    position: fixed; inset: 0; pointer-events: none; z-index: 9999;
    overflow: hidden;
}
.confetti-dot {
    position: absolute; top: -20px;
    width: 9px; height: 14px; border-radius: 2px;
    animation: cx-confetti-fall linear forwards;
}
@keyframes cx-confetti-fall {
    0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
.toast--success { border-left: 3px solid var(--color-success); }
.toast--success .toast-icon { color: var(--color-success); }
.toast--error   { border-left: 3px solid var(--color-danger); }
.toast--error .toast-icon   { color: var(--color-danger); }
.toast--warning { border-left: 3px solid var(--color-warning); }
.toast--warning .toast-icon { color: var(--color-warning); }
.toast--info    { border-left: 3px solid var(--color-info); }
.toast--info .toast-icon    { color: var(--color-info); }

/* ---------- Auth / Login ---------- */
.auth-body { background: var(--color-bg); min-height: 100vh; margin: 0; }
.auth-wrapper { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-card {
    padding: 44px 52px;
    display: flex; flex-direction: column;
    background: var(--color-surface);
    max-width: 560px; width: 100%; margin: 0 auto; justify-content: center;
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand h1 { margin: 4px 0 0; font-size: 22px; letter-spacing: -0.01em; }
.auth-brand p { color: var(--color-text-muted); margin: 6px 0 0; font-size: 13px; }

.demo-banner {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--color-info-soft);
    color: var(--color-info);
    font-size: 12.5px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.demo-banner [data-lucide] { width: 16px; height: 16px; flex-shrink: 0; }

.auth-alert {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.auth-alert [data-lucide] { width: 16px; height: 16px; flex-shrink: 0; }
.auth-alert--error   { background: var(--color-danger-soft, #fee2e2); color: var(--color-danger, #b91c1c); }
.auth-alert--success { background: var(--color-success-soft, #dcfce7); color: var(--color-success, #15803d); }
.auth-alert--success .link { color: inherit; text-decoration: underline; font-weight: 600; }

.input-suffix {
    background: transparent; border: none; padding: 2px 4px;
    color: var(--color-text-subtle); cursor: pointer; display: flex; align-items: center;
}
.input-suffix:hover { color: var(--color-text); }
.input-suffix [data-lucide] { width: 18px; height: 18px; }

.field-hint { color: var(--color-text-subtle); font-size: 11.5px; margin-top: 2px; }

.pwd-strength {
    display: flex; align-items: center; gap: 10px;
    margin: -6px 0 4px;
    transition: opacity 0.15s ease;
}
.pwd-strength[aria-hidden="true"] { opacity: 0; pointer-events: none; height: 0; margin: 0; }
.pwd-strength-bar {
    flex: 1; height: 4px; border-radius: 999px; overflow: hidden;
    background: var(--color-border);
}
.pwd-strength-bar > span {
    display: block; height: 100%; width: 0;
    background: var(--color-danger);
    transition: width 0.2s ease, background 0.2s ease;
}
.pwd-strength-label { font-size: 11.5px; font-weight: 600; min-width: 56px; text-align: right; }

.auth-wrapper--narrow { grid-template-columns: 1fr; }
.auth-wrapper--narrow .auth-card { max-width: 480px; }

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--color-surface-3); color: var(--color-text); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--color-text); }
.input-wrap {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 10px;
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
}
.input-wrap:focus-within { border-color: var(--color-primary); box-shadow: var(--ring); }
.input-wrap [data-lucide] { color: var(--color-text-subtle); }
.input-wrap input { flex: 1; border: none; outline: none; background: transparent; font-family: inherit; font-size: 14px; color: var(--color-text); }
.row-between { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--color-text-muted); cursor: pointer; }

.divider-text { text-align: center; position: relative; margin: 4px 0; }
.divider-text::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--color-border); }
.divider-text span { position: relative; background: var(--color-surface); padding: 0 12px; color: var(--color-text-subtle); font-size: 12px; }

.auth-footer { display: flex; justify-content: space-between; margin-top: 30px; color: var(--color-text-subtle); font-size: 12px; }

.auth-hero {
    background:
        radial-gradient(1200px 600px at 10% 20%, rgba(216, 171, 72, 0.34), transparent 60%),
        radial-gradient(900px 500px at 90% 80%, rgba(216, 171, 72, 0.18), transparent 60%),
        linear-gradient(135deg, #8f0812, #5c0007);
    position: relative; color: white; overflow: hidden;
}
.hero-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 48px 56px; }
.hero-overlay h2 { font-size: 26px; line-height: 1.25; margin: 0 0 20px; font-weight: 700; letter-spacing: -0.01em; }
.hero-overlay ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.hero-overlay li { display: flex; align-items: center; gap: 10px; font-size: 14px; opacity: 0.92; }
.hero-overlay [data-lucide] { color: #f6edd6; }

@media (max-width: 960px) {
    .auth-wrapper { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
}

/* ---------- Role selector ---------- */
.role-body {
    min-height: 100vh;
    background:
        radial-gradient(900px 500px at 0% 0%, rgba(216, 171, 72, 0.12), transparent 60%),
        radial-gradient(800px 500px at 100% 100%, rgba(216, 171, 72, 0.08), transparent 60%),
        var(--color-bg);
    margin: 0;
}
.role-wrapper { max-width: 1280px; margin: 0 auto; padding: 32px 28px 56px; }
.role-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.role-header-brand { display: flex; gap: 14px; align-items: center; }
.role-header-brand h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.role-header-brand p { margin: 4px 0 0; color: var(--color-text-muted); font-size: 13.5px; }
.role-header-actions { display: flex; gap: 10px; align-items: center; }

.role-section { margin-bottom: 36px; }
.role-section-title { margin-bottom: 14px; }
.role-section-title .eyebrow {
    display: inline-block;
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700;
    color: var(--color-primary); margin-bottom: 4px;
}
.role-section-title h2 { font-size: 17px; margin: 0; letter-spacing: -0.01em; }
.role-section-title p { margin: 4px 0 0; color: var(--color-text-muted); font-size: 13px; }

.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }

.role-card {
    position: relative;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 20px;
    display: flex; flex-direction: column; gap: 14px;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
    overflow: hidden; min-height: 260px;
}
.role-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgba(17, 24, 39, 0.10); border-color: var(--rc-1); }
.role-card.is-current { border-color: var(--rc-1); box-shadow: 0 0 0 3px var(--rc-soft); }
.role-card-top { display: flex; justify-content: space-between; align-items: center; }
.role-card-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: grid; place-items: center; color: white;
    background: linear-gradient(135deg, var(--rc-1), var(--rc-2));
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}
.role-card-icon [data-lucide] { width: 24px; height: 24px; stroke-width: 2; }
.role-card-body { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.role-card-title { display: flex; flex-direction: column; line-height: 1.25; }
.role-card-name { font-size: 16px; font-weight: 700; color: var(--color-text); letter-spacing: -0.01em; }
.role-card-name-th { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.role-card-desc { color: var(--color-text-muted); line-height: 1.55; font-size: 13px; margin: 0; }
.role-card-highlights { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.chip {
    display: inline-flex; align-items: center;
    padding: 3px 9px; border-radius: 999px;
    background: var(--rc-soft); color: var(--rc-1);
    font-size: 10.5px; font-weight: 600;
}
.role-card-cta {
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 10px; border-top: 1px dashed var(--color-border);
    color: var(--rc-1); font-size: 13px; font-weight: 600;
}
.role-card-cta [data-lucide] { width: 16px; height: 16px; transition: transform .15s; }
.role-card:hover .role-card-cta [data-lucide] { transform: translateX(4px); }

/* Admin "pro" row — horizontal, de-emphasized */
.role-section--admin { margin-top: 8px; }
.role-pro {
    display: flex; align-items: center; gap: 18px;
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--rc-soft), var(--color-surface) 180%);
    border: 1px solid var(--rc-soft);
    border-radius: var(--radius-lg);
    color: var(--color-text);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.role-pro:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--rc-1); }
.role-pro.is-current { border-color: var(--rc-1); box-shadow: 0 0 0 3px var(--rc-soft); }
.role-pro-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: grid; place-items: center; color: white;
    background: linear-gradient(135deg, var(--rc-1), var(--rc-2));
    flex-shrink: 0;
}
.role-pro-icon [data-lucide] { width: 24px; height: 24px; }
.role-pro-body { flex: 1; min-width: 0; }
.role-pro-title { display: flex; flex-direction: column; line-height: 1.25; margin-bottom: 4px; }
.role-pro-cta { display: flex; align-items: center; gap: 8px; color: var(--rc-1); font-size: 13px; font-weight: 600; white-space: nowrap; }
.role-pro-cta [data-lucide] { width: 16px; height: 16px; }

.role-footer { margin-top: 28px; text-align: center; }
.muted { color: var(--color-text-subtle); font-size: 12.5px; }

@media (max-width: 600px) {
    .role-wrapper { padding: 22px 14px 40px; }
    .role-card { min-height: auto; padding: 16px; }
    .role-pro { flex-direction: column; align-items: flex-start; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-area { margin-left: 0 !important; }
    .search { min-width: 0; }
    .search-placeholder { display: none; }
}
@media (max-width: 680px) {
    .content { padding: 16px; }
    .breadcrumb { padding: 0 16px; }
    .user-info { display: none; }
    .topbar-role span { display: none; }
    .topbar { padding: 0 14px; }
}

/* ---------- Procedure picker (group -> procedure) ---------- */
.proc-picker { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.proc-picker .pp-group { flex: 0 0 auto; min-width: 130px; max-width: 170px; }
.proc-picker .pp-name, .proc-picker .pp-custom { flex: 1; min-width: 150px; }
.proc-picker select[hidden], .proc-picker input[hidden] { display: none; }

/* ---------- OR rooms/calendar sub-tabs ---------- */
.or-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: 16px; }
.or-tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; font-size: 13.5px; font-weight: 600;
    color: var(--color-text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.or-tab:hover { color: var(--color-text); }
.or-tab.is-active { color: var(--color-primary, #6366f1); border-bottom-color: var(--color-primary, #6366f1); }

/* ============================================================
   Mobile responsive layer (≤768px) — additive only.
   Desktop (769px+) is unaffected by anything below this line.
   ============================================================ */
@media (max-width: 768px) {
    /* RESP-001 — images never exceed their container */
    img { max-width: 100%; height: auto; }

    /* RESP-002 — comfortable tap targets (≥44px) on touch screens */
    .btn { min-height: 44px; }
    .icon-btn { min-width: 44px; min-height: 44px; }
    .user-chip { min-height: 44px; }
    .nav-link { min-height: 44px; }

    /* RESP-005 — dim scrim behind the off-canvas sidebar (created by main.js) */
    .sidebar-scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 39; }
    .sidebar-scrim[hidden] { display: none; }
}
