/* ═══ Twenty-inspired theme tokens (light + dark) ═══ */
[data-theme="light"] {
  --bg: #ffffff;
  --bg2: #fcfcfc;
  --bg3: #f9f9f9;
  --bg4: #f1f1f1;
  --border: #e8e8e8;
  --border2: #d4d4d4;
  --text1: #333333;
  --text2: #666666;
  --text3: #999999;
  --accent: #3e63dd;
  --accent2: #3358cc;
  --green: #30a46c;
  --amber: #f5a524;
  --red: #e5484d;
  --blue: #3e63dd;
  --chart-grid: #f4f4f5;
  --chart-primary: #18181b;
  --chart-success: #16a34a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  --focus-ring: rgba(124, 106, 247, 0.2);
  --badge-active-bg: #dcfce7;
  --badge-active-fg: #15803d;
  --badge-paused-bg: #fef3c7;
  --badge-paused-fg: #b45309;
  --badge-closed-bg: #fee2e2;
  --badge-closed-fg: #b91c1c;
  --rank-top-bg: #f0fdf4;
  --rank-bottom-bg: #fef2f2;
  --row-hover: #fafafa;
  --alert-error-bg: #fef2f2;
  --alert-error-border: #fecaca;
  --alert-error-fg: #991b1b;
  --logo-gold: #9a7b2e;
  --logo-gold-light: #c4a24a;
  --logo-gold-deep: #7a6120;
  --logo-marble: #6b6560;
  --logo-tile-bg: #1a1917;
  --logo-line: #5c5650;
}

[data-theme="dark"] {
  --bg: #171717;
  --bg2: #1a1a1a;
  --bg3: #1f1f1f;
  --bg4: #262626;
  --border: #303030;
  --border2: #404040;
  --text1: #ebebeb;
  --text2: #a1a1aa;
  --text3: #6b6b76;
  --accent: #5b6ef7;
  --accent2: #4f5ee5;
  --green: #3dd68c;
  --amber: #f5a524;
  --red: #f2555a;
  --blue: #5b6ef7;
  --chart-grid: #1f1f23;
  --chart-primary: #f0f0f2;
  --chart-success: #22c55e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  --focus-ring: rgba(124, 106, 247, 0.25);
  --badge-active-bg: #16302b;
  --badge-active-fg: #4ade80;
  --badge-paused-bg: #2d2510;
  --badge-paused-fg: #fbbf24;
  --badge-closed-bg: #2a1515;
  --badge-closed-fg: #f87171;
  --rank-top-bg: rgba(34, 197, 94, 0.08);
  --rank-bottom-bg: rgba(239, 68, 68, 0.08);
  --row-hover: var(--bg3);
  --alert-error-bg: #2a1515;
  --alert-error-border: #7f1d1d;
  --alert-error-fg: #fca5a5;
  --logo-gold: #d4b65a;
  --logo-gold-light: #e8cf82;
  --logo-gold-deep: #b8943f;
  --logo-marble: #d8d4cc;
  --logo-tile-bg: #0f0e0d;
  --logo-line: #ebe7e0;
}

[data-theme="light"],
[data-theme="dark"] {
  --text: var(--text1);
  --muted: var(--text2);
  --surface: var(--bg2);
  --surface-2: var(--bg3);
  --bg-hover: var(--bg3);
  --border-strong: var(--border2);
  --primary: var(--accent);
  --primary-hover: var(--accent2);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --success: var(--green);
  --danger: var(--red);
  --warning: var(--amber);
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 240px;
  --font: "Geist", "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.layout-app {
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ——— Sidebar ——— */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  height: 100vh;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text1);
  text-decoration: none;
}
.sidebar-logo:hover { text-decoration: none; color: var(--text1); }

.sidebar-logo-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.sidebar-logo:hover .sidebar-logo-icon {
  opacity: 0.84;
  transform: scale(1.05);
}

.sidebar-logo-icon svg {
  width: 40px;
  height: 40px;
  display: block;
}

.sidebar-logo-icon .logo-dome {
  fill: color-mix(in srgb, var(--logo-gold) 10%, transparent);
  stroke: var(--logo-gold);
  stroke-width: 1.15;
  stroke-linecap: round;
}

.sidebar-logo-icon .logo-pediment {
  fill: color-mix(in srgb, var(--logo-gold) 14%, transparent);
  stroke: var(--logo-gold-deep);
  stroke-width: 1.1;
  stroke-linejoin: round;
}

.sidebar-logo-icon .logo-entablature,
.sidebar-logo-icon .logo-column,
.sidebar-logo-icon .logo-step {
  stroke: var(--logo-line);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.sidebar-logo-icon .logo-capital {
  stroke: var(--logo-gold);
  stroke-width: 1.35;
  stroke-linecap: round;
}

.sidebar-logo-icon .logo-flute {
  stroke: color-mix(in srgb, var(--logo-line) 55%, var(--logo-marble));
  stroke-width: 0.65;
  stroke-linecap: round;
}

.sidebar-logo-icon .logo-step {
  stroke: color-mix(in srgb, var(--logo-line) 68%, var(--logo-marble));
}

.sidebar-logo-icon--lg {
  width: 56px;
  height: 56px;
}

.sidebar-logo-icon--lg svg {
  width: 56px;
  height: 56px;
}

.auth-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--text3);
}

.sidebar-section {
  padding: 0 0 4px;
}

.sidebar-section + .sidebar-section {
  margin-top: 6px;
  padding-top: 2px;
}

.sidebar-pinned {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.sidebar-group {
  margin-bottom: 4px;
}

.sidebar-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.12s, color 0.12s;
}

.sidebar-group-title::-webkit-details-marker { display: none; }

.sidebar-group-title::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text3);
  border-bottom: 1.5px solid var(--text3);
  transform: rotate(45deg);
  transition: transform 0.15s;
  flex-shrink: 0;
  margin-left: 8px;
}

.sidebar-group[open] > .sidebar-group-title {
  color: var(--text2);
}

.sidebar-group[open] > .sidebar-group-title::after {
  transform: rotate(-135deg);
  margin-top: 3px;
}

.sidebar-group-title:hover {
  background: var(--bg3);
  color: var(--text2);
}

.sidebar-group-links {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 4px 4px;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.72;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-nav a.is-active .nav-icon,
.sidebar-footer .sidebar-link.is-active .nav-icon {
  opacity: 1;
}

.sidebar-nav a,
.sidebar-footer .sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text2);
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  position: relative;
  margin-bottom: 1px;
}

.sidebar-nav a:hover,
.sidebar-footer .sidebar-link:hover {
  background: var(--bg3);
  color: var(--text1);
  text-decoration: none;
}

.sidebar-nav a.is-active,
.sidebar-footer .sidebar-link.is-active {
  background: var(--bg4);
  color: var(--text1);
  font-weight: 500;
}

.sidebar-nav a.is-active::before,
.sidebar-footer .sidebar-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-section {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 10px 10px 6px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-top: 4px;
  border-radius: 8px;
  transition: background 0.15s;
}
.sidebar-user:hover { background: var(--bg3); }

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 10px;
  flex-shrink: 0;
}

.sidebar-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.sidebar-user-name {
  font-weight: 500;
  font-size: 12px;
  color: var(--text1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--text3);
  margin-top: 1px;
  text-transform: capitalize;
}

.sidebar-logout {
  font-size: 11px;
  color: var(--text3);
  text-decoration: none;
  margin-top: 2px;
}
.sidebar-logout:hover { color: var(--red); text-decoration: none; }

/* ——— Main + topbar ——— */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  background: var(--bg2);
  flex-shrink: 0;
}

.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text1);
  flex-shrink: 0;
  min-width: 0;
  letter-spacing: -0.2px;
}

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

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}

.main-content::-webkit-scrollbar { width: 4px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px;
}

.main-panel { padding: 24px; }

/* ——— Theme toggle ——— */
.theme-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  gap: 2px;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 999px;
  flex-shrink: 0;
}

.theme-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.theme-switch-btn:hover:not(.is-active) {
  color: var(--text2);
}

[data-theme="dark"] .theme-switch-btn:not(.is-active):not([data-theme-value="light"]) {
  background: transparent;
  box-shadow: none;
}

.theme-switch-btn[data-theme-value="light"] {
  background-color: #ffffff;
  background: #ffffff;
  border-color: #e4e4e7;
}

.theme-switch-btn[data-theme-value="light"]:not(.is-active) {
  color: #a1a1aa;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.theme-switch-btn[data-theme-value="light"]:hover:not(.is-active) {
  color: #71717a;
}

.theme-switch-btn[data-theme-value="light"].is-active {
  border-color: #d4d4d8;
  color: #ea8c00;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.95),
    0 1px 4px rgba(0, 0, 0, 0.18),
    inset 0 0 0 1px #f4f4f5;
}

.theme-switch-btn[data-theme-value="dark"].is-active {
  background-color: #18181b;
  background: #18181b;
  border-color: #3f3f46;
  color: #fafafa;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.theme-switch-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.theme-switch-icon-sun {
  stroke-width: 2;
}

.btn-icon {
  padding: 6px;
  width: 32px;
  height: 32px;
}

.theme-icon { display: none; }
[data-theme="dark"] .theme-icon-moon { display: block; }
[data-theme="light"] .theme-icon-sun { display: block; }

.auth-theme-toggle.theme-switch {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
}

.auth-wrap {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-link-muted {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.sidebar-link-muted:hover {
  background: var(--bg3);
  color: var(--text1);
  text-decoration: none;
}
.sidebar-link-muted.is-active {
  background: var(--bg4);
  color: var(--text1);
}

/* ——— Auth layout ——— */
.layout-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
  min-height: 100vh;
  overflow: hidden;
}

/* ——— Page ——— */
.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text1);
}
.page-subtitle {
  margin: 0;
  color: var(--text2);
  font-size: 13px;
}

.section-heading {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text3);
}

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
@media (min-width: 900px) {
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border2); }
.card h2, .card h3 {
  margin-top: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text1);
}

.kpi-value {
  font-size: 26px;
  font-weight: 600;
  margin: 6px 0 0;
  letter-spacing: -0.5px;
  font-family: var(--font-mono);
  color: var(--text1);
}
.kpi-label {
  color: var(--text3);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 500;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent2);
  text-decoration: none;
  color: #fff;
}
.btn-ghost {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg4);
  color: var(--text1);
  border-color: var(--border2);
  text-decoration: none;
}
.btn-danger { background: var(--red); color: #fff; }
.btn.active {
  border-color: var(--accent);
  background: var(--bg4);
  color: var(--text1);
}

/* ——— Forms ——— */
.form { display: grid; gap: 14px; }
.form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text1);
}
.form input, .form select, .form textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text1);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.form input::placeholder { color: var(--text3); }
.form textarea { min-height: 96px; resize: vertical; }
.form-inline { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }

/* ——— Tables ——— */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg2);
}
.table-wrap table { border-collapse: collapse; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}
th {
  color: var(--text3);
  font-size: 11px;
  font-weight: 500;
  background: var(--bg3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
td { color: var(--text2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--row-hover); }

.card.table-wrap { padding: 0; overflow: hidden; }
.card.table-wrap h2, .card.table-wrap h3 {
  padding: 16px 20px 0;
}

/* ——— Badges ——— */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}
.badge-green, .badge-active { background: var(--badge-active-bg); color: var(--badge-active-fg); }
.badge-red, .badge-closed { background: var(--badge-closed-bg); color: var(--badge-closed-fg); }
.badge-gray, .badge-paused { background: var(--badge-paused-bg); color: var(--badge-paused-fg); }

.progress {
  height: 4px;
  background: var(--bg4);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* ——— Auth card (legacy) ——— */
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text1);
}
.auth-submit { width: 100%; margin-top: 8px; }

/* ——— Premium login page ——— */
.login-page {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  z-index: 1;
}

.login-page__mesh {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.login-page__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  animation: login-orb-drift 18s ease-in-out infinite alternate;
}

.login-page__orb--accent {
  width: min(560px, 90vw);
  height: min(560px, 90vw);
  top: -18%;
  left: -12%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 42%, transparent) 0%, transparent 68%);
}

.login-page__orb--gold {
  width: min(480px, 80vw);
  height: min(480px, 80vw);
  bottom: -14%;
  right: -10%;
  background: radial-gradient(circle, color-mix(in srgb, var(--logo-gold) 28%, transparent) 0%, transparent 70%);
  animation-delay: -9s;
}

.login-page__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(color-mix(in srgb, var(--border) 35%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--border) 35%, transparent) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, black 20%, transparent 75%);
  opacity: 0.45;
}

[data-theme="light"] .login-page__orb { opacity: 0.35; }
[data-theme="light"] .login-page__grid { opacity: 0.3; }

@keyframes login-orb-drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(24px, -18px) scale(1.06); }
}

.login-card {
  position: relative;
  background: color-mix(in srgb, var(--bg2) 88%, transparent);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid color-mix(in srgb, var(--border) 70%, var(--border2));
  border-radius: 16px;
  padding: 40px 36px 36px;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--border) 40%, transparent),
    0 1px 2px rgba(0, 0, 0, 0.06),
    0 12px 48px rgba(0, 0, 0, 0.22);
}

[data-theme="light"] .login-card {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--border) 60%, transparent),
    0 1px 3px rgba(0, 0, 0, 0.04),
    0 16px 48px rgba(0, 0, 0, 0.08);
}

.login-card__brand {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.login-card__header {
  text-align: center;
  margin-bottom: 28px;
}

.login-card__header h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text1);
}

.login-card__subtitle {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  color: var(--text2);
  letter-spacing: -0.01em;
}

.login-card__alert {
  background: var(--alert-error-bg);
  border: 1px solid var(--alert-error-border);
  color: var(--alert-error-fg);
  padding: 11px 14px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 18px;
}

.login-field {
  display: grid;
  gap: 7px;
}

.login-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text1);
  letter-spacing: -0.01em;
}

.login-field input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text1);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.login-field input::placeholder {
  color: var(--text3);
}

.login-field input:hover:not(:focus) {
  border-color: var(--border2);
  background: color-mix(in srgb, var(--bg3) 85%, var(--bg4));
}

.login-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
  background: var(--bg2);
}

.login-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 6px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff 8%) 0%, var(--accent) 50%, var(--accent2) 100%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 color-mix(in srgb, #fff 18%, transparent);
  transition: transform 0.15s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.login-submit:hover {
  filter: brightness(1.06);
  box-shadow:
    0 4px 16px color-mix(in srgb, var(--accent) 35%, transparent),
    0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 color-mix(in srgb, #fff 22%, transparent);
}

.login-submit:active {
  transform: scale(0.985);
  filter: brightness(0.97);
}

.login-submit:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px var(--focus-ring),
    0 4px 16px color-mix(in srgb, var(--accent) 35%, transparent);
}

@media (max-width: 480px) {
  .layout-auth { padding: 16px; }
  .login-card {
    padding: 32px 24px 28px;
    border-radius: 14px;
  }
  .login-card__header h1 { font-size: 22px; }
  .login-card__brand { margin-bottom: 24px; }
  .login-card__header { margin-bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .login-page__orb { animation: none; }
  .login-submit { transition: none; }
}
.alert-error {
  background: var(--alert-error-bg);
  border: 1px solid var(--alert-error-border);
  color: var(--alert-error-fg);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}
.hint { margin-top: 16px; color: var(--text3); font-size: 12px; }

.section { margin-top: 24px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.red-zone-banner {
  background: var(--alert-error-bg);
  border: 1px solid var(--alert-error-border);
  color: var(--alert-error-fg);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}

.finance-card {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.finance-card:hover {
  border-color: var(--border2);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.search-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text1);
  border-radius: 8px;
  padding: 9px 12px;
}
.search-results, .search-list { display: grid; gap: 4px; margin-top: 12px; }
.search-item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg3);
  color: var(--text1);
  text-decoration: none;
  border: 1px solid transparent;
}
.search-item:hover {
  background: var(--bg4);
  border-color: var(--border);
  text-decoration: none;
}

.branch-row { margin-bottom: 16px; }
.branch-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 16px 0 20px;
}
.tab-link {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-link:hover { color: var(--text); }
.tab-link.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.list-filters {
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
.filter-field-grow { flex: 1; min-width: 200px; }
.filter-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-list { list-style: none; padding: 0; margin: 0; }
.stat-list li {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text2);
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.rank-top td { background: var(--rank-top-bg) !important; }
.rank-bottom td { background: var(--rank-bottom-bg) !important; }
.team-block {
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--bg3);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.team-block summary { cursor: pointer; font-weight: 500; color: var(--text1); }

.support-feed { display: grid; gap: 10px; max-height: 60vh; overflow-y: auto; }
.support-msg {
  padding: 14px 16px;
  background: var(--bg3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.support-msg-fixed { opacity: 0.85; }
.support-msg-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.support-actions { margin-top: 8px; }
.filters-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.contest-form .participant-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 2px 12px;
  max-height: 320px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.contest-form .participant-filters > .muted {
  grid-column: 1 / -1;
  margin: 8px 0 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
}

.contest-form .participant-filters > .muted:first-child {
  margin-top: 0;
}

/* ——— Twenty-style checkboxes ——— */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
  border: 1px solid var(--border2);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  vertical-align: middle;
  transition: border-color 0.12s, background-color 0.12s, box-shadow 0.12s;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
}

input[type="checkbox"]:hover:not(:disabled) {
  border-color: var(--text3);
  background-color: var(--bg3);
}

input[type="checkbox"]:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8.5L6.5 11.5L12.5 4.5' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input[type="checkbox"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

label:has(> input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  color: var(--text2);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
}

label:has(> input[type="checkbox"]:checked) {
  color: var(--text1);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin: 0;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s;
}

.checkbox-line:hover {
  background: var(--bg4);
  color: var(--text1);
}

.checkbox-line:has(input:checked) {
  color: var(--text1);
}

.checkbox-line input[type="checkbox"] {
  margin-top: 0;
}
.role-picks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.form-section { margin: 12px 0; }
.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.table-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

@media (max-width: 768px) {
  .layout-app { height: auto; overflow: auto; }
  .app-shell { flex-direction: column; height: auto; }
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: none;
  }
  .main { overflow: visible; }
  .main-content { padding: 16px; }
  .kanban-board { grid-template-columns: 1fr; }
  .toolbar-form { flex-direction: column; align-items: stretch; }
}

/* ——— Page chrome ——— */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 8px;
}
.breadcrumbs a { color: var(--text3); text-decoration: none; }
.breadcrumbs a:hover { color: var(--text1); text-decoration: none; }
.bc-sep { opacity: 0.5; }
.bc-current { color: var(--text1); font-weight: 500; }

.page-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
}
.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text1);
}
.page-subtitle {
  margin: 4px 0 0;
  color: var(--text2);
  font-size: 13px;
}

.section-sm { margin-top: 12px; margin-bottom: 12px; }

.widget-settings summary {
  cursor: pointer;
  list-style: none;
  display: inline-block;
}
.widget-settings summary::-webkit-details-marker { display: none; }
.widget-settings-panel {
  margin-top: 12px;
  max-width: 520px;
}

.period-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.period-picker-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
}
.period-picker-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.period-picker-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  background: var(--bg3);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.period-picker-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.period-picker-date-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
}
.period-picker-date {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text1);
  font-size: 12px;
  font-family: inherit;
}
.period-picker-date:focus {
  outline: none;
  border-color: var(--accent);
}
.period-picker-apply {
  cursor: pointer;
}
.period-link {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  text-decoration: none;
  border: none;
  background: transparent;
  transition: all 0.15s;
}
.period-link:hover {
  color: var(--text1);
  text-decoration: none;
}
.period-link.is-active {
  color: var(--text1);
  background: var(--bg2);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.progress.lg { height: 10px; margin-top: 8px; }

.card-flat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  margin-bottom: 16px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}
.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  min-width: 200px;
  flex: 1;
  max-width: 320px;
}
.toolbar-search:focus-within { border-color: var(--accent); }
.toolbar-icon { width: 16px; height: 16px; color: var(--text3); flex-shrink: 0; }
.toolbar-input {
  border: none;
  background: transparent;
  padding: 8px 0;
  width: 100%;
  font-size: 12px;
  font-family: inherit;
  color: var(--text1);
}
.toolbar-input:focus { outline: none; }
.toolbar-input::placeholder { color: var(--text3); }
.toolbar-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: var(--bg3);
  color: var(--text1);
  font-family: inherit;
}

.view-toggle {
  display: inline-flex;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}
.view-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.view-btn.active {
  background: var(--bg2);
  color: var(--text1);
  box-shadow: var(--shadow-sm);
}
.view-btn:hover:not(.active) { color: var(--text1); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
}
.avatar-md { width: 32px; height: 32px; font-size: 13px; }
.avatar-sm { width: 24px; height: 24px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }
.avatar:not([class*="avatar-"]) { width: 32px; height: 32px; font-size: 13px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}
.status-in_work { background: var(--badge-active-bg); color: var(--badge-active-fg); }
.status-red_zone { background: var(--badge-closed-bg); color: var(--badge-closed-fg); }
.status-inactive { background: var(--bg4); color: var(--text2); }
.status-call-done { background: var(--badge-active-bg); color: var(--badge-active-fg); }
.status-call-pending { background: var(--bg4); color: var(--text2); }
.status-call-overdue { background: var(--badge-closed-bg); color: var(--badge-closed-fg); }

.dash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease;
}
.dash-row:last-child { border-bottom: none; }
.dash-row:hover { background: var(--bg3); }
.dash-row-title { font-size: 14px; font-weight: 500; color: var(--text); }
.dash-row-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }

.record-table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  box-shadow: var(--shadow-sm);
}
.record-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.record-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.record-table tbody td {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
  color: var(--text2);
}
.record-row { cursor: pointer; transition: background 0.12s; }
.record-row:hover td { background: var(--row-hover); }
.record-row:last-child td { border-bottom: none; }
.col-check { width: 36px; color: var(--text3); }
.col-num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.col-action { width: 36px; text-align: right; }
.record-cell { display: flex; align-items: center; gap: 10px; }
.record-cell.compact { gap: 8px; }
.record-primary { font-weight: 500; color: var(--text1); }
.record-secondary { font-size: 11px; color: var(--text3); }
.record-mono { font-weight: 500; font-family: var(--font-mono); color: var(--text1); }
.row-chevron { color: var(--text3); font-size: 18px; line-height: 1; }

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text3);
  font-size: 14px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 12px;
  align-items: start;
}
.kanban-column {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 200px;
}
.kanban-column-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}
.kanban-count {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
}
.kanban-cards { padding: 10px; display: grid; gap: 8px; }
.kanban-card {
  display: block;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.kanban-card:hover {
  border-color: var(--border2);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.kanban-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.kanban-card-id { font-weight: 600; font-size: 14px; color: var(--text1); }
.kanban-card-meta { font-size: 12px; color: var(--text3); margin-bottom: 6px; }
.kanban-card-foot { font-size: 13px; font-weight: 500; font-family: var(--font-mono); }
.kanban-empty { padding: 16px; text-align: center; color: var(--text3); font-size: 12px; }

.callout {
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  border: 1px solid var(--border);
  background: var(--bg2);
}
.callout-info { border-color: color-mix(in srgb, var(--blue) 40%, var(--border)); background: color-mix(in srgb, var(--blue) 8%, var(--bg2)); }
.callout-danger { border-color: var(--alert-error-border); background: var(--alert-error-bg); color: var(--alert-error-fg); }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg3);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text1);
  text-decoration: none;
}
.chip:hover { border-color: var(--border2); text-decoration: none; }

.record-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.record-hero h1 { margin: 0; font-size: 28px; letter-spacing: -0.03em; color: var(--text1); }
.record-hero-meta { color: var(--text2); font-size: 13px; margin-top: 4px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.detail-stat {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-width: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.detail-stat:hover { border-color: var(--border2); }
.detail-stat-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 8px;
}
.detail-stat-value {
  display: block;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  line-height: 1.2;
  font-family: var(--font-mono);
  color: var(--text1);
  word-break: break-word;
}

.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  font-size: 13px;
  color: var(--text1);
}
.panel-body { padding: 16px 18px; }

.timeline-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.timeline-type { font-weight: 500; color: var(--text1); }
.timeline-date { color: var(--text3); font-size: 12px; }
.timeline-desc { margin-top: 4px; color: var(--text2); font-size: 13px; }

.call-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  background: var(--bg3);
}
.call-item:last-child { margin-bottom: 0; }

/* ——— Client detail ——— */
.client-page {
  max-width: 960px;
}

.client-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border: 1px solid var(--alert-error-border);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--alert-error-bg) 70%, var(--bg2));
  color: var(--alert-error-fg);
  font-size: 13px;
  line-height: 1.4;
}
.client-alert-icon {
  flex-shrink: 0;
  color: var(--red);
  opacity: 0.9;
}

.client-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.client-hero-body {
  min-width: 0;
  flex: 1;
}
.client-hero-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.client-hero h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text1);
  line-height: 1.2;
}
.client-hero-meta {
  margin-top: 4px;
  color: var(--text2);
  font-size: 13px;
}

.client-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
@media (max-width: 640px) {
  .client-stats { grid-template-columns: 1fr; }
}
.client-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s;
}
.client-stat:hover { border-color: var(--border2); }
.client-stat-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
}
.client-stat-value {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text1);
  font-family: var(--font);
  line-height: 1.2;
}
.client-stat-value--count {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-weight: 500;
}

.client-actions { margin-bottom: 20px; }
.client-actions-grid {
  display: grid;
  gap: 14px;
}
.client-action-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}
@media (max-width: 560px) {
  .client-action-row { grid-template-columns: 1fr; }
  .client-action-row .btn { width: 100%; }
}
.client-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.client-field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
}
.client-field input,
.client-field select,
.client-field textarea,
.client-action-row input,
.client-action-row select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text1);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.client-field input:focus,
.client-field select:focus,
.client-field textarea:focus,
.client-action-row input:focus,
.client-action-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.client-field textarea,
.client-comment-form textarea,
.client-call-complete textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.5;
}
.client-comment-form {
  display: grid;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.client-comment-form .btn {
  justify-self: end;
}

.client-tabs {
  margin-top: 4px;
  margin-bottom: 16px;
}
.client-tabs .tab-link { color: var(--text2); }
.client-tabs .tab-link.is-active { color: var(--text1); }

.client-tab-panel { margin-bottom: 16px; }
.client-timeline--filters { padding-top: 0; }
.client-history-filters {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.client-tab-more {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.client-tab-more:hover { text-decoration: underline; }

.client-calls-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.client-call-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg3);
}
.client-call-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.client-call-time {
  font-size: 14px;
  font-weight: 500;
  color: var(--text1);
  font-variant-numeric: tabular-nums;
}
.client-call-note {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.45;
}
.client-call-complete {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.client-call-complete .btn { justify-self: end; }
.client-empty { margin: 0; text-align: center; padding: 12px 0; }

.client-finance-table { padding: 0; }
.client-finance-table .record-table-wrap {
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.client-tx-amount {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--green);
}
.client-tx-amount--out { color: var(--red); }

.datetime-picker.flatpickr-input {
  width: 100%;
}

/* ——— Charts ——— */
.chart-card {
  padding: 20px 22px;
}
.chart-card h3 {
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text1);
  letter-spacing: -0.01em;
}
.chart-wrap {
  position: relative;
  width: 100%;
  height: 260px;
  min-height: 240px;
  max-height: 280px;
  padding: 4px 0 0;
  overflow: hidden;
}
.chart-wrap-doughnut {
  min-height: 260px;
  height: 280px;
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-wrap canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}
.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text3);
  font-size: 13px;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.detail-stat { animation: fadeUp 0.4s ease both; }
.card:not(.chart-card) { animation: fadeUp 0.4s ease 0.1s both; }

/* ——— Global search ——— */
.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
  padding: 0 12px;
}

.global-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 0 12px;
  width: 100%;
  max-width: 420px;
  min-height: 36px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.global-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.global-search-icon {
  color: var(--text2);
  flex-shrink: 0;
  opacity: 0.9;
}

.global-search-input {
  border: none;
  background: transparent;
  color: var(--text1);
  font-size: 13px;
  font-family: inherit;
  font-weight: 400;
  padding: 8px 0;
  width: 100%;
  outline: none;
  -webkit-text-fill-color: var(--text1);
}

.global-search-input::placeholder {
  color: var(--text2);
  opacity: 0.85;
}

.global-search-input::-webkit-search-decoration,
.global-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

[data-theme="dark"] .global-search-input {
  color-scheme: dark;
}

.global-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 60;
  max-height: 320px;
  overflow-y: auto;
}

.global-search-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border);
}

.global-search-item:last-child { border-bottom: none; }
.global-search-item:hover { background: var(--bg3); text-decoration: none; }
.global-search-type { font-size: 10px; text-transform: uppercase; color: var(--text3); letter-spacing: 0.06em; }
.global-search-label { font-size: 13px; font-weight: 500; color: var(--text1); }
.global-search-meta { font-size: 11px; color: var(--text2); }
.global-search-empty { padding: 12px; color: var(--text2); font-size: 13px; }

/* ——— Topbar notifications ——— */
.topbar-notify {
  position: relative;
}

.topbar-notify-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg3);
  color: var(--text1);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.topbar-notify-btn:hover {
  background: var(--bg4);
  border-color: var(--border2);
}

.topbar-notify-btn[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.topbar-notify-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
}

.topbar-notify-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(320px, 85vw);
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 70;
  overflow: hidden;
}

.topbar-notify-head {
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}

.topbar-notify-list {
  max-height: 280px;
  overflow-y: auto;
}

.notify-item-link {
  display: block;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border);
}

.notify-item-link:hover { background: var(--bg3); text-decoration: none; }
.notify-item-link:last-child { border-bottom: none; }

.notify-item {
  padding: 12px 14px;
}

.notify-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
  margin-bottom: 2px;
}

.notify-item-text {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
}

.notify-item-danger .notify-item-title { color: var(--red); }
.notify-item-warning .notify-item-title { color: var(--amber); }
.notify-item-ok .notify-item-title { color: var(--green); }

.topbar-notify-all {
  display: block;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  border-top: 1px solid var(--border);
  color: var(--accent);
  text-decoration: none;
}

.topbar-notify-all:hover { background: var(--bg3); text-decoration: none; }

.notify-empty {
  padding: 14px;
  margin: 0;
  font-size: 12px;
  color: var(--text3);
}

.page-top-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ——— Ratings ——— */
.ratings-page-top { margin-bottom: 4px; }

.ratings-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.ratings-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.ratings-tab {
  position: relative;
  padding: 8px 4px 10px;
  margin-right: 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  text-decoration: none;
  transition: color 0.15s;
}

.ratings-tab:hover {
  color: var(--text1);
  text-decoration: none;
}

.ratings-tab.is-active {
  color: var(--text1);
}

.ratings-tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.ratings-period-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.ratings-period {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ratings-period-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.ratings-period-date-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
}

.ratings-period-date {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text1);
  font-size: 12px;
  font-family: inherit;
}

.ratings-period-date:focus {
  outline: none;
  border-color: var(--accent);
}

.ratings-period-apply {
  cursor: pointer;
}

.ratings-period-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ratings-period-btn:hover {
  border-color: var(--border2);
  color: var(--text1);
  text-decoration: none;
}

.ratings-period-btn.is-active {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--text1);
  box-shadow: var(--shadow-sm);
}

.ratings-kpi-grid {
  margin-bottom: 20px;
}

.ratings-kpi-grid-single {
  max-width: 360px;
}

.ratings-kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 4px;
}

.ratings-kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text3);
}

.ratings-kpi-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
  letter-spacing: -0.02em;
}

.ratings-kpi-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text1);
  font-variant-numeric: tabular-nums;
}

.ratings-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ratings-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ratings-grid-single { grid-template-columns: 1fr; }

.ratings-card-wide {
  grid-column: 1 / -1;
}

.ratings-card {
  padding: 0;
  overflow: hidden;
}

.ratings-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.ratings-card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text1);
}

.ratings-card-count {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}

/* Greek-style top-3 podium */
.ratings-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  margin: 8px 12px 12px;
  padding: 20px 16px 0;
  border-radius: 14px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(201, 162, 39, 0.08), transparent 70%),
    linear-gradient(180deg, var(--podium-bg-top, #f7f3eb) 0%, var(--podium-bg-bottom, #efe8dc) 100%);
  border: 1px solid var(--podium-border, #ddd4c4);
  position: relative;
  overflow: hidden;
}

.ratings-podium::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 18px,
    rgba(0, 0, 0, 0.03) 18px,
    rgba(0, 0, 0, 0.03) 19px
  );
  pointer-events: none;
}

[data-theme="dark"] .ratings-podium {
  --podium-bg-top: #2a2724;
  --podium-bg-bottom: #1f1d1a;
  --podium-border: #3d3832;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(201, 162, 39, 0.12), transparent 70%),
    linear-gradient(180deg, var(--podium-bg-top) 0%, var(--podium-bg-bottom) 100%);
}

.ratings-podium-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 140px;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.ratings-podium-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  margin-bottom: 10px;
  padding: 0 6px;
}

.ratings-podium-wreath {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  font-family: "Geist Mono", monospace;
  color: #5c6570;
  background: linear-gradient(145deg, #eef1f4, #c5ccd6);
  border: 2px solid #9aa5b1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.ratings-podium-wreath-gold {
  width: 32px;
  height: 32px;
  font-size: 12px;
  color: #7a5c00;
  background: linear-gradient(145deg, #ffe9a8, #d4a72c);
  border-color: #c9a227;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.2), 0 3px 10px rgba(201, 162, 39, 0.35);
}

.ratings-podium-place-3 .ratings-podium-wreath {
  color: #6b4226;
  background: linear-gradient(145deg, #f0d0b0, #b87333);
  border-color: #a0642a;
}

.ratings-podium-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
  line-height: 1.25;
  word-break: break-word;
}

.ratings-podium-place-1 .ratings-podium-name {
  font-size: 14px;
}

.ratings-podium-value {
  font-size: 12px;
  font-weight: 600;
  font-family: "Geist Mono", monospace;
  color: var(--text2);
}

.ratings-podium-place-1 .ratings-podium-value {
  font-size: 13px;
  color: var(--text1);
}

.ratings-podium-step {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #faf7f2 0%, #e8e0d4 55%, #d9cfc0 100%);
  border: 1px solid #cfc4b2;
  border-bottom: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  position: relative;
}

.ratings-podium-step::before {
  content: "";
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 6px;
  border-radius: 0 0 4px 4px;
  background: repeating-linear-gradient(90deg, #c9a227 0, #c9a227 4px, transparent 4px, transparent 8px);
  opacity: 0.45;
}

[data-theme="dark"] .ratings-podium-step {
  background: linear-gradient(180deg, #4a4540 0%, #35312c 55%, #2a2724 100%);
  border-color: #524c44;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.ratings-podium-place-1 .ratings-podium-step {
  height: 88px;
  border-color: #c9a227;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 -4px 16px rgba(201, 162, 39, 0.15);
}

.ratings-podium-place-2 .ratings-podium-step {
  height: 64px;
  border-color: #9aa5b1;
}

.ratings-podium-place-3 .ratings-podium-step {
  height: 48px;
  border-color: #a0642a;
}

.ratings-podium-rank {
  font-size: 22px;
  font-weight: 700;
  font-family: "Geist Mono", monospace;
  color: rgba(0, 0, 0, 0.08);
  line-height: 1;
  user-select: none;
}

[data-theme="dark"] .ratings-podium-rank {
  color: rgba(255, 255, 255, 0.07);
}

.ratings-podium-place-1 .ratings-podium-rank {
  font-size: 28px;
  color: rgba(201, 162, 39, 0.22);
}

.ratings-leaderboard {
  list-style: none;
  margin: 0;
  padding: 8px 12px 16px;
}

.ratings-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 8px;
  transition: background 0.12s;
}

.ratings-row:hover { background: var(--row-hover); }

.ratings-rank {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  background: var(--bg3);
  font-variant-numeric: tabular-nums;
}

.ratings-row-top1 .ratings-rank {
  background: var(--badge-active-bg);
  color: var(--badge-active-fg);
}

.ratings-row-top2 .ratings-rank,
.ratings-row-top3 .ratings-rank {
  background: var(--bg4);
  color: var(--text1);
}

.ratings-row-main {
  flex: 1;
  min-width: 0;
}

.ratings-row-topline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.ratings-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ratings-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ratings-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg4);
  overflow: hidden;
}

.ratings-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.75;
  transition: width 0.3s ease;
}

.ratings-row-top1 .ratings-bar span { background: var(--green); opacity: 1; }
.ratings-row-low .ratings-bar span { background: var(--red); opacity: 0.55; }

.ratings-empty {
  margin: 0;
  padding: 24px 20px;
  color: var(--text3);
  font-size: 13px;
}

@media (max-width: 900px) {
  .ratings-grid,
  .ratings-grid-2 {
    grid-template-columns: 1fr;
  }
  .ratings-card-wide { grid-column: auto; }
}

/* ——— Alerts ——— */
.alerts-panel { display: grid; gap: 8px; }
.alert-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
}
.alert-card-body { display: grid; gap: 2px; }
.alert-card-body strong { font-size: 13px; color: var(--text1); }
.alert-card-body span { font-size: 12px; color: var(--text2); }
.alert-card-link { font-size: 12px; color: var(--accent); white-space: nowrap; text-decoration: none; }
.alert-card-link:hover { text-decoration: underline; }
.alert-danger { border-color: color-mix(in srgb, var(--red) 40%, var(--border)); background: color-mix(in srgb, var(--red) 8%, var(--bg2)); }
.alert-warning { border-color: color-mix(in srgb, var(--amber) 40%, var(--border)); background: color-mix(in srgb, var(--amber) 8%, var(--bg2)); }
.alert-ok { border-color: color-mix(in srgb, var(--green) 30%, var(--border)); }

/* ——— Activity feed ——— */
.panel-body-flush { padding: 0; }
.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.activity-dot-green { background: var(--green); }
.activity-dot-accent { background: var(--accent); }
.activity-dot-blue { background: var(--blue); }
.activity-text { font-size: 12px; color: var(--text2); line-height: 1.5; }
.activity-text strong { color: var(--text1); font-weight: 500; }
.activity-time { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ——— Mobile /m/ layout ——— */
.layout-mobile {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text1);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
.m-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 10;
}
.m-logo { font-weight: 600; color: var(--text1); text-decoration: none; }
.m-user { font-size: 13px; color: var(--text2); }
.m-main { padding: 12px 16px 24px; }
.m-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.m-tab {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  font-size: 11px;
  color: var(--text2);
  text-decoration: none;
}
.m-tab.is-active { color: var(--accent); font-weight: 600; }
.m-search { display: grid; gap: 8px; margin-bottom: 12px; }
.m-search input, .m-search select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  color: var(--text1);
  font-size: 16px;
}
.m-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.m-card {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg2);
  text-decoration: none;
  color: inherit;
}
.m-card-static { display: block; }
.m-card-title { display: block; font-weight: 600; font-size: 15px; }
.m-card-meta { display: block; font-size: 12px; color: var(--text2); margin-top: 4px; }
.m-empty { padding: 24px; text-align: center; color: var(--text3); font-size: 14px; }
.m-back a { color: var(--accent); font-size: 14px; text-decoration: none; }
.m-detail { margin: 12px 0 20px; }
.m-detail h1 { margin: 0 0 12px; font-size: 20px; }
.m-detail-row { display: flex; justify-content: space-between; margin: 8px 0; font-size: 14px; }
.m-section-title { font-size: 16px; margin: 16px 0 8px; }
.m-page-title { font-size: 20px; margin: 0 0 12px; }
.m-full-btn { display: block; width: 100%; margin-top: 16px; text-align: center; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }

.matrix-table th.matrix-perm,
.matrix-table td.matrix-cell {
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.matrix-table th[scope="row"] { text-align: left; white-space: nowrap; }
.matrix-yes { color: var(--green); font-weight: 700; }

@media (max-width: 768px) {
  .global-search-input { font-size: 16px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .page-header h1 { font-size: 20px; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ═══ Flatpickr date picker (Twenty theme) ═══ */
.date-picker.flatpickr-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
}

input.date-picker.form-control.input,
input.date-picker {
  min-width: 7.5rem;
  cursor: pointer;
}

input.date-picker.form-control.input:focus,
input.date-picker:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.flatpickr-calendar {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow);
  font-family: inherit;
  color: var(--text1);
}

.flatpickr-calendar::before,
.flatpickr-calendar::after {
  display: none;
}

.flatpickr-months {
  padding: 8px 8px 0;
}

.flatpickr-months .flatpickr-month {
  height: 36px;
  color: var(--text1);
  fill: var(--text2);
}

.flatpickr-current-month {
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
}

.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
  background: transparent;
  color: var(--text1);
  font-weight: 600;
  border-radius: 6px;
}

.flatpickr-current-month .flatpickr-monthDropdown-months:hover,
.flatpickr-current-month input.cur-year:hover {
  background: var(--bg3);
}

.flatpickr-weekdays {
  background: transparent;
}

span.flatpickr-weekday {
  color: var(--text3);
  font-size: 11px;
  font-weight: 600;
}

.flatpickr-day {
  color: var(--text1);
  border-radius: 8px;
  border: none;
  font-size: 12px;
  font-weight: 500;
  line-height: 36px;
  max-width: 36px;
  height: 36px;
}

.flatpickr-day:hover,
.flatpickr-day:focus {
  background: var(--bg3);
  border-color: transparent;
  color: var(--text1);
}

.flatpickr-day.today {
  border-color: var(--accent);
  color: var(--accent);
}

.flatpickr-day.today:hover {
  background: var(--bg3);
  color: var(--accent);
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #fff;
}

.flatpickr-day.inRange {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: transparent;
  box-shadow: none;
  color: var(--text1);
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover,
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
  color: var(--text3);
  opacity: 0.55;
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
  background: transparent;
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  fill: var(--text2);
  padding: 6px;
  border-radius: 8px;
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
  fill: var(--text1);
  background: var(--bg3);
}

.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg {
  width: 12px;
  height: 12px;
}

