/* ==========================================================================
   Taqam HR — design system (app, console, portal)
   RTL-first with logical properties; light + dark themes via [data-theme]
   ========================================================================== */

:root {
  --font: "Plex Arabic", "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", monospace;

  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --fs-md: 15px; --fs-lg: 17px;
  --fs-xl: 20px; --fs-2xl: 24px; --fs-3xl: 30px;

  /* Brand — deep teal */
  --brand-50: #eef7f4; --brand-100: #d6ede6; --brand-200: #aad9cb; --brand-300: #75bfaa;
  --brand-400: #3f9f88; --brand-500: #1a8470; --brand-600: #127265; --brand-700: #0e5a50;
  --brand-800: #0c4740; --brand-900: #0a3631;
  --accent: #d9952e; --accent-soft: #fdf4e6; --accent-text: #8a5a12;

  /* Neutrals (green-tinted gray) */
  --gray-25: #fafbfa; --gray-50: #f4f6f5; --gray-100: #eceff0; --gray-150: #e7ebe9; --gray-200: #dfe4e1;
  --gray-300: #c7cfca; --gray-400: #9ba6a1; --gray-500: #6f7b76; --gray-600: #525e5a;
  --gray-700: #3b4542; --gray-800: #252d2b; --gray-900: #161c1a;

  /* Semantic */
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --surface-3: #f1f4f2;
  --border: #e1e6e3;
  --border-strong: #cbd3ce;
  --text: #161c1a;
  --text-2: #3b4542;
  --muted: #6b7772;
  --faint: #98a39e;
  --primary: var(--brand-600);
  --primary-hover: var(--brand-700);
  --primary-soft: var(--brand-50);
  --primary-soft-2: var(--brand-100);
  --primary-text: var(--brand-700);
  --on-primary: #ffffff;
  --ring: 0 0 0 3px rgba(18, 114, 101, .20);

  --success: #15803d; --success-soft: #eaf6ee; --success-text: #166534; --success-border: #bfe3cb;
  --warning: #b45309; --warning-soft: #fdf3e3; --warning-text: #8a4209; --warning-border: #f3d6a8;
  --danger: #c2362b;  --danger-soft: #fcedeb;  --danger-text: #a12a21;  --danger-border: #f2c3bd;
  --info: #2563eb;    --info-soft: #ebf1fe;    --info-text: #1e4fc2;    --info-border: #c5d6fb;

  --radius-xs: 4px; --radius-sm: 6px; --radius: 8px; --radius-md: 10px; --radius-lg: 12px; --radius-xl: 16px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 22, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 22, .07), 0 1px 2px rgba(16, 24, 22, .04);
  --shadow-md: 0 8px 20px -6px rgba(16, 24, 22, .14), 0 2px 6px -2px rgba(16, 24, 22, .06);
  --shadow-lg: 0 24px 48px -16px rgba(16, 24, 22, .28);

  --sidebar-w: 268px;
  --topbar-h: 60px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Sidebar (company app = light) */
  --side-bg: #ffffff;
  --side-border: var(--border);
  --side-text: #3b4542;
  --side-icon: #7b8782;
  --side-group: #9aa5a0;
  --side-hover: #f3f6f4;
  --side-active-bg: var(--brand-50);
  --side-active-text: var(--brand-700);
  --side-active-bar: var(--brand-600);

  color-scheme: light;
}

/* Console uses an ink sidebar to make the SaaS-owner area unmistakable */
.theme-console {
  --side-bg: #0f1d1a;
  --side-border: #1b2b27;
  --side-text: #c6d3cf;
  --side-icon: #7f938d;
  --side-group: #5d706a;
  --side-hover: #172a26;
  --side-active-bg: #1b3a34;
  --side-active-text: #ffffff;
  --side-active-bar: #3fbfa5;
}

[data-theme="dark"] {
  --bg: #0b1110;
  --surface: #111917;
  --surface-2: #0f1614;
  --surface-3: #17211e;
  --border: #213029;
  --border-strong: #2f413b;
  --text: #e6eeeb;
  --text-2: #c2cec9;
  --muted: #8d9d97;
  --faint: #64746e;
  --primary: #23a28c;
  --primary-hover: #2db69e;
  --primary-soft: rgba(35, 162, 140, .13);
  --primary-soft-2: rgba(35, 162, 140, .22);
  --primary-text: #6fd3bf;
  --ring: 0 0 0 3px rgba(35, 162, 140, .30);
  --success: #2fb36a; --success-soft: rgba(47, 179, 106, .12); --success-text: #6fdc9f; --success-border: rgba(47, 179, 106, .3);
  --warning: #e39b3a; --warning-soft: rgba(227, 155, 58, .12); --warning-text: #f2c27e; --warning-border: rgba(227, 155, 58, .3);
  --danger: #ef6a5e;  --danger-soft: rgba(239, 106, 94, .12);  --danger-text: #f6a39b;  --danger-border: rgba(239, 106, 94, .3);
  --info: #5b8ff5;    --info-soft: rgba(91, 143, 245, .12);    --info-text: #9dbcfa;    --info-border: rgba(91, 143, 245, .3);
  --accent-soft: rgba(217, 149, 46, .14); --accent-text: #f0c27a;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .45);
  --shadow-md: 0 10px 24px -8px rgba(0, 0, 0, .6);
  --shadow-lg: 0 28px 56px -18px rgba(0, 0, 0, .75);
  --side-bg: #0e1513;
  --side-border: #1c2925;
  --side-text: #c2cec9;
  --side-icon: #7f908a;
  --side-group: #5b6b66;
  --side-hover: #16201d;
  --side-active-bg: rgba(35, 162, 140, .15);
  --side-active-text: #8fe3d1;
  --side-active-bar: #23a28c;
  color-scheme: dark;
}

/* --------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.35; font-weight: 600; color: var(--text); }
p { margin: 0; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
small { font-size: var(--fs-xs); }
::selection { background: var(--primary-soft-2); color: var(--text); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
code, kbd, .mono { font-family: var(--font-mono); font-size: .92em; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num { font-variant-numeric: tabular-nums; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-xs { width: 14px; height: 14px; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; stroke-width: 1.5; }
[dir="rtl"] .icon-flip { transform: scaleX(-1); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; } }

/* --------------------------------------------------------------- app shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--side-bg);
  border-inline-end: 1px solid var(--side-border);
  color: var(--side-text);
  z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; height: var(--topbar-h); border-bottom: 1px solid var(--side-border); }
.sidebar-brand .logo-mark { width: 30px; height: 30px; flex: none; }
.sidebar-brand .brand-name { font-weight: 700; font-size: 17px; color: var(--side-active-text); letter-spacing: 0; }
.theme-console .sidebar-brand .brand-name { color: #fff; }
.sidebar-brand .brand-tag { font-size: 11px; color: var(--side-group); display: block; line-height: 1.2; font-weight: 500; }
.sidebar-tenant { margin: 12px 12px 4px; padding: 10px 12px; border: 1px solid var(--side-border); border-radius: var(--radius-md); display: flex; align-items: center; gap: 10px; }
.sidebar-tenant .t-name { font-weight: 600; font-size: 13px; color: var(--text); line-height: 1.3; }
.theme-console .sidebar-tenant .t-name { color: #fff; }
.sidebar-tenant .t-plan { font-size: 11.5px; color: var(--side-group); }

.nav { flex: 1; overflow-y: auto; padding: 8px 10px 16px; scrollbar-width: thin; }
.nav-group + .nav-group { margin-top: 14px; }
.nav-title { font-size: 11.5px; font-weight: 600; color: var(--side-group); padding: 6px 10px 4px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin: 1px 0; border-radius: var(--radius);
  color: var(--side-text); font-size: 13.5px; font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-link .icon { color: var(--side-icon); width: 18px; height: 18px; }
.nav-link:hover { background: var(--side-hover); text-decoration: none; color: var(--side-text); }
.nav-link.is-active { background: var(--side-active-bg); color: var(--side-active-text); font-weight: 600; }
.nav-link.is-active .icon { color: var(--side-active-bar); }
.nav-link.is-active::before { content: ""; position: absolute; inset-inline-start: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--side-active-bar); }
[dir="rtl"] .nav-link.is-active::before { border-radius: 3px 0 0 3px; }
.nav-link.is-locked { opacity: .55; }
.nav-badge { margin-inline-start: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; }
.nav-lock { margin-inline-start: auto; color: var(--side-group); }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--side-border); font-size: 12px; color: var(--side-group); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-search { position: relative; flex: 1; max-width: 420px; }
.topbar-search .icon { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.topbar-search input { width: 100%; height: 38px; padding-inline: 36px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }
.topbar-search input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); background: var(--surface); }
.topbar-end { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.topbar-btn { position: relative; width: 38px; height: 38px; border-radius: var(--radius); border: 0; background: transparent; color: var(--text-2); display: inline-grid; place-items: center; }
.topbar-btn:hover { background: var(--surface-3); }
.topbar-btn .dot { position: absolute; top: 8px; inset-inline-end: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface); }
.menu-toggle { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 10px; border-radius: var(--radius-md); border: 0; background: transparent; text-align: start; }
[dir="rtl"] .user-chip { padding: 4px 10px 4px 6px; }
.user-chip:hover { background: var(--surface-3); }
.user-chip .u-name { font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--text); }
.user-chip .u-role { font-size: 11.5px; color: var(--muted); line-height: 1.2; }

.content { padding: 24px 28px 56px; width: 100%; max-width: 1480px; margin-inline: auto; }
.content-narrow { max-width: 980px; }

.banner { display: flex; align-items: center; gap: 10px; padding: 10px 28px; font-size: 13px; border-bottom: 1px solid; }
.banner-warning { background: var(--warning-soft); color: var(--warning-text); border-color: var(--warning-border); }
.banner-danger { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-border); }
.banner-info { background: var(--info-soft); color: var(--info-text); border-color: var(--info-border); }
.banner a { color: inherit; font-weight: 600; text-decoration: underline; }
.banner .btn { margin-inline-start: auto; }

.sidebar-backdrop { display: none; }

@media (max-width: 1080px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(var(--sidebar-w), 86vw); transform: translateX(-100%); transition: transform .22s var(--ease); box-shadow: var(--shadow-lg); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(8, 14, 12, .45); z-index: 35; }
  .menu-toggle { display: inline-grid; }
  .topbar { padding: 0 14px; }
  .content { padding: 18px 16px 48px; }
  .user-chip .u-meta { display: none; }
}

/* --------------------------------------------------------------- page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head-main { min-width: 0; }
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--primary-text); }
.breadcrumbs .sep { color: var(--faint); }
.page-title { font-size: 22px; font-weight: 700; line-height: 1.3; }
.page-sub { margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --------------------------------------------------------------- layout utils */
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid-side-main { display: grid; gap: 20px; grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main-side, .grid-side-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-nowrap { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.stack-lg > * + * { margin-top: 24px; }
.ms-auto { margin-inline-start: auto; }
.me-auto { margin-inline-end: auto; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 24px; } .mt-6 { margin-top: 32px; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 24px; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.w-100 { width: 100%; }
.text-muted { color: var(--muted); }
.text-faint { color: var(--faint); }
.text-success { color: var(--success-text); }
.text-danger { color: var(--danger-text); }
.text-warning { color: var(--warning-text); }
.text-primary { color: var(--primary-text); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-lg { font-size: var(--fs-lg); }
.text-end { text-align: end; }
.text-center { text-align: center; }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.hide-mobile { } @media (max-width: 760px) { .hide-mobile { display: none !important; } }
.show-mobile { display: none !important; } @media (max-width: 760px) { .show-mobile { display: initial !important; } }

/* --------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); min-height: 56px; flex-wrap: wrap; }
.card-head.no-border { border-bottom: 0; padding-bottom: 0; }
.card-title { font-size: var(--fs-md); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title .icon { color: var(--muted); }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-actions { display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 14px 16px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-flush > .table-wrap { border: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-flush > .table-wrap:first-child { border-radius: var(--radius-lg); }
.card + .card { margin-top: 16px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 4px 0 10px; }

/* --------------------------------------------------------------- stats */
.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow-xs); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--text); }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-inline-start: 4px; }
.stat-meta { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-meta .up { color: var(--success-text); } .stat-meta .down { color: var(--danger-text); }
.stat-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); flex: none; }
.stat-icon.tone-success { background: var(--success-soft); color: var(--success-text); }
.stat-icon.tone-warning { background: var(--warning-soft); color: var(--warning-text); }
.stat-icon.tone-danger { background: var(--danger-soft); color: var(--danger-text); }
.stat-icon.tone-info { background: var(--info-soft); color: var(--info-text); }
.stat-icon.tone-accent { background: var(--accent-soft); color: var(--accent-text); }
.stat.is-highlight { background: linear-gradient(160deg, var(--brand-700), var(--brand-900)); border-color: transparent; color: #fff; }
.stat.is-highlight .stat-label, .stat.is-highlight .stat-meta { color: rgba(255, 255, 255, .72); }
.stat.is-highlight .stat-value { color: #fff; }
.stat.is-highlight .stat-icon { background: rgba(255, 255, 255, .12); color: #fff; }

/* --------------------------------------------------------------- buttons */
.btn {
  --btn-h: 38px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--btn-h); padding: 0 14px; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 600; line-height: 1; white-space: nowrap; text-decoration: none !important;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn.is-disabled { opacity: .55; pointer-events: none; }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 1px 2px rgba(16, 24, 22, .12); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-3); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-soft { background: var(--primary-soft); color: var(--primary-text); }
.btn-soft:hover { background: var(--primary-soft-2); color: var(--primary-text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger-text); }
.btn-danger-soft:hover { border-color: var(--danger-border); color: var(--danger-text); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.93); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-sm { --btn-h: 32px; padding: 0 11px; font-size: 12.5px; gap: 6px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-xs { --btn-h: 26px; padding: 0 8px; font-size: 12px; gap: 4px; border-radius: var(--radius-sm); }
.btn-xs .icon { width: 14px; height: 14px; }
.btn-lg { --btn-h: 46px; padding: 0 20px; font-size: 15px; border-radius: var(--radius-md); }
.btn-icon { width: var(--btn-h); padding: 0; }
.btn-block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: rgba(255, 255, 255, .9) rgba(255, 255, 255, .9) transparent transparent; animation: spin .7s linear infinite; }
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after, .btn-soft.is-loading::after { border-color: var(--primary) var(--primary) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-start-start-radius: var(--radius); border-end-start-radius: var(--radius); }
.btn-group .btn:last-child { border-start-end-radius: var(--radius); border-end-end-radius: var(--radius); }
.btn-group .btn + .btn { margin-inline-start: -1px; }

/* --------------------------------------------------------------- forms */
.form-grid { display: grid; gap: 16px 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 900px) { .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: minmax(0, 1fr); } .form-grid .span-2 { grid-column: auto; } }

.form-section { padding: 20px 0; border-top: 1px solid var(--border); display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section-title { font-size: 15px; font-weight: 600; }
.form-section-desc { font-size: 13px; color: var(--muted); margin-top: 4px; }
@media (max-width: 900px) { .form-section { grid-template-columns: minmax(0, 1fr); gap: 12px; } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.label .req, .req { color: var(--danger); font-weight: 700; }
.label .opt { color: var(--faint); font-weight: 400; font-size: 12px; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.field-error { font-size: 12.5px; color: var(--danger-text); font-weight: 500; }

.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 14px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--gray-400); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.textarea { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.6; resize: vertical; }
.input-sm, .select-sm { height: 34px; font-size: 13px; }
.input[type="number"] { font-variant-numeric: tabular-nums; }
.input[type="date"], .input[type="time"], .input[type="datetime-local"], .input[type="month"] { font-variant-numeric: tabular-nums; }
.select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7772' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6 -6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-inline-end: 34px;
}
[dir="rtl"] .select { background-position: left 10px center; }
select[multiple].select { height: auto; min-height: 120px; padding: 6px; background-image: none; }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--danger); }
.has-error .input:focus, .has-error .select:focus { box-shadow: 0 0 0 3px rgba(194, 54, 43, .18); }

.input-group { display: flex; align-items: stretch; }
.input-group .input, .input-group .select { border-radius: 0; flex: 1; min-width: 0; }
.input-group > :first-child { border-start-start-radius: var(--radius); border-end-start-radius: var(--radius); }
.input-group > :last-child { border-start-end-radius: var(--radius); border-end-end-radius: var(--radius); }
.input-group > * + * { margin-inline-start: -1px; }
.input-addon { display: inline-flex; align-items: center; padding: 0 12px; background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--muted); font-size: 13px; white-space: nowrap; }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: 12px; color: var(--faint); pointer-events: none; }
.input-icon > .input { padding-inline-start: 38px; }

.check, .radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.check input, .radio input { width: 17px; height: 17px; accent-color: var(--primary); margin: 0; flex: none; cursor: pointer; }
.checks-inline { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.day-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.day-picker label { position: relative; }
.day-picker input { position: absolute; opacity: 0; pointer-events: none; }
.day-picker span { display: inline-grid; place-items: center; min-width: 52px; height: 34px; padding: 0 10px; border-radius: var(--radius); border: 1px solid var(--border-strong); font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer; background: var(--surface); transition: all .15s var(--ease); }
.day-picker input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.day-picker input:focus-visible + span { box-shadow: var(--ring); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; color: var(--text-2); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--gray-300); transition: background .18s var(--ease); flex: none; }
[data-theme="dark"] .switch-track { background: #34433e; }
.switch-track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .18s var(--ease); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
[dir="rtl"] .switch input:checked + .switch-track::after { transform: translateX(-16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }

.radio-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.radio-card { position: relative; display: flex; gap: 10px; padding: 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); cursor: pointer; background: var(--surface); transition: border-color .15s, box-shadow .15s, background .15s; }
.radio-card input { position: absolute; opacity: 0; }
.radio-card .rc-title { font-weight: 600; font-size: 13.5px; }
.radio-card .rc-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.radio-card .rc-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); flex: none; }
.radio-card:hover { border-color: var(--gray-400); }
.radio-card:has(input:checked) { border-color: var(--primary); box-shadow: var(--ring); background: var(--primary-soft); }
.radio-card:has(input:checked) .rc-icon { background: var(--primary); color: #fff; }

.form-actions { display: flex; align-items: center; gap: 10px; padding-top: 18px; margin-top: 8px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.form-actions.sticky { position: sticky; bottom: 0; background: var(--surface); padding: 14px 20px; margin: 0 -20px -20px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); z-index: 5; }

.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 28px 20px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-2); color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.dropzone .dz-title { font-weight: 600; color: var(--text); }
.dropzone .dz-files { font-size: 12.5px; color: var(--primary-text); font-weight: 600; }
.dropzone input[type="file"] { display: none; }

/* --------------------------------------------------------------- filters / toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.filters .field { gap: 4px; }
.filters .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.filters .input, .filters .select { height: 36px; font-size: 13px; min-width: 150px; }
.filters .input-search { min-width: 220px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.chip.is-active, a.chip.is-active { background: var(--primary-soft); border-color: var(--primary-soft-2); color: var(--primary-text); }
a.chip:hover { text-decoration: none; border-color: var(--border-strong); }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--radius-md); background: var(--surface-3); border: 1px solid var(--border); gap: 2px; }
.segmented a, .segmented button { height: 30px; padding: 0 12px; border-radius: 7px; border: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.segmented a:hover { text-decoration: none; color: var(--text); }
.segmented .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* --------------------------------------------------------------- tables */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12.5px; text-align: start; padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tfoot td { background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--border-strong); border-bottom: 0; padding: 12px 16px; }
.table .num, .table td.num, .table th.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .center { text-align: center; }
.table-compact td { padding: 8px 12px; }
.table-compact th { padding: 8px 12px; }
.table tr.is-clickable { cursor: pointer; }
.table tr.row-danger td { background: color-mix(in srgb, var(--danger-soft) 70%, transparent); }
.table tr.row-warning td { background: color-mix(in srgb, var(--warning-soft) 70%, transparent); }
.table tr.row-success td { background: color-mix(in srgb, var(--success-soft) 70%, transparent); }
.table tr.row-muted td { background: var(--surface-2); color: var(--muted); }
.table .col-check { width: 40px; }
.table .col-actions { width: 1%; white-space: nowrap; text-align: end; }
.cell-actions { display: inline-flex; align-items: center; gap: 2px; justify-content: flex-end; }
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-user .cu-name { font-weight: 600; color: var(--text); line-height: 1.3; display: block; }
.cell-user .cu-sub { font-size: 12px; color: var(--muted); line-height: 1.3; display: block; }
.cell-user a.cu-name:hover { color: var(--primary-text); }
.table-sticky-first td:first-child, .table-sticky-first th:first-child { position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 2; }
.table-sticky-first th:first-child { background: var(--surface-2); z-index: 3; }
.table-matrix th, .table-matrix td { padding: 6px 8px; text-align: center; font-size: 12px; border-inline-start: 1px solid var(--border); }
.table-empty { padding: 36px 16px !important; text-align: center; color: var(--muted); }

/* --------------------------------------------------------------- badges */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1; border: 1px solid transparent; }
.badge-neutral { background: var(--surface-3); color: var(--text-2); border-color: var(--border); }
.badge-brand { background: var(--primary-soft); color: var(--primary-text); border-color: var(--primary-soft-2); }
.badge-success { background: var(--success-soft); color: var(--success-text); border-color: var(--success-border); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); border-color: var(--warning-border); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-border); }
.badge-info { background: var(--info-soft); color: var(--info-text); border-color: var(--info-border); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-lg { height: 26px; padding: 0 11px; font-size: 12.5px; }
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* --------------------------------------------------------------- alerts / flash */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid; font-size: 13.5px; line-height: 1.6; }
.alert > .icon { margin-top: 2px; }
.alert-title { font-weight: 600; }
.alert-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning-text); }
.alert-danger, .alert-error { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
.alert-info { background: var(--info-soft); border-color: var(--info-border); color: var(--info-text); }
.alert-neutral { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.alert .alert-close { margin-inline-start: auto; background: transparent; border: 0; color: inherit; opacity: .7; padding: 0; }
.flash-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }

/* --------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-bottom: 20px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; color: var(--muted); font-weight: 600; font-size: 13.5px; white-space: nowrap; border: 0; background: none; text-decoration: none !important; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary-text); }
.tab.is-active::after { content: ""; position: absolute; inset-inline: 10px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--primary); }
.tab .count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); font-size: 11.5px; display: inline-grid; place-items: center; color: var(--muted); }
.tab.is-active .count { background: var(--primary-soft); color: var(--primary-text); }
.card > .tabs { padding: 0 12px; margin-bottom: 0; }
.tab-panel:not(.is-active) { display: none; }

/* --------------------------------------------------------------- modal */
dialog.modal { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.modal[open] { display: flex; flex-direction: column; animation: modal-in .2s var(--ease); }
dialog.modal::backdrop { background: rgba(8, 15, 13, .48); backdrop-filter: blur(2px); }
dialog.modal.modal-lg { width: min(860px, calc(100vw - 32px)); }
dialog.modal.modal-sm { width: min(420px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { margin-inline-start: auto; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.modal-foot .me-auto { margin-inline-end: auto; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.confirm-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--danger-soft); color: var(--danger-text); margin-bottom: 12px; }

/* --------------------------------------------------------------- dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); z-index: 60; display: none; }
.dropdown-menu.align-start { inset-inline-end: auto; inset-inline-start: 0; }
.dropdown.is-open > .dropdown-menu { display: block; animation: modal-in .14s var(--ease); }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 7px; border: 0; background: none; color: var(--text-2); font-size: 13.5px; text-align: start; text-decoration: none !important; }
.dropdown-item .icon { color: var(--muted); }
.dropdown-item:hover { background: var(--surface-3); color: var(--text); }
.dropdown-item.is-danger { color: var(--danger-text); }
.dropdown-item.is-danger .icon { color: var(--danger-text); }
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.dropdown-head { padding: 8px 10px 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.notif-menu { width: 360px; max-width: calc(100vw - 24px); padding: 0; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-2); text-decoration: none !important; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.is-unread { background: color-mix(in srgb, var(--primary-soft) 60%, transparent); }
.notif-item .n-title { font-weight: 600; font-size: 13px; color: var(--text); }
.notif-item .n-body { font-size: 12.5px; color: var(--muted); }
.notif-item .n-time { font-size: 11.5px; color: var(--faint); margin-top: 2px; }

/* --------------------------------------------------------------- avatar */
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; overflow: hidden; font-size: 13px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 76px; height: 76px; font-size: 24px; border-radius: 18px; }
.tint-1 { background: #dcefe9; color: #0e5a50; } .tint-2 { background: #e2ebfd; color: #1e4fc2; } .tint-3 { background: #fbecd6; color: #8a4f0f; }
.tint-4 { background: #f8e1e6; color: #9b2c4a; } .tint-5 { background: #ebe4fb; color: #5b3aa8; } .tint-6 { background: #e5eaee; color: #3a4a57; }
[data-theme="dark"] .tint-1 { background: #173a33; color: #8fe3d1; } [data-theme="dark"] .tint-2 { background: #1b2a4a; color: #9dbcfa; } [data-theme="dark"] .tint-3 { background: #3a2a12; color: #f2c27e; }
[data-theme="dark"] .tint-4 { background: #3d1c25; color: #f3a6b8; } [data-theme="dark"] .tint-5 { background: #2a2042; color: #c4b2f4; } [data-theme="dark"] .tint-6 { background: #222c33; color: #b8c6d1; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-inline-start: -8px; }

/* --------------------------------------------------------------- key-value / profile */
.kv { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); margin: 0; }
.kv dt, .kv dd { margin: 0; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.kv dt:nth-last-child(2), .kv dd:last-child { border-bottom: 0; }

.profile-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; padding: 20px; }
.profile-info { flex: 1; min-width: 220px; }
.profile-name { font-size: 21px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; color: var(--muted); font-size: 13px; }
.profile-meta span { display: inline-flex; align-items: center; gap: 6px; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 1px solid var(--border); }
.profile-stats > div { padding: 14px 20px; border-inline-end: 1px solid var(--border); }
.profile-stats > div:last-child { border-inline-end: 0; }
.profile-stats .ps-label { font-size: 12px; color: var(--muted); }
.profile-stats .ps-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* --------------------------------------------------------------- empty / progress / timeline */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 24px; color: var(--muted); }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); margin-bottom: 6px; }
.empty-icon .icon { width: 26px; height: 26px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); }
.empty-text { font-size: 13.5px; max-width: 420px; }
.empty .btn { margin-top: 8px; }

.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; border-radius: inherit; background: var(--primary); transition: width .3s var(--ease); }
.progress-bar.tone-warning { background: var(--warning); }
.progress-bar.tone-danger { background: var(--danger); }
.progress-sm { height: 5px; }

.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; inset-inline-start: -22px; top: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); }
.timeline-dot.tone-danger { border-color: var(--danger); } .timeline-dot.tone-warning { border-color: var(--warning); } .timeline-dot.tone-info { border-color: var(--info); } .timeline-dot.tone-neutral { border-color: var(--gray-400); }
.timeline-title { font-weight: 600; font-size: 13.5px; }
.timeline-meta { font-size: 12px; color: var(--muted); }
.timeline-body { font-size: 13px; color: var(--text-2); margin-top: 4px; }

/* --------------------------------------------------------------- list rows */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 13.5px; }
.list-item .li-sub { font-size: 12.5px; color: var(--muted); }
a.list-item { color: inherit; text-decoration: none; }
a.list-item:hover { background: var(--surface-2); }

/* --------------------------------------------------------------- calendar */
.cal { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.cal-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-head div { padding: 8px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-day { min-height: 98px; padding: 6px 8px; border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day:nth-child(7n) { border-inline-end: 0; }
.cal-day .cd-num { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.cal-day.is-muted { background: var(--surface-2); }
.cal-day.is-muted .cd-num { color: var(--faint); }
.cal-day.is-weekend { background: repeating-linear-gradient(135deg, transparent, transparent 6px, var(--surface-2) 6px, var(--surface-2) 12px); }
.cal-day.is-today .cd-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; }
.cal-event { display: block; font-size: 11.5px; font-weight: 600; padding: 2px 6px; border-radius: 5px; background: var(--primary-soft); color: var(--primary-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-inline-start: 3px solid currentColor; }
@media (max-width: 760px) { .cal-day { min-height: 64px; padding: 4px; } .cal-event { font-size: 10px; } }

/* Attendance strip (one cell per day) */
.att-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); gap: 4px; }
.att-cell { height: 26px; border-radius: 6px; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; color: var(--text-2); background: var(--surface-3); }
.att-cell.s-present { background: var(--success-soft); color: var(--success-text); }
.att-cell.s-late { background: var(--warning-soft); color: var(--warning-text); }
.att-cell.s-absent { background: var(--danger-soft); color: var(--danger-text); }
.att-cell.s-leave, .att-cell.s-mission { background: var(--info-soft); color: var(--info-text); }
.att-cell.s-incomplete { background: var(--accent-soft); color: var(--accent-text); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* --------------------------------------------------------------- steps */
.steps { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.step .step-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--border-strong); font-size: 12px; background: var(--surface); }
.step.is-active { color: var(--text); }
.step.is-active .step-num { border-color: var(--primary); background: var(--primary); color: #fff; }
.step.is-done .step-num { border-color: var(--primary); color: var(--primary-text); background: var(--primary-soft); }
.step-sep { width: 32px; height: 1.5px; background: var(--border-strong); }

/* --------------------------------------------------------------- pagination */
.pagination-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-link { min-width: 32px; height: 32px; padding: 0 8px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); display: inline-grid; place-items: center; font-weight: 600; font-size: 12.5px; text-decoration: none !important; }
.page-link:hover { background: var(--surface-3); }
.page-link.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.is-disabled { opacity: .45; pointer-events: none; }

/* --------------------------------------------------------------- toasts */
.toasts { position: fixed; z-index: 100; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 12px; background: var(--gray-900); color: #fff; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; animation: toast-in .22s var(--ease); }
[data-theme="dark"] .toast { background: #26332f; }
.toast .icon { width: 18px; height: 18px; }
.toast.t-success .icon { color: #5ee3a1; } .toast.t-error .icon { color: #ff8f84; } .toast.t-warning .icon { color: #ffc56e; } .toast.t-info .icon { color: #8fb4ff; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------- charts / misc */
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 180px; }
.chart-box.lg { height: 320px; }
.kbd { display: inline-block; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); background: var(--surface-2); font-size: 11.5px; font-family: var(--font-mono); }
.code-box { direction: ltr; text-align: left; font-family: var(--font-mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.copy-field { display: flex; gap: 6px; align-items: center; }
.copy-field .code-box { flex: 1; padding: 8px 10px; }
.money-pos { color: var(--success-text); }
.money-neg { color: var(--danger-text); }
.map-box { height: 340px; border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: hidden; z-index: 0; }
.leaflet-container { font-family: var(--font) !important; }
.loading-overlay { position: relative; }
.loading-overlay.is-loading::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--surface) 60%, transparent); border-radius: inherit; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: spin .7s linear infinite; display: inline-block; }
.lock-note { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--accent-soft); color: var(--accent-text); font-size: 13px; }

/* --------------------------------------------------------------- auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); background: var(--surface); }
.auth-form-side { display: flex; flex-direction: column; padding: 28px clamp(20px, 6vw, 72px); }
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 18px; text-decoration: none !important; }
.auth-logo .logo-mark { width: 32px; height: 32px; }
.auth-center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 0; }
.auth-card { width: 100%; max-width: 400px; }
.auth-title { font-size: 26px; font-weight: 700; line-height: 1.3; }
.auth-sub { color: var(--muted); margin-top: 6px; font-size: 14px; }
.auth-card form { margin-top: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth-card .input { height: 46px; font-size: 15px; }
.auth-card .btn-lg { width: 100%; }
.auth-foot { font-size: 12.5px; color: var(--faint); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth-brand-side { position: relative; overflow: hidden; background: #0c2723; color: #e8f3f0; display: flex; flex-direction: column; justify-content: space-between; padding: 48px clamp(28px, 5vw, 64px); }
.auth-brand-side::before { content: ""; position: absolute; inset: 0; background:
  radial-gradient(900px 500px at 85% -10%, rgba(63, 191, 165, .28), transparent 60%),
  radial-gradient(600px 400px at -10% 110%, rgba(217, 149, 46, .16), transparent 60%); }
.auth-brand-side::after { content: ""; position: absolute; inset: 0; opacity: .5; background-image: linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent); }
.auth-brand-side > * { position: relative; z-index: 1; }
.auth-quote { font-size: clamp(22px, 2.4vw, 30px); font-weight: 700; line-height: 1.45; max-width: 520px; color: #fff; }
.auth-quote em { font-style: normal; color: #7fe0c9; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; max-width: 480px; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: rgba(232, 243, 240, .86); font-size: 14px; line-height: 1.6; }
.auth-points .icon { color: #7fe0c9; margin-top: 3px; }
.auth-panel { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); border-radius: 16px; padding: 18px; backdrop-filter: blur(6px); max-width: 420px; }
.auth-panel .ap-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, .08); font-size: 13px; }
.auth-panel .ap-row:last-child { border-bottom: 0; }
.auth-panel .ap-k { color: rgba(232, 243, 240, .7); }
.auth-panel .ap-v { font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; }
.auth-panel .ap-v.pos { color: #7fe0c9; } .auth-panel .ap-v.neg { color: #ffb3a8; }
.auth-portal .auth-brand-side { background: #10231f; }
@media (max-width: 960px) { .auth { grid-template-columns: minmax(0, 1fr); } .auth-brand-side { display: none; } }

/* --------------------------------------------------------------- error pages */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.error-box { text-align: center; max-width: 460px; }
.error-code { font-size: 64px; font-weight: 700; color: var(--primary); line-height: 1; font-variant-numeric: tabular-nums; }
.error-title { font-size: 20px; font-weight: 700; margin-top: 12px; }
.error-text { color: var(--muted); margin-top: 8px; }
.error-box .row { justify-content: center; margin-top: 22px; }

/* --------------------------------------------------------------- portal (employee self-service) */
.portal-body { background: var(--bg); }
.portal-top { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); }
.portal-top-inner { max-width: 1080px; margin: 0 auto; height: 60px; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.portal-company { display: flex; align-items: center; gap: 10px; min-width: 0; }
.portal-company .pc-logo { width: 34px; height: 34px; border-radius: 9px; overflow: hidden; flex: none; background: var(--primary-soft); display: grid; place-items: center; color: var(--primary-text); font-weight: 700; }
.portal-company .pc-logo img { width: 100%; height: 100%; object-fit: cover; }
.portal-company .pc-name { font-weight: 700; font-size: 14.5px; line-height: 1.2; }
.portal-company .pc-sub { font-size: 11.5px; color: var(--muted); }
.portal-tabs { max-width: 1080px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; overflow-x: auto; }
.portal-tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; font-size: 13.5px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none !important; }
.portal-tabs a.is-active { color: var(--primary-text); border-bottom-color: var(--primary); }
.portal-main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 96px; }
.portal-nav { display: none; }
@media (max-width: 760px) {
  .portal-tabs { display: none; }
  .portal-main { padding: 16px 14px 104px; }
  .portal-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; inset-inline: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .portal-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 10px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none !important; }
  .portal-nav a .icon { width: 22px; height: 22px; }
  .portal-nav a.is-active { color: var(--primary-text); background: var(--primary-soft); }
}

/* Check-in hero (portal home) */
.checkin { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 22px; text-align: center; box-shadow: var(--shadow-sm); }
.checkin-clock { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: .5px; direction: ltr; }
.checkin-date { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.checkin-btn { position: relative; width: 168px; height: 168px; border-radius: 50%; margin: 22px auto 14px; border: 0; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px;
  background: radial-gradient(circle at 50% 35%, var(--brand-500), var(--brand-700)); box-shadow: 0 18px 40px -14px rgba(14, 90, 80, .7), inset 0 2px 0 rgba(255, 255, 255, .18); transition: transform .15s var(--ease), filter .15s; }
.checkin-btn::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 2px solid var(--primary-soft-2); }
.checkin-btn:active { transform: scale(.97); }
.checkin-btn .icon { width: 44px; height: 44px; stroke-width: 1.5; }
.checkin-btn.is-out { background: radial-gradient(circle at 50% 35%, #e0663c, #b63d22); box-shadow: 0 18px 40px -14px rgba(182, 61, 34, .6), inset 0 2px 0 rgba(255, 255, 255, .18); }
.checkin-btn.is-out::before { border-color: rgba(224, 102, 60, .25); }
.checkin-btn:disabled { background: var(--gray-300); box-shadow: none; color: #fff; cursor: not-allowed; }
[data-theme="dark"] .checkin-btn:disabled { background: #2a3633; }
.checkin-btn.is-pulsing::before { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.94); opacity: 1; } 100% { transform: scale(1.14); opacity: 0; } }
.checkin-status { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.checkin-status .badge { height: 26px; }

/* --------------------------------------------------------------- print */
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; color: #000; font-size: 12px; }
  .sidebar, .topbar, .page-actions, .no-print, .toasts, .banner, .portal-top, .portal-nav, .portal-tabs, .tabs, .filters, .toolbar, .pagination-bar, .btn { display: none !important; }
  .shell { display: block; }
  .content, .portal-main { padding: 0 !important; max-width: none; }
  .card, .stat, .table-wrap { box-shadow: none !important; border-color: #ccc !important; break-inside: avoid; }
  .table th { position: static; background: #f1f1f1 !important; color: #000; }
  .print-only { display: block !important; }
  a { color: #000; text-decoration: none; }
}
