/* ============================================================
   Mejabantu Admin — adopted from Ledgerly admin template.
   Server-rendered Twig version (no React).
   Combines: tokens + shell + screens + login.
   ============================================================ */

:root {
  /* Brand — Odoo-inspired purple-pink (template default).
     Recolor the --brand-* ramp to switch palette. */
  --brand-50:  #faf6f8;
  --brand-100: #f1e8ee;
  --brand-200: #e0cbd8;
  --brand-300: #c4a3b6;
  --brand-500: #8d6280;
  --brand-600: #714B67;
  --brand-700: #5d3d55;
  --brand-800: #4a3144;
  --brand-900: #2e1f2a;

  /* Neutrals — warm slate */
  --gray-25:  #fcfcfd;
  --gray-50:  #f7f7f8;
  --gray-100: #f1f1f3;
  --gray-150: #e8e8ec;
  --gray-200: #dfdfe4;
  --gray-300: #c8c8d0;
  --gray-400: #9c9ca8;
  --gray-500: #6c6c78;
  --gray-600: #4a4a55;
  --gray-700: #36363f;
  --gray-800: #232329;
  --gray-900: #15151a;
  --gray-950: #0b0b0e;

  /* Semantic colors */
  --green-50: #ecfdf3;
  --green-100: #d1fadf;
  --green-500: #12b76a;
  --green-700: #027a48;

  --amber-50: #fffaeb;
  --amber-100: #fef0c7;
  --amber-500: #f79009;
  --amber-700: #b54708;

  --red-50: #fef3f2;
  --red-100: #fee4e2;
  --red-500: #f04438;
  --red-700: #b42318;

  --blue-50: #eff8ff;
  --blue-100: #d1e9ff;
  --blue-500: #2e90fa;
  --blue-700: #175cd3;

  /* Backgrounds */
  --bg-page: #f5f5f7;
  --bg-card: #ffffff;
  --bg-subtle: var(--gray-50);
  --bg-hover: var(--gray-100);

  /* Borders */
  --border: #e6e6eb;
  --border-strong: #d4d4dc;

  /* Sidebar (light variant default) */
  --sidebar-bg: #ffffff;
  --sidebar-border: var(--border);
  --sidebar-text: var(--gray-700);
  --sidebar-text-dim: var(--gray-500);
  --sidebar-text-active: var(--brand-700);
  --sidebar-bg-active: var(--brand-50);
  --sidebar-bg-hover: var(--gray-100);
  --sidebar-divider: var(--gray-150);
  --sidebar-section: var(--gray-400);

  /* Type */
  --f-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Shape */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, 0.12), 0 4px 8px -2px rgba(16, 24, 40, 0.06);
  --shadow-focus: 0 0 0 4px rgba(113, 75, 103, 0.16);

  /* Motion */
  --ease: cubic-bezier(.4,.0,.2,1);
  --dur: 150ms;
}

[data-sidebar="dark"] {
  --sidebar-bg: #1c1c2e;
  --sidebar-border: rgba(255,255,255,0.08);
  --sidebar-text: #d4d4dc;
  --sidebar-text-dim: #8a8aa0;
  --sidebar-text-active: #ffffff;
  --sidebar-bg-active: rgba(113, 75, 103, 0.32);
  --sidebar-bg-hover: rgba(255, 255, 255, 0.06);
  --sidebar-divider: rgba(255,255,255,0.08);
  --sidebar-section: #6e6e85;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-page);
  color: var(--gray-900);
  font-family: var(--f-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02","cv03","cv04","cv11";
}

button { font: inherit; cursor: pointer; border: 0; background: 0; color: inherit; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-300); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

::selection { background: var(--brand-100); color: var(--brand-900); }

/* ============ ATOMS ============ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  border: 1px solid transparent;
  text-decoration: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }

.btn-secondary { background: #fff; color: var(--gray-800); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--gray-50); }

.btn-ghost { background: transparent; color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-100); }

.btn-danger { background: var(--red-500); color: #fff; }
.btn-danger:hover { background: var(--red-700); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }

.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); color: var(--gray-600);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  position: relative;
}
.icon-btn:hover { background: var(--gray-100); color: var(--gray-900); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge .dot { width: 5px; height: 5px; border-radius: 99px; }

.badge-success { background: var(--green-50); color: var(--green-700); border-color: #a6f4c5; }
.badge-success .dot { background: var(--green-500); }
.badge-warning { background: var(--amber-50); color: var(--amber-700); border-color: #fedf89; }
.badge-warning .dot { background: var(--amber-500); }
.badge-danger { background: var(--red-50); color: var(--red-700); border-color: #fecdca; }
.badge-danger .dot { background: var(--red-500); }
.badge-info { background: var(--blue-50); color: var(--blue-700); border-color: #b2ddff; }
.badge-info .dot { background: var(--blue-500); }
.badge-neutral { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-200); }
.badge-neutral .dot { background: var(--gray-400); }
.badge-brand { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); }
.badge-brand .dot { background: var(--brand-600); }

.input, .select, .textarea {
  display: block; width: 100%;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  font-size: 13.5px; color: var(--gray-900);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 88px; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--gray-400); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--gray-400); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--shadow-focus); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--gray-50); color: var(--gray-500); cursor: not-allowed; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236c6c78' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-800); margin-bottom: 6px; }
.label-hint { display: block; font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.label-required { color: var(--red-500); margin-left: 2px; }

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

/* Layout */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w, 240px) 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  transition: grid-template-columns 220ms var(--ease);
}
.app-shell.collapsed { --sidebar-w: 64px; }

.app-main {
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--bg-page);
  overflow: hidden;
}
.app-main > .content-scroll { min-width: 0; }

/* Page header */
.page-header {
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.page-title { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; color: var(--gray-900); margin: 4px 0 0; line-height: 1.2; }
.page-sub { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--gray-500);
}
.breadcrumb a { color: var(--gray-500); }
.breadcrumb a:hover { color: var(--gray-800); }
.breadcrumb .sep { color: var(--gray-300); }
.breadcrumb .current { color: var(--gray-800); font-weight: 500; }

.muted { color: var(--gray-500); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; padding: 1px 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--f-mono); font-size: 10.5px; color: var(--gray-600);
  background: var(--bg-card);
}

.content-scroll { overflow: auto; height: 100%; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; font-size: 12px; font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }

.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; border-radius: 99px;
  background: var(--red-500);
  border: 2px solid var(--bg-card);
}

/* ============ SIDEBAR ============ */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: background 200ms var(--ease), border-color 200ms var(--ease);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  height: 60px;
  padding: 0 16px;
  border-bottom: 1px solid var(--sidebar-divider);
  flex-shrink: 0;
  color: var(--sidebar-text);
}
.brand-mark {
  width: 28px; height: 28px; flex-shrink: 0;
  background: var(--brand-600); color: #fff;
  border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-text { flex: 1; min-width: 0; }
.brand-name { font-size: 14px; font-weight: 600; color: var(--sidebar-text-active); letter-spacing: -0.01em; }
.brand-org { font-size: 11px; color: var(--sidebar-text-dim); margin-top: 1px; }
.sidebar-collapse {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--sidebar-text-dim);
}
.sidebar-collapse:hover { background: var(--sidebar-bg-hover); color: var(--sidebar-text); }

.sidebar-search {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 12px 4px;
  padding: 0 10px; height: 32px;
  background: var(--sidebar-bg-hover);
  border: 1px solid var(--sidebar-divider);
  border-radius: var(--radius);
  color: var(--sidebar-text-dim);
  font-size: 12.5px;
  transition: border-color var(--dur) var(--ease);
}
.sidebar-search:hover { border-color: var(--border-strong); }
.sidebar-search > span:first-of-type { flex: 1; text-align: left; }
.sidebar-search-kbd { display: inline-flex; gap: 2px; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 4px;
  display: flex; flex-direction: column; gap: 4px;
}

.nav-group { display: flex; flex-direction: column; gap: 1px; padding-bottom: 6px; }
.nav-section {
  font-size: 10.5px; font-weight: 600; color: var(--sidebar-section);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 12px 10px 6px;
}
.nav-section-divider { height: 1px; background: var(--sidebar-divider); margin: 8px 8px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 13.5px; font-weight: 450;
  text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  flex-shrink: 0;
  text-decoration: none;
}
.nav-item:hover { background: var(--sidebar-bg-hover); color: var(--sidebar-text-active); }
.nav-item.is-active {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
  font-weight: 500;
}
.nav-item.is-active svg { color: var(--brand-600); }
[data-sidebar="dark"] .nav-item.is-active svg { color: var(--brand-300); }

.sidebar.is-collapsed .nav-item { justify-content: center; padding: 9px 0; }
.sidebar.is-collapsed .nav-label,
.sidebar.is-collapsed .nav-count,
.sidebar.is-collapsed .brand-text,
.sidebar.is-collapsed .sidebar-collapse,
.sidebar.is-collapsed .sidebar-search,
.sidebar.is-collapsed .nav-section,
.sidebar.is-collapsed .sidebar-upgrade { display: none; }

/* Expand button: hidden by default, only visible while collapsed. */
.sidebar-expand { display: none; }
.sidebar.is-collapsed .sidebar-expand { display: flex; justify-content: center; }

.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
  font-size: 11px; font-weight: 500;
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-dim);
  padding: 1px 7px; border-radius: 999px;
  min-width: 22px; text-align: center;
}
.nav-count.active { background: var(--brand-600); color: #fff; }
[data-sidebar="dark"] .nav-count.active { background: var(--brand-500); }

.sidebar-footer {
  flex-shrink: 0;
  padding: 8px;
  border-top: 1px solid var(--sidebar-divider);
  display: flex; flex-direction: column; gap: 1px;
}

.sidebar-upgrade {
  margin-top: 8px;
  padding: 12px;
  background: linear-gradient(135deg, var(--brand-50), #fff);
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-md);
  display: flex; gap: 10px; align-items: flex-start;
  min-width: 0;
}
[data-sidebar="dark"] .sidebar-upgrade {
  background: linear-gradient(135deg, rgba(113,75,103,0.18), rgba(255,255,255,0.02));
  border-color: rgba(113,75,103,0.32);
}
.upgrade-icon {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--brand-600); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.upgrade-text { min-width: 0; flex: 1; }
.upgrade-title { font-size: 12.5px; font-weight: 600; color: var(--sidebar-text-active); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upgrade-sub { font-size: 11px; color: var(--sidebar-text-dim); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ TOPBAR ============ */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 460px) auto;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-width: 0;
}
.topbar-left { min-width: 0; overflow: hidden; }
.topbar-left .breadcrumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; padding: 0 14px; }
  .topbar-search-kbd { display: none; }
  .topbar-cta { display: none; }
}
@media (max-width: 700px) {
  .topbar-left { display: none; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
}

.topbar-search {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--gray-500);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.topbar-search:focus-within { background: #fff; border-color: var(--brand-500); box-shadow: var(--shadow-focus); }
.topbar-search input {
  flex: 1; min-width: 0;
  border: 0; background: transparent; outline: none;
  font-size: 13.5px; color: var(--gray-900);
}
.topbar-search input::placeholder { color: var(--gray-400); }
.topbar-search-kbd { display: inline-flex; gap: 2px; }

.topbar-right { display: flex; align-items: center; gap: 4px; }

.topbar-cta {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border-radius: var(--radius);
  background: var(--brand-600); color: #fff;
  font-size: 13px; font-weight: 500;
  margin-right: 8px;
  transition: background var(--dur) var(--ease);
}
.topbar-cta:hover { background: var(--brand-700); }

.user-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius);
  transition: background var(--dur) var(--ease);
}
.user-trigger:hover, .user-trigger.is-open { background: var(--gray-100); }
.user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.user-name { font-size: 12.5px; font-weight: 500; color: var(--gray-900); }
.user-role { font-size: 11px; color: var(--gray-500); }
@media (max-width: 980px) { .user-meta { display: none; } }

/* ============ DROPDOWNS ============ */
.dropdown-wrap { position: relative; }
.dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
  animation: dd-in 140ms var(--ease);
}
.dropdown[hidden] { display: none; }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.dd-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 8px;
  font-size: 13px; font-weight: 600; color: var(--gray-900);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.dd-link { font-size: 12px; color: var(--brand-700); font-weight: 500; background: 0; border: 0; cursor: pointer; }
.dd-link:hover { color: var(--brand-800); }
.dd-footer { padding: 6px 10px 4px; border-top: 1px solid var(--border); margin-top: 4px; text-align: center; }

.dd-divider { height: 1px; background: var(--border); margin: 4px -2px; }

.dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--gray-800);
  width: 100%; text-align: left;
  transition: background var(--dur) var(--ease);
  text-decoration: none;
}
.dd-item:hover { background: var(--gray-100); }
.dd-item svg { color: var(--gray-500); flex-shrink: 0; }
.dd-item.danger { color: var(--red-700); }
.dd-item.danger svg { color: var(--red-500); }
.dd-item.danger:hover { background: var(--red-50); }
.dd-item form { display: contents; }
.dd-item button[type="submit"] {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: 0; border: 0; cursor: pointer; padding: 0;
  color: inherit; font: inherit;
}

.user-dd { min-width: 240px; }
.user-dd-head { display: flex; gap: 12px; align-items: center; padding: 8px 10px 12px; }
.user-dd-name { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.user-dd-email { font-size: 12.5px; color: var(--gray-500); }

.notifications-dd { width: 380px; max-width: calc(100vw - 32px); padding: 0; }
.notifications-dd .dd-header { padding: 12px 14px; border-bottom: 1px solid var(--border); margin: 0; }
.notifications-dd .dd-body { max-height: 380px; overflow-y: auto; padding: 4px; }
.notifications-dd .dd-footer { padding: 8px; }

.notif {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
  position: relative;
}
.notif:hover { background: var(--gray-50); }
.notif.unread { background: var(--brand-50); }
.notif.unread:hover { background: var(--brand-100); }
.notif-icon {
  width: 28px; height: 28px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.notif-icon.kind-warning { background: var(--amber-100); color: var(--amber-700); }
.notif-icon.kind-success { background: var(--green-100); color: var(--green-700); }
.notif-icon.kind-info { background: var(--blue-100); color: var(--blue-700); }
.notif-title { font-size: 13px; font-weight: 500; color: var(--gray-900); line-height: 1.3; }
.notif-body { font-size: 12.5px; color: var(--gray-600); margin-top: 2px; line-height: 1.4; }
.notif-when { font-size: 11.5px; color: var(--gray-400); margin-top: 4px; }
.notif-unread-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--brand-600); align-self: center; }

/* ============ TASK MANAGER ============ */
.app-shell[data-screen-label="screen-task-board"] .content-scroll {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-shell[data-screen-label="screen-task-board"] .page-header {
  flex-shrink: 0;
}

.task-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  background: var(--bg-page);
}

.task-page.has-panel {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.task-workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 20px 24px 48px;
  overflow: hidden;
}

.task-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 150px 150px 170px auto auto;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  margin-bottom: 12px;
}

.task-toolbar-project {
  grid-template-columns: minmax(240px, 1fr) 150px 150px auto auto;
}

.task-search {
  background: #fff;
}

.task-view-switch {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  flex-shrink: 0;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  margin-bottom: 14px;
}

.task-view-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--gray-600);
}

.task-view-pill:hover {
  color: var(--gray-900);
  background: var(--gray-50);
}

.task-view-pill.is-active {
  background: var(--blue-50);
  color: var(--blue-700);
  box-shadow: inset 0 0 0 1px var(--blue-100);
}

.task-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(280px, 1fr));
  gap: 12px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
  overflow-x: auto;
  padding-bottom: 4px;
}

.task-column {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.72);
  min-width: 0;
  min-height: 0;
  padding: 12px;
  box-shadow: var(--shadow-xs);
}

.task-column-head,
.task-column-title,
.task-card-meta,
.task-card-foot,
.task-assignee-cell,
.task-section-head,
.task-panel-head,
.task-panel-actions,
.task-inline-form,
.task-comment,
.task-activity-row {
  display: flex;
  align-items: center;
}

.task-column-head,
.task-section-head,
.task-panel-head {
  justify-content: space-between;
  gap: 10px;
}

.task-column-title {
  gap: 8px;
  min-width: 0;
  font-weight: 600;
  color: var(--gray-900);
}

.task-column-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--gray-400);
  flex-shrink: 0;
}

.task-column-warning .task-column-dot { background: var(--amber-500); }
.task-column-info .task-column-dot { background: #0e9aa7; }
.task-column-success .task-column-dot { background: var(--green-500); }
.task-column-danger .task-column-dot { background: var(--red-500); }

.task-count {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 12px;
  font-weight: 600;
}

.task-card-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
  min-height: 0;
  margin-top: 12px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding-right: 2px;
}

.task-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.task-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.task-card.is-selected {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 1px var(--blue-500);
}

.task-card-link {
  display: block;
  padding: 12px;
}

.task-card-title {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--gray-900);
  line-height: 1.35;
}

.task-card-priority-text {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 600;
  vertical-align: baseline;
}

.task-card-priority-text svg {
  flex-shrink: 0;
}

.task-priority-text-low { color: #0f766e; }
.task-priority-text-medium { color: var(--blue-700); }
.task-priority-text-high { color: var(--amber-700); }
.task-priority-text-urgent { color: var(--red-700); }
}

.task-card-desc {
  margin-top: 6px;
  color: var(--gray-600);
  font-size: 12.5px;
  line-height: 1.45;
}

.task-card-meta {
  gap: 7px;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 10px;
}

.task-card-foot {
  gap: 8px;
  justify-content: space-between;
  margin-top: 11px;
  color: var(--gray-500);
  font-size: 12px;
  min-width: 0;
}

.task-date {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--gray-600);
  white-space: nowrap;
}

.task-priority,
.task-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.task-priority-low { color: #0f766e; background: #ccfbf1; }
.task-priority-medium { color: var(--blue-700); background: var(--blue-50); }
.task-priority-high { color: var(--amber-700); background: var(--amber-50); }
.task-priority-urgent { color: var(--red-700); background: var(--red-50); }

.task-status-todo { color: var(--gray-700); background: var(--gray-100); }
.task-status-in_progress { color: var(--amber-700); background: var(--amber-50); }
.task-status-review { color: #0f766e; background: #ccfbf1; }
.task-status-done { color: var(--green-700); background: var(--green-50); }

.task-avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, #475569, #0f766e);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.task-avatar-sm {
  width: 22px;
  height: 22px;
  font-size: 9.5px;
}

.task-add-card {
  height: 32px;
  flex-shrink: 0;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--gray-600);
  font-size: 13px;
  font-weight: 500;
}

.task-add-card:hover {
  background: #fff;
  color: var(--gray-900);
}

.task-empty-column {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--gray-400);
  font-size: 12.5px;
}

.task-table-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.task-table-card .table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.task-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.task-pager-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gray-500);
  font-size: 12.5px;
  margin: 0;
  white-space: nowrap;
  flex: 0 0 auto;
}

.task-page-size {
  width: 58px;
  min-width: 58px;
  padding-left: 10px;
  padding-right: 24px;
}

.task-pager-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
  margin-left: auto;
}

.task-pager .is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.task-page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  font-size: 12px;
  font-weight: 500;
  background: #fff;
}

.task-page-link:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}

.task-page-link.is-current {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
  pointer-events: none;
}

.task-assignee-cell {
  gap: 7px;
}

.task-detail-panel {
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: #fff;
  padding: 20px;
  overflow: auto;
  overscroll-behavior: contain;
}

.task-panel-head {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.task-panel-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.3;
}

.task-panel-sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--gray-500);
}

.task-detail-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-title-input {
  min-height: 48px;
  resize: none;
  overflow: hidden;
  line-height: 1.45;
}

.task-detail-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.task-detail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.task-detail-item span {
  color: var(--gray-500);
  font-size: 12.5px;
}

.task-detail-item strong {
  color: var(--gray-800);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

.task-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.task-panel-actions {
  gap: 8px;
  margin-top: 2px;
}

.task-detail-actions {
  margin-top: 18px;
  justify-content: flex-end;
}

.task-detail-actions form {
  margin: 0;
}

.task-panel-section {
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid var(--border);
}

.task-panel-tabs {
  min-height: 0;
}

.task-tab-list {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--gray-50);
  margin-bottom: 14px;
}

.task-tab {
  flex: 1;
  min-width: 0;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  font-size: 12.5px;
  font-weight: 600;
}

.task-tab:hover {
  background: #fff;
  color: var(--gray-900);
}

.task-tab.is-active {
  background: #fff;
  color: var(--brand-700);
  box-shadow: var(--shadow-xs);
}

.task-tab span {
  color: var(--gray-400);
  font-size: 11.5px;
}

.task-tab-panel[hidden] {
  display: none;
}

.task-load-more {
  min-height: 34px;
  margin-top: 12px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--gray-600);
  font-size: 12.5px;
  font-weight: 600;
}

.task-load-more:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}

.task-load-more span {
  color: var(--gray-400);
  font-weight: 500;
}

.task-section-head {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 10px;
}

.task-progress {
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--gray-100);
  margin-bottom: 10px;
}

.task-progress span {
  display: block;
  height: 100%;
  background: #0e9aa7;
}

.task-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-check-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  color: var(--gray-700);
  text-align: left;
}

.task-check-row.is-done {
  color: var(--gray-400);
  text-decoration: line-through;
}

.task-check-box {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.task-check-row.is-done .task-check-box {
  background: #0e9aa7;
  border-color: #0e9aa7;
}

.task-inline-form {
  gap: 8px;
  margin-top: 10px;
}

.task-comments,
.task-activity {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-comment,
.task-activity-row {
  gap: 9px;
  align-items: flex-start;
}

.task-activity-content {
  min-width: 0;
  padding-top: 1px;
  line-height: 1.28;
}

.task-activity-content > div:first-child {
  color: var(--gray-900);
  font-size: 13px;
  line-height: 1.3;
}

.task-activity-content .muted {
  display: block;
  margin-top: 2px;
  line-height: 1.25;
}

.task-comment-meta {
  color: var(--gray-500);
  font-size: 12px;
}

.task-comment-body {
  color: var(--gray-700);
  font-size: 13px;
  margin-top: 2px;
  line-height: 1.45;
}

.task-comment-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.task-panel-empty {
  color: var(--gray-500);
  font-size: 13px;
  padding: 10px 0;
}

.task-panel-empty-large {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.task-errors {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--red-50);
  color: var(--red-700);
  border: 1px solid var(--red-100);
  font-size: 13px;
  margin-bottom: 12px;
}

.task-project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 16px;
}

.task-project-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.task-project-main {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
}

.task-project-icon,
.task-project-empty-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-50);
  color: var(--blue-700);
  font-size: 13px;
  font-weight: 800;
}

.task-project-content {
  min-width: 0;
}

.task-project-head,
.task-project-stats,
.task-project-actions,
.danger-zone {
  display: flex;
  align-items: center;
}

.task-project-head,
.task-project-stats,
.danger-zone {
  justify-content: space-between;
  gap: 12px;
}

.task-project-title {
  color: var(--gray-900);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.task-project-code {
  color: var(--gray-500);
  font-family: var(--f-mono);
  font-size: 11.5px;
  margin-top: 2px;
}

.task-project-desc {
  color: var(--gray-600);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 10px;
  min-height: 38px;
}

.task-project-progress {
  margin-top: 12px;
}

.task-project-stats {
  color: var(--gray-500);
  font-size: 12px;
  margin-top: 6px;
}

.task-project-actions {
  gap: 6px;
  justify-content: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
}

.task-project-empty {
  grid-column: 1 / -1;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 28px;
}

.task-project-form {
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
  gap: 16px;
}

.task-project-form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.task-project-form .span-2 {
  grid-column: 1 / -1;
}

.form-field {
  display: flex;
  flex-direction: column;
}

.alert-danger {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--red-50);
  color: var(--red-700);
  border: 1px solid var(--red-100);
  font-size: 13px;
}

.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.task-member-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gray-900);
  font-size: 14px;
  font-weight: 600;
}

.task-member-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--gray-200);
  color: var(--gray-600);
  font-size: 12px;
  font-weight: 700;
}

.task-member-summary {
  padding: 16px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.task-member-summary-item,
.task-member-picker-item {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.task-member-summary-item {
  position: relative;
  cursor: default;
}

.task-member-summary-item[hidden] {
  display: none;
}

.task-member-summary-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  color: var(--gray-500);
  background: #fff;
}

.task-member-summary-remove:hover {
  color: var(--red-700);
  background: var(--red-50);
}

.task-member-summary-item .task-member-text {
  padding-right: 28px;
}

.task-member-picker-item:hover {
  border-color: var(--border-strong);
  background: var(--gray-50);
}

.task-member-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.task-member-name {
  color: var(--gray-900);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-member-email {
  color: var(--gray-500);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-project-members-empty {
  grid-column: 1 / -1;
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.task-project-members-empty[hidden] {
  display: none;
}

.task-member-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 18px 24px;
  background: rgb(17 24 39 / 0.35);
}

.task-member-modal[hidden] {
  display: none;
}

.task-member-modal-card {
  width: min(560px, 100%);
  max-height: min(640px, 86vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.task-member-modal-head,
.task-member-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
}

.task-member-modal-head {
  border-bottom: 1px solid var(--border);
}

.task-member-modal-title {
  color: var(--gray-900);
  font-size: 18px;
  font-weight: 700;
}

.task-member-modal-sub {
  margin-top: 4px;
  color: var(--gray-600);
  font-size: 13px;
}

.task-member-modal-body {
  min-height: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-member-picker {
  min-height: 96px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--gray-50);
  padding: 8px;
}

.task-member-picker-item {
  margin-bottom: 8px;
}

.task-member-picker-item:last-child {
  margin-bottom: 0;
}

.task-member-picker-item[hidden] {
  display: none;
}

.task-member-picker-empty {
  padding: 32px 12px;
  color: var(--gray-500);
  font-size: 13px;
  text-align: center;
}

.task-member-selected {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-member-selected-head {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gray-700);
  font-size: 12.5px;
  font-weight: 700;
}

.task-member-selected-head span:last-child {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--gray-200);
  color: var(--gray-600);
  font-size: 11px;
}

.task-member-selected-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}

.task-member-selected-item {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.task-member-selected-item[hidden] {
  display: none;
}

.task-member-selected-item .icon-btn {
  margin-left: auto;
  flex-shrink: 0;
}

.task-member-selected-empty {
  grid-column: 1 / -1;
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--gray-500);
  font-size: 13px;
  text-align: center;
  background: #fff;
}

.task-member-selected-empty[hidden] {
  display: none;
}

.task-member-modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
}

.danger-zone {
  margin-top: 16px;
  padding: 16px 18px;
}

@media (max-width: 1250px) {
  .app-shell[data-screen-label="screen-task-board"] .content-scroll {
    display: block;
    overflow: auto;
  }
  .task-page {
    min-height: calc(100vh - 96px);
    grid-template-columns: 1fr;
  }
  .task-workspace {
    display: block;
    overflow: visible;
  }
  .task-board {
    min-height: 0;
    overflow: visible;
  }
  .task-column {
    min-height: 0;
  }
  .task-card-list {
    overflow: visible;
  }
  .task-detail-panel {
    border-left: 0;
    border-top: 1px solid var(--border);
    overflow: visible;
  }
}

@media (max-width: 980px) {
  .task-toolbar {
    grid-template-columns: 1fr 1fr;
  }
  .task-board {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
  .task-project-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 640px) {
  .task-workspace,
  .task-detail-panel {
    padding: 16px;
  }
  .task-toolbar,
  .task-board,
  .task-form-grid,
  .task-project-grid,
  .task-project-form {
    grid-template-columns: 1fr;
  }
  .task-pager {
    align-items: flex-start;
    flex-direction: column;
  }
  .task-pager-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-left: 0;
  }
  .task-project-form .span-2 {
    grid-column: auto;
  }
}

/* ============ PAGE BODY ============ */
.page-body { padding: 24px 28px 60px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.card-sub { font-size: 12.5px; color: var(--gray-500); margin-top: 2px; }

/* ===== KPI ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi { padding: 18px 20px; }
.kpi-head { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; color: var(--gray-500); font-weight: 500; }
.kpi-icon {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--brand-50); color: var(--brand-700);
  display: inline-flex; align-items: center; justify-content: center;
}
.kpi-value {
  font-size: 26px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--gray-900);
  margin: 8px 0 6px;
  font-variant-numeric: tabular-nums;
}
.kpi-foot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.kpi-delta {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 7px; border-radius: 999px;
  font-weight: 500; font-size: 11.5px;
}
.kpi-delta.up { background: var(--green-50); color: var(--green-700); }
.kpi-delta.down { background: var(--red-50); color: var(--red-700); }
.kpi-sub { color: var(--gray-500); }

/* ===== Dashboard rows ===== */
.dash-row {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  margin-bottom: 16px;
}
.dash-row-2 { grid-template-columns: 1fr 360px; }
@media (max-width: 1100px) { .dash-row, .dash-row-2 { grid-template-columns: 1fr; } }

.chart-card { display: flex; flex-direction: column; }
.activity-card { display: flex; flex-direction: column; }
.activity-list { padding: 8px; flex: 1; }
.activity-row {
  display: grid; grid-template-columns: 18px 1fr; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  align-items: flex-start;
}
.activity-row:hover { background: var(--gray-50); }
.activity-dot {
  width: 8px; height: 8px; border-radius: 99px;
  margin-top: 7px;
  background: var(--gray-400);
  box-shadow: 0 0 0 3px var(--gray-100);
}
.activity-dot.kind-deal, .activity-dot.kind-payment { background: var(--green-500); box-shadow: 0 0 0 3px var(--green-100); }
.activity-dot.kind-overdue { background: var(--red-500); box-shadow: 0 0 0 3px var(--red-100); }
.activity-dot.kind-invoice { background: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-100); }
.activity-dot.kind-customer { background: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100); }
.activity-dot.kind-product { background: var(--amber-500); box-shadow: 0 0 0 3px var(--amber-100); }
.activity-text { font-size: 13px; color: var(--gray-800); line-height: 1.45; }
.activity-who { font-weight: 500; color: var(--gray-900); }
.activity-target { font-weight: 500; color: var(--gray-900); }
.activity-amt { color: var(--gray-700); font-variant-numeric: tabular-nums; }
.activity-when { font-size: 11.5px; color: var(--gray-400); margin-top: 2px; }

/* ===== Quick actions ===== */
.quick-card { display: flex; flex-direction: column; }
.quick-actions { display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.quick-action {
  display: grid; grid-template-columns: 32px 1fr 16px;
  gap: 12px; align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  text-align: left;
  transition: background var(--dur) var(--ease);
  text-decoration: none;
  width: 100%;
  background: 0; border: 0; cursor: pointer;
  color: inherit;
}
.quick-action:hover { background: var(--gray-50); }
.qa-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.qa-icon.kind-brand { background: var(--brand-50); color: var(--brand-700); }
.qa-icon.kind-blue { background: var(--blue-50); color: var(--blue-700); }
.qa-icon.kind-amber { background: var(--amber-50); color: var(--amber-700); }
.qa-icon.kind-green { background: var(--green-50); color: var(--green-700); }
.qa-icon.kind-red { background: var(--red-50); color: var(--red-700); }
.qa-text { display: flex; flex-direction: column; min-width: 0; }
.qa-title { font-size: 13px; font-weight: 500; color: var(--gray-900); }
.qa-sub { font-size: 12px; color: var(--gray-500); margin-top: 1px; }
.quick-action svg:last-child { color: var(--gray-400); }
.quick-action form { display: contents; }

/* ===== Tables ===== */
.table-card { padding: 0; }
.table-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.table-search {
  flex: 1; max-width: 320px;
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--gray-500);
}
.table-search:focus-within { background: #fff; border-color: var(--brand-500); box-shadow: var(--shadow-focus); }
.table-search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 13px; color: var(--gray-900); }
.toolbar-spacer { flex: 1; }
.select-sm { height: 32px; font-size: 12.5px; padding: 0 28px 0 10px; background-position: right 8px center; }

.table-wrap { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  text-align: left; font-weight: 500; color: var(--gray-500);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--gray-50);
  font-size: 12px; letter-spacing: 0.01em;
  white-space: nowrap;
}
.data-table thead th.align-right { text-align: right; }
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--gray-800);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--dur) var(--ease); }
.data-table tbody tr:hover { background: var(--gray-50); }

.cell-mono { font-family: var(--f-mono); font-size: 12px; color: var(--gray-600); }
.cell-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.align-right { text-align: right; }
.cell-primary { font-weight: 500; color: var(--gray-900); }
.cell-secondary { font-size: 12px; color: var(--gray-500); margin-top: 1px; }

/* ============ MARKDOWN EDITOR (split-pane) ============ */
.md-tabs {
  display: inline-flex;
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 2px;
}
.md-tab {
  padding: 5px 10px;
  font-size: 12px; color: var(--gray-600);
  border-radius: 4px;
  font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.md-tab:hover { color: var(--gray-900); }
.md-tab.is-active {
  background: #fff;
  color: var(--gray-900);
  box-shadow: var(--shadow-xs);
}

.md-editor {
  display: grid;
  gap: 0;
  min-height: 480px;
}
.md-editor.md-mode-split   { grid-template-columns: 1fr 1fr; }
.md-editor.md-mode-edit    { grid-template-columns: 1fr; }
.md-editor.md-mode-preview { grid-template-columns: 1fr; }

.md-pane { min-height: 480px; overflow: hidden; }
.md-mode-edit    .md-pane-preview { display: none; }
.md-mode-preview .md-pane-edit    { display: none; }

.md-input {
  width: 100%; height: 100%;
  border: 0;
  border-radius: 0;
  resize: none;
  padding: 18px;
  font-family: var(--f-mono);
  font-size: 13px; line-height: 1.6;
  background: var(--gray-50);
  color: var(--gray-900);
}
.md-input:focus { outline: 0; box-shadow: none; background: #fff; border-color: transparent; }
.md-mode-split .md-input { border-right: 1px solid var(--border); }

.md-preview {
  height: 100%;
  overflow-y: auto;
  padding: 18px 22px;
  background: var(--bg-card);
  font-size: 14px; line-height: 1.65;
  color: var(--gray-800);
}
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4 {
  letter-spacing: -0.015em; line-height: 1.25;
  margin: 1.5em 0 0.4em;
}
.md-preview h1 { font-size: 24px; font-weight: 700; margin-top: 0; }
.md-preview h2 { font-size: 19px; font-weight: 600; }
.md-preview h3 { font-size: 16px; font-weight: 600; }
.md-preview p  { margin: 0 0 1em; }
.md-preview a  { color: var(--brand-700); text-decoration: underline; }
.md-preview ul, .md-preview ol { padding-left: 1.4em; }
.md-preview li { margin: 0.25em 0; }
.md-preview code {
  background: var(--gray-100); padding: 2px 5px;
  border-radius: 4px; font-size: 0.9em;
  font-family: var(--f-mono);
}
.md-preview pre {
  background: var(--gray-100); padding: 12px 14px;
  border-radius: var(--radius); overflow-x: auto;
  font-size: 12.5px; line-height: 1.55;
  margin: 0 0 1em;
}
.md-preview pre code { background: 0; padding: 0; }
.md-preview blockquote {
  border-left: 3px solid var(--brand-300);
  padding: 4px 14px; margin: 0 0 1em;
  color: var(--gray-600);
}
.md-preview img { max-width: 100%; border-radius: var(--radius); margin: 0.5em 0; }
.md-preview hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }
.md-preview table {
  width: 100%; border-collapse: collapse; font-size: 13px; margin: 0 0 1em;
}
.md-preview th, .md-preview td {
  border: 1px solid var(--border); padding: 6px 10px; text-align: left;
}
.md-preview th { background: var(--gray-50); font-weight: 600; }
.md-preview:empty::before {
  content: 'Preview tampil di sini saat kamu mulai mengetik…';
  color: var(--gray-400); font-style: italic;
}

@media (max-width: 900px) {
  .md-editor.md-mode-split { grid-template-columns: 1fr; }
  .md-mode-split .md-pane-edit    { border-bottom: 1px solid var(--border); }
  .md-mode-split .md-input { border-right: 0; }
}

/* ============ COMPONENT EDITOR (Phase 5a) ============ */
.comp-editor { display: flex; flex-direction: column; }
.comp-list { padding: 12px 18px; display: flex; flex-direction: column; gap: 10px; }
.comp-empty { padding: 32px; text-align: center; }
.comp-empty[style*="display: none"] { display: none !important; }

.comp-item {
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease);
}
.comp-item:hover { border-color: var(--border-strong); }

.comp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.comp-grip {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
}
.comp-type-badge {
  font-size: 10.5px; font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--brand-100);
  color: var(--brand-700);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.comp-preview {
  font-size: 12.5px; color: var(--gray-600);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.comp-actions { display: flex; gap: 2px; flex-shrink: 0; }
.comp-actions .icon-btn {
  width: 26px; height: 26px;
  font-size: 11px;
  color: var(--gray-500);
}
.comp-actions .icon-btn:hover:not(:disabled) {
  background: var(--gray-100); color: var(--gray-900);
}
.comp-actions .icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.comp-actions [data-act="del"]:hover { background: var(--red-50); color: var(--red-700); }

/* Wrapper combines line-number gutter (left) + textarea (right). */
.comp-textarea-wrap {
  display: flex;
  align-items: stretch;
  background: var(--gray-50);
  min-height: 180px;
}
.comp-textarea-wrap:focus-within { background: #fff; }

.comp-line-numbers {
  flex: 0 0 auto;
  min-width: 36px;
  padding: 12px 8px 12px 12px;
  background: var(--gray-100);
  text-align: right;
  font-family: var(--f-mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--gray-400);
  white-space: pre;
  overflow: hidden;
  user-select: none;
  pointer-events: none;
  border-right: 1px solid var(--border);
}
.comp-textarea-wrap:focus-within .comp-line-numbers {
  background: var(--gray-50);
  color: var(--gray-500);
}

.comp-textarea {
  flex: 1;
  width: 100%;
  border: 0;
  border-radius: 0;
  resize: vertical;
  padding: 12px;
  font-family: var(--f-mono);
  font-size: 12.5px; line-height: 1.55;
  background: transparent;
  color: var(--gray-900);
  min-height: 180px;
  white-space: pre;       /* preserve formatting; no wrap so line numbers align */
  overflow-x: auto;
}
.comp-textarea:focus { outline: 0; box-shadow: none; }

/* ============ FLASH MESSAGES ============ */
.admin-toast-region {
  position: fixed;
  top: 76px;
  right: 24px;
  z-index: 80;
  width: min(440px, calc(100vw - 48px));
  pointer-events: none;
}

.admin-flash {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  margin: 0;
  padding: 12px 14px;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 13.5px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16), var(--shadow-xs);
  pointer-events: auto;
  animation: toast-in 220ms var(--ease);
}
.admin-flash .flash-icon { display: inline-flex; flex-shrink: 0; }
.admin-flash .flash-msg { flex: 1; color: var(--gray-800); line-height: 1.45; }
.admin-flash .flash-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.admin-flash .flash-close:hover { background: var(--gray-100); color: var(--gray-900); }
.admin-flash.is-leaving {
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
}
.flash-life {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: currentColor;
  opacity: 0.32;
  transform-origin: left center;
  animation: flash-life 4500ms linear forwards;
}
.admin-flash:hover .flash-life {
  animation-play-state: paused;
}

.flash-success { background: var(--green-50); border-color: #a6f4c5; }
.flash-success .flash-icon { color: var(--green-700); }
.flash-success .flash-msg { color: var(--green-700); }

.flash-error { background: var(--red-50); border-color: #fecdca; }
.flash-error .flash-icon { color: var(--red-700); }
.flash-error .flash-msg { color: var(--red-700); }

.flash-warning { background: var(--amber-50); border-color: #fedf89; }
.flash-warning .flash-icon { color: var(--amber-700); }
.flash-warning .flash-msg { color: var(--amber-700); }

.flash-info { background: var(--blue-50); border-color: #b2ddff; }
.flash-info .flash-icon { color: var(--blue-700); }
.flash-info .flash-msg { color: var(--blue-700); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes flash-life {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (max-width: 640px) {
  .admin-toast-region {
    top: 72px;
    right: 16px;
    width: calc(100vw - 32px);
  }
}

/* ============ FORMS ============ */
.form-page { padding-bottom: 80px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  align-items: flex-start;
}
@media (max-width: 1100px) { .form-grid { grid-template-columns: 1fr; } }

.form-main, .form-side { display: flex; flex-direction: column; gap: 16px; }

.form-section { padding: 0; }
.form-section-head { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.form-section-title { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.form-section-sub { font-size: 12.5px; color: var(--gray-500); margin-top: 2px; }
.form-section-body { padding: 18px; display: flex; flex-direction: column; gap: 16px; }

.form-row { display: grid; gap: 14px; grid-template-columns: 1fr; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 700px) { .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; }

.input-prefix, .input-suffix { position: relative; }
.input-prefix .input { padding-left: 26px; }
.input-prefix .prefix {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--gray-500); font-size: 13.5px;
}
.input-suffix .input { padding-right: 36px; }
.input-suffix .suffix {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--gray-500); font-size: 12.5px;
}

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: 0; padding-bottom: 0; }
.toggle-row.compact { padding: 8px 0; }
.toggle-row-title { font-size: 13.5px; font-weight: 500; color: var(--gray-900); }
.toggle-row-sub { font-size: 12.5px; color: var(--gray-500); margin-top: 2px; }

.upload-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 24px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--gray-50);
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  text-align: center;
}
.upload-zone:hover { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); }
.upload-text { display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.upload-text strong { color: var(--gray-800); font-weight: 500; }
.upload-zone:hover .upload-text strong { color: var(--brand-800); }
.upload-hint { font-size: 11.5px; color: var(--gray-400); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 4px 3px 10px;
  background: var(--gray-100); color: var(--gray-700);
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.tag button {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--gray-500); border-radius: 999px;
}
.tag button:hover { background: var(--gray-200); color: var(--gray-900); }
.tag-add {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border: 1px dashed var(--border-strong);
  color: var(--gray-600);
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.tag-add:hover { border-color: var(--brand-500); color: var(--brand-700); background: var(--brand-50); }

/* Sticky save bar at bottom of form-page */
.form-sticky-bar {
  position: sticky; bottom: 16px;
  margin-top: 16px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--gray-900);
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.form-sticky-info { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gray-300); }
.form-sticky-info svg { color: var(--amber-500); }
.form-sticky-actions { display: flex; align-items: center; gap: 8px; }
.form-sticky-bar .btn-ghost { color: var(--gray-300); }
.form-sticky-bar .btn-ghost:hover { background: rgba(255,255,255,0.1); color: #fff; }
.form-sticky-bar .btn-secondary { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); color: #fff; box-shadow: none; }
.form-sticky-bar .btn-secondary:hover { background: rgba(255,255,255,0.18); }

/* ============ LOGIN ============ */
.login-body {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(1200px 600px at 0% 0%, var(--brand-50), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, var(--brand-100), transparent 55%),
    var(--bg-page);
  padding: 24px;
  font-family: var(--f-sans);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}
.login-brand {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin-bottom: 24px;
}
.login-brand .brand-mark { width: 44px; height: 44px; border-radius: 10px; }
.login-brand h1 {
  font-size: 18px; font-weight: 600; color: var(--gray-900);
  margin: 6px 0 0; letter-spacing: -0.01em;
}
.login-brand p { font-size: 13px; color: var(--gray-500); margin: 0; }

.login-error {
  display: flex; align-items: center; gap: 8px;
  background: var(--red-50); color: var(--red-700);
  border: 1px solid #fecdca;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
}

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .field { display: flex; flex-direction: column; }

/* Password field wrapper */
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 40px; }
.password-toggle {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 38px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--gray-400);
  transition: color var(--dur) var(--ease);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.password-toggle:hover { color: var(--gray-600); }

/* Login button */
.login-btn {
  height: 40px;
  background: var(--brand-600); color: #fff;
  border-radius: var(--radius);
  font-weight: 500; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--dur) var(--ease);
  margin-top: 4px;
  position: relative;
}
.login-btn:hover:not(:disabled) { background: var(--brand-700); }
.login-btn:disabled { opacity: .75; cursor: not-allowed; }
.login-btn-label { display: inline-flex; align-items: center; gap: 6px; }

.login-secondary-form {
  margin-top: 12px;
}
.login-btn-secondary {
  width: 100%;
  height: 40px;
  background: #fff;
  color: var(--gray-700);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 13.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.login-btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-900);
}
.login-btn-secondary:disabled {
  background: var(--gray-25);
  border-color: var(--border);
  color: var(--gray-500);
  cursor: not-allowed;
  box-shadow: none;
}
.login-btn-secondary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(127, 81, 111, .18);
}
.login-btn-secondary svg {
  color: var(--gray-500);
}
.login-btn-secondary:disabled svg {
  color: var(--gray-400);
}
.login-action-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr);
  gap: 8px;
  margin-top: 12px;
}
.login-action-grid form {
  min-width: 0;
}
.login-action-grid .login-btn-secondary {
  margin-top: 0;
}
.login-action-grid .login-btn-secondary span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 380px) {
  .login-action-grid {
    grid-template-columns: 1fr;
  }
}

.module-choice-head {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}
.module-choice-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
}
.module-choice-sub {
  font-size: 12px;
  line-height: 1.45;
  color: var(--gray-500);
}
.module-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.module-choice {
  display: block;
  cursor: pointer;
}
.module-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.module-choice-body {
  min-height: 92px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 11px;
  display: grid;
  grid-template-columns: 28px 1fr 18px;
  gap: 9px;
  align-items: start;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.module-choice:hover .module-choice-body {
  background: var(--gray-50);
  border-color: var(--gray-300);
}
.module-choice input:checked + .module-choice-body {
  background: var(--brand-50);
  border-color: var(--brand-300);
  box-shadow: 0 0 0 1px rgba(127, 81, 111, .08);
}
.module-choice input:focus-visible + .module-choice-body {
  box-shadow: 0 0 0 3px rgba(127, 81, 111, .18);
}
.module-choice-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--gray-50);
  color: var(--brand-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.module-choice-copy {
  min-width: 0;
}
.module-choice-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.25;
}
.module-choice-desc {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--gray-500);
}
.module-choice-check {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.module-choice input:checked + .module-choice-body .module-choice-check {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}
.module-choice-recommend {
  margin-top: 8px;
}
.module-choice-recommend .module-choice-body {
  min-height: auto;
  grid-template-columns: 28px 1fr 18px;
}

@media (max-width: 640px) {
  .module-choice-grid {
    grid-template-columns: 1fr;
  }
}

/* Loading spinner inside button */
.login-btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: login-spin .6s linear infinite;
}
@keyframes login-spin {
  to { transform: rotate(360deg); }
}

.login-foot {
  text-align: center; margin-top: 18px;
  font-size: 12.5px; color: var(--gray-500);
}
.login-foot a { color: var(--brand-700); font-weight: 500; }
.login-foot a:hover { color: var(--brand-800); }

/* ======= Confirm Modal ======= */
.mb-confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 9900;
  display: flex; align-items: center; justify-content: center;
  animation: mb-fade-in 120ms var(--ease);
}
.mb-confirm-overlay[hidden] { display: none; }
@keyframes mb-fade-in { from { opacity: 0; } to { opacity: 1; } }

.mb-confirm-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 24px 20px;
  width: 360px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  animation: mb-slide-up 140ms var(--ease);
}
@keyframes mb-slide-up { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.mb-confirm-title {
  margin: 0 0 6px;
  font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--gray-900);
}
.mb-confirm-msg {
  margin: 0 0 20px;
  color: var(--gray-600);
  font-size: 13.5px;
  letter-spacing: -0.005em;
  line-height: 1.6;
}
.mb-confirm-actions {
  display: flex; justify-content: flex-end; gap: 8px;
}
