/* ===========================================================
   CRM Local — Interface Nova 2024
   Une refonte complète des codes graphiques et de la grille
   =========================================================== */

/* ---------- THEME VARIABLES ---------- */
:root {
  --font-base: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Manrope", system-ui, sans-serif;

  --bg-primary: #f8fafc;
  --bg-secondary: #e2e8f0;
  --surface: #ffffff;
  --surface-strong: #f8fafc;
  --surface-muted: #f1f5f9;
  --ink: #111827;
  --ink-muted: #334155;
  --ink-subtle: #475569;
  --line: #cbd5f5;
  --brand: #4f46e5;
  --brand-strong: #3730a3;
  --brand-soft: rgba(79, 70, 229, 0.14);
  --accent: #db2777;
  --accent-soft: rgba(219, 39, 119, 0.18);
  --success: #15803d;
  --warning: #d97706;
  --danger: #b91c1c;
  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --shadow-lg: 0 24px 70px rgba(15, 23, 42, 0.12);
  --shadow-md: 0 16px 44px rgba(15, 23, 42, 0.1);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.08);
  --ring: 0 0 0 4px rgba(79, 70, 229, 0.2);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg-primary: #050816;
  --bg-secondary: #0f172a;
  --surface: rgba(11, 18, 39, 0.78);
  --surface-strong: rgba(17, 26, 51, 0.92);
  --surface-muted: rgba(11, 18, 39, 0.5);
  --ink: #e2e8f0;
  --ink-muted: rgba(226, 232, 240, 0.75);
  --ink-subtle: rgba(226, 232, 240, 0.55);
  --line: rgba(99, 102, 241, 0.22);
  --brand: #8b95ff;
  --brand-strong: #6366f1;
  --brand-soft: rgba(139, 149, 255, 0.18);
  --accent: #fb7185;
  --accent-soft: rgba(251, 113, 133, 0.22);
  --shadow-lg: 0 36px 90px rgba(8, 12, 35, 0.65);
  --shadow-md: 0 22px 50px rgba(8, 12, 35, 0.55);
  --shadow-soft: 0 16px 38px rgba(8, 12, 35, 0.4);
  --ring: 0 0 0 4px rgba(139, 149, 255, 0.28);
  color-scheme: dark;
}

/* ---------- GLOBAL BASE ---------- */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-base);
  font-weight: 500;
  background: linear-gradient(160deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  color: var(--ink);
  line-height: 1.6;
  letter-spacing: -0.01em;
  position: relative;
  overflow-x: hidden;
  transition: background 0.5s ease, color 0.5s ease;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 30% 10%, rgba(219, 39, 119, 0.12), transparent 55%),
              radial-gradient(circle at 80% 20%, rgba(79, 70, 229, 0.14), transparent 60%);
  pointer-events: none;
  mix-blend-mode: normal;
  opacity: 0.2;
  z-index: 0;
}

a {
  color: var(--brand-strong);
  text-decoration-color: color-mix(in srgb, var(--brand) 70%, transparent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.25em;
}

a:hover {
  text-decoration-color: currentColor;
}

.aurora,
.aurora-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.aurora {
  background: radial-gradient(circle at 10% 20%, rgba(219, 39, 119, 0.18), transparent 60%),
              radial-gradient(circle at 90% 35%, rgba(56, 189, 248, 0.18), transparent 58%);
  filter: blur(110px);
  opacity: 0.55;
  transform: scale(1.05);
}

.aurora--secondary {
  background: radial-gradient(circle at 80% 80%, rgba(79, 70, 229, 0.18), transparent 65%),
              radial-gradient(circle at 20% 80%, rgba(219, 39, 119, 0.14), transparent 70%);
  mix-blend-mode: normal;
  opacity: 0.45;
}

.aurora-grid {
  background-image: linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 160px 160px;
  opacity: 0.18;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  z-index: 1000;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 16px;
}

/* ---------- LAYOUT SHELL ---------- */
.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: clamp(2.8rem, 4vw, 4rem) clamp(1.4rem, 4vw, 3.5rem);
  display: flex;
  justify-content: center;
}

.app-shell__layout {
  width: min(1280px, 100%);
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 3.5rem);
  align-items: start;
}

.app-shell__layout[data-sidebar-collapsed="true"] {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell__layout[data-sidebar-collapsed="true"] .sidebar {
  display: none;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  position: sticky;
  top: clamp(1.5rem, 3vw, 2.5rem);
  align-self: start;
  padding: 2.1rem;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  background: linear-gradient(160deg, color-mix(in srgb, var(--surface) 85%, transparent) 0%, color-mix(in srgb, var(--surface) 75%, transparent) 100%);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.sidebar__header {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sidebar__logo {
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.sidebar__caption {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

.sidebar__edition {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--accent);
}

.sidebar__nav {
  display: grid;
  gap: 0.6rem;
}

.sidebar__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--ink-muted);
  text-decoration: none;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
  overflow: hidden;
}

.sidebar__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid transparent;
  transition: inherit;
}

.sidebar__link span {
  font-size: 1.1rem;
}

.sidebar__link:hover,
.sidebar__link:focus-visible {
  transform: translateX(6px);
  background: color-mix(in srgb, var(--brand-soft) 55%, transparent);
  color: var(--ink);
}

.sidebar__link:hover::after,
.sidebar__link:focus-visible::after {
  border-color: color-mix(in srgb, var(--brand) 60%, transparent);
}

.sidebar__link.is-active {
  color: var(--ink);
  background: linear-gradient(120deg, color-mix(in srgb, var(--brand-soft) 80%, transparent) 0%, color-mix(in srgb, var(--accent-soft) 65%, transparent) 100%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 55%, transparent);
}

.sidebar__footer {
  margin-top: auto;
  padding: 1.1rem;
  border-radius: calc(var(--radius-sm) + 4px);
  background: color-mix(in srgb, var(--surface-muted) 90%, transparent);
  color: var(--ink-subtle);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ---------- TOGGLES ---------- */
.theme-toggle,
.sidebar-toggle {
  position: fixed;
  top: clamp(1.2rem, 4vw, 2.25rem);
  z-index: 50;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.theme-toggle {
  right: clamp(1.2rem, 4vw, 2.25rem);
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  cursor: pointer;
}

.theme-toggle:hover,
.sidebar-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

.theme-toggle:focus-visible,
.sidebar-toggle:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* ---------- LIGHT THEME LEGACY UTILITY OVERRIDES ---------- */
html[data-theme="light"] .bg-white\/5,
html[data-theme="light"] .bg-white\/10,
html[data-theme="light"] .bg-white\/15,
html[data-theme="light"] .bg-white\/20 {
  background-color: rgba(255, 255, 255, 0.9) !important;
  color: var(--ink);
}

html[data-theme="light"] .bg-midnight-800\/60,
html[data-theme="light"] .bg-midnight-800\/40,
html[data-theme="light"] .bg-midnight-800\/80 {
  background-color: rgba(236, 242, 255, 0.9) !important;
}

html[data-theme="light"] .border-white\/10,
html[data-theme="light"] .border-white\/15,
html[data-theme="light"] .border-white\/20 {
  border-color: rgba(148, 163, 184, 0.4) !important;
}

html[data-theme="light"] .text-white {
  color: var(--ink) !important;
}

html[data-theme="light"] .text-slate-200,
html[data-theme="light"] .text-slate-300 {
  color: #475569 !important;
}

html[data-theme="light"] .text-slate-400 {
  color: #64748b !important;
}

html[data-theme="light"] .text-indigo-200 {
  color: #4f46e5 !important;
}

.sidebar-toggle {
  left: clamp(1.2rem, 4vw, 2.25rem);
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  cursor: pointer;
}

.sidebar-toggle span {
  font-size: 1.05rem;
}

.sidebar-toggle__label {
  font-size: 0.88rem;
}

/* ---------- SURFACE ---------- */
.app-shell__surface {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  padding: clamp(2.6rem, 4vw, 3.6rem);
  display: flex;
  flex-direction: column;
  gap: clamp(2rem, 4vw, 3rem);
}

.app-shell__surface::before {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: calc(var(--radius-lg) - 12px);
  border: 1px solid color-mix(in srgb, var(--brand) 18%, var(--line));
  opacity: 0.35;
  pointer-events: none;
}

.app-shell__surface--wide {
  padding-left: clamp(2rem, 4vw, 3.8rem);
  padding-right: clamp(2rem, 4vw, 3.8rem);
}

/* ---------- PAGE HEADING ---------- */
.page-heading {
  position: relative;
  padding: 2.2rem 2.4rem;
  border-radius: var(--radius-md);
  background: linear-gradient(
    130deg,
    color-mix(in srgb, var(--surface-muted) 88%, var(--brand-soft)) 0%,
    color-mix(in srgb, var(--surface-muted) 85%, var(--accent-soft)) 100%
  );
  overflow: hidden;
  display: grid;
  gap: 0.55rem;
}

.page-heading::after {
  content: "";
  position: absolute;
  inset: -40% 20% auto -20%;
  height: 180%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.35), transparent 75%);
  opacity: 0.35;
}

.page-heading__badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: fit-content;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-muted) 92%, var(--brand-soft));
  color: var(--brand-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.page-heading__eyebrow {
  position: relative;
  font-size: 0.88rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}

.page-heading__title {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 1.2rem + 1.4vw, 2.6rem);
  letter-spacing: -0.015em;
}

.page-heading__subtitle {
  position: relative;
  margin: 0;
  font-size: 1.02rem;
  max-width: 48rem;
  color: var(--ink-muted);
}

/* ---------- DASHBOARD INTRO ---------- */
.dashboard-intro {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: clamp(1.6rem, 4vw, 2.4rem);
  padding: clamp(1.8rem, 4vw, 2.6rem);
  border-radius: var(--radius-md);
  background: linear-gradient(
    120deg,
    color-mix(in srgb, var(--surface-muted) 92%, var(--brand-soft)) 0%,
    color-mix(in srgb, var(--surface-muted) 90%, var(--accent-soft)) 100%
  );
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line));
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.dashboard-intro::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -20%;
  width: 60%;
  height: 160%;
  background: radial-gradient(circle at 50% 50%, rgba(79, 70, 229, 0.18), transparent 65%);
  filter: blur(36px);
  opacity: 0.55;
  pointer-events: none;
}

.dashboard-intro__headline {
  position: relative;
  display: grid;
  gap: 0.9rem;
}

.dashboard-intro__eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--ink-subtle);
}

.dashboard-intro__headline h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 1.1rem + 1.2vw, 2.2rem);
}

.dashboard-intro__headline p {
  margin: 0;
  color: var(--ink-muted);
  max-width: 36rem;
}

.dashboard-intro__metrics {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.metric-card {
  padding: 1.4rem;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  display: grid;
  gap: 0.45rem;
}

.metric-card__label {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}

.metric-card__value {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.8rem;
  letter-spacing: -0.03em;
}

.metric-card__hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

/* ---------- PANELS ---------- */
.panel {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 2rem 2.2rem 1.6rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, color-mix(in srgb, var(--surface-muted) 92%, var(--surface)) 0%, color-mix(in srgb, var(--surface-muted) 88%, var(--surface)) 100%);
}

.panel-title {
  display: grid;
  gap: 0.35rem;
}

.panel-title h2 {
  margin: 0;
  font-size: 1.4rem;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.panel-subtitle {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.panel-body {
  padding: 2.2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ---------- SEARCH ---------- */
.search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}

.search input {
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font: inherit;
  min-width: 260px;
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
  box-shadow: var(--ring);
}

/* ---------- BUTTONS ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0.65rem 1.4rem;
  text-decoration: none;
  background: color-mix(in srgb, var(--surface-strong) 90%, transparent);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn.primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff;
  border: none;
  box-shadow: 0 18px 45px rgba(79, 70, 229, 0.28);
}

.btn.ghost {
  background: color-mix(in srgb, var(--surface-muted) 90%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.btn.danger {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.92), rgba(185, 28, 28, 0.95));
  color: #fff;
  border: none;
}

.btn.icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.btn.sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: 14px;
}

.btn.xs {
  padding: 0.32rem 0.6rem;
  font-size: 0.78rem;
  border-radius: 10px;
}

/* ---------- SUMMARY CARDS ---------- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.1rem;
}

.summary-card {
  padding: 1.35rem 1.5rem;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.summary-card__label {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-subtle);
}

.summary-card__value {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
}

.summary-card__hint {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.summary-card__list {
  margin: 0;
  padding-left: 1rem;
  color: var(--ink-muted);
  display: grid;
  gap: 0.45rem;
  font-size: 0.9rem;
}

/* ---------- ALERTS ---------- */
.alert {
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  padding: 1.5rem 1.8rem;
  margin-bottom: 1.5rem;
  background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
  box-shadow: var(--shadow-soft);
}

.alert.success {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.12);
}

.alert.warning {
  border-color: rgba(234, 179, 8, 0.4);
  background: rgba(234, 179, 8, 0.14);
}

.alert-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}

.alert-subtitle {
  margin: 0.6rem 0 0.4rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.alert-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink-muted);
}

/* ---------- TABLES ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: calc(var(--radius-md) - 6px);
  border: 1px solid var(--line);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
}

.table thead th {
  text-align: left;
  padding: 1.2rem 1.4rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}

.table tbody tr {
  transition: background 0.2s ease;
}

.table tbody tr:hover {
  background: color-mix(in srgb, var(--surface-muted) 80%, var(--brand-soft));
}

.table td {
  padding: 1rem 1.4rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  vertical-align: top;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.table td strong,
.table .table-strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1rem;
}

.table-subtext {
  font-size: 0.85rem;
  color: var(--ink-subtle);
}

.table td.empty {
  text-align: center;
  padding: 2.6rem 1.4rem;
  color: var(--ink-muted);
  font-size: 1.05rem;
}

.table .actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  align-items: center;
}

.table .th-actions {
  text-align: right;
}

/* ---------- BADGES ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--surface-muted) 90%, transparent);
  color: var(--ink-muted);
}

.badge.success {
  background: rgba(16, 185, 129, 0.16);
  color: #047857;
}

.badge.danger {
  background: rgba(239, 68, 68, 0.18);
  color: #b91c1c;
}

.badge.neutral {
  background: rgba(148, 163, 184, 0.16);
  color: var(--ink-muted);
}

html[data-theme="dark"] .badge.success {
  color: #bbf7d0;
}

html[data-theme="dark"] .badge.danger {
  color: #fecaca;
}

html[data-theme="dark"] .badge.neutral {
  color: #cbd5f5;
}

/* ---------- CLIENT CARDS ---------- */
.client-list {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.client-list__empty {
  margin: 0;
  padding: 1.6rem;
  text-align: center;
  border: 1px dashed color-mix(in srgb, var(--line) 75%, transparent);
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  background: color-mix(in srgb, var(--surface-muted) 92%, transparent);
}

.client-card {
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.client-card summary {
  position: relative;
  list-style: none;
  cursor: pointer;
  padding: 1.35rem 1.8rem;
  background: linear-gradient(120deg, color-mix(in srgb, var(--surface) 86%, transparent) 0%, color-mix(in srgb, var(--surface-muted) 80%, transparent) 100%);
}

.client-card summary::-webkit-details-marker {
  display: none;
}

.client-card__summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
}

.client-card__identity {
  display: grid;
  gap: 0.5rem;
}

.client-card__identity h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: -0.01em;
}

.client-card__primary {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.client-card__tags {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-soft) 70%, transparent);
  color: var(--accent);
  width: fit-content;
  font-size: 0.82rem;
}

.client-card__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  color: var(--ink-subtle);
}

.client-card__count {
  font-size: 0.86rem;
}

.client-card__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-muted) 90%, transparent);
  font-size: 0.85rem;
}

.client-card[open] {
  border-color: color-mix(in srgb, var(--brand) 60%, transparent);
  box-shadow: 0 26px 60px rgba(99, 102, 241, 0.22);
  transform: translateY(-3px);
}

.client-card__body {
  display: flex;
  flex-direction: column;
  gap: 2.2rem;
  padding: 1.8rem 2rem 2.2rem;
}

.client-card__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.8rem;
}

.client-card__section h4 {
  margin: 0 0 0.9rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.client-card__dl {
  margin: 0;
  display: grid;
  gap: 0.9rem;
}

.client-card__dl div {
  display: grid;
  gap: 0.35rem;
}

.client-card__dl dt {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-subtle);
}

.client-card__dl dd {
  margin: 0;
  font-size: 0.96rem;
  color: var(--ink);
}

.client-card__empty {
  color: var(--ink-subtle);
  font-style: italic;
}

/* ---------- CONTACT LIST ---------- */
.contact-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 1rem;
}

.contact-list__item {
  padding: 1rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  display: grid;
  gap: 0.6rem;
}

.contact-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.contact-list__name {
  font-weight: 700;
}

.contact-list__badge {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: color-mix(in srgb, var(--brand-soft) 80%, transparent);
  color: var(--brand-strong);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.contact-list__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.contact-list__meta a {
  color: var(--brand-strong);
  font-weight: 600;
}

.contact-list__empty {
  font-size: 0.9rem;
  color: var(--ink-subtle);
}

/* ---------- CONTACT FORM ---------- */
.contact-form {
  display: grid;
  gap: 1.4rem;
  padding: 1.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: color-mix(in srgb, var(--surface-muted) 88%, transparent);
}

.contact-form__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.1rem;
}

.contact-form label {
  display: grid;
  gap: 0.45rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.contact-form input,
.contact-form select {
  padding: 0.7rem 1rem;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: color-mix(in srgb, var(--surface-strong) 90%, transparent);
  font: inherit;
  color: var(--ink);
}

.contact-form input:focus,
.contact-form select:focus {
  outline: none;
  box-shadow: var(--ring);
  border-color: color-mix(in srgb, var(--brand) 60%, transparent);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

/* ---------- SUBCONTRACT LIST ---------- */
.subcontract-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 1rem;
}

.subcontract-list__item {
  padding: 1.1rem 1.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  display: grid;
  gap: 0.7rem;
}

.subcontract-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.subcontract-list__identity {
  display: grid;
  gap: 0.35rem;
}

.subcontract-list__title {
  font-weight: 700;
  font-size: 1.02rem;
}

.subcontract-list__category {
  font-size: 0.86rem;
  color: var(--ink-subtle);
}

.subcontract-list__actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.subcontract-list__badge {
  font-size: 0.75rem;
}

/* ---------- TABLE MOBILE ---------- */
@media (max-width: 760px) {
  .table {
    min-width: 100%;
  }

  .table thead {
    display: none;
  }

  .table tbody tr {
    display: grid;
    gap: 0.9rem;
    padding: 1.2rem 1rem;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  }

  .table td {
    padding: 0;
    border: none;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
  }

  .table td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--ink-subtle);
    text-transform: uppercase;
    letter-spacing: 0.12em;
  }

  .table td.empty {
    padding: 1.8rem 0;
  }

  .table .actions {
    justify-content: flex-start;
  }
}

/* ---------- RESPONSIVE LAYOUT ---------- */
@media (max-width: 1080px) {
  .app-shell__layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: relative;
    top: auto;
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
  }

  .sidebar__nav {
    display: flex;
    flex-direction: row;
    gap: 0.7rem;
  }

  .sidebar__footer {
    display: none;
  }
}

@media (max-width: 980px) {
  .dashboard-intro {
    grid-template-columns: 1fr;
  }

  .dashboard-intro__metrics {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 2.2rem 1.4rem 3rem;
  }

  .theme-toggle,
  .sidebar-toggle {
    position: fixed;
    top: 1rem;
  }

  .app-shell__surface {
    padding: 2.2rem 1.5rem;
  }

  .app-shell__surface::before {
    inset: 12px;
  }

  .page-heading {
    padding: 1.8rem 1.6rem;
  }

  .sidebar {
    padding: 1.3rem 1.4rem;
    border-radius: var(--radius-md);
  }

  .sidebar__nav {
    overflow-x: auto;
    width: 100%;
  }

  .sidebar-toggle {
    left: 1rem;
    padding: 0.6rem 1.1rem;
  }

  .theme-toggle {
    right: 1rem;
    width: 48px;
    height: 48px;
  }

  .dashboard-intro {
    padding: 1.6rem;
  }

  .panel-header,
  .panel-body {
    padding: 1.6rem;
  }

  .client-card__body {
    padding: 1.6rem;
  }

  .client-card__summary {
    flex-direction: column;
    align-items: flex-start;
  }

  .client-card__meta {
    flex-direction: row;
    align-items: center;
    gap: 0.8rem;
  }
}

@media (max-width: 540px) {
  .contact-list__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-actions {
    justify-content: stretch;
  }

  .form-actions .btn {
    width: 100%;
  }
}

/* ---------- TEMPLATE UTILITIES ---------- */
summary {
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

.nova-select {
  appearance: none;
  background: linear-gradient(130deg, rgba(18, 28, 56, 0.82), rgba(7, 12, 32, 0.92)) !important;
  border-color: rgba(148, 163, 184, 0.35) !important;
  color: #e2e8f0 !important;
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.2), 0 18px 42px -28px rgba(15, 23, 42, 0.6);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
  padding-right: 2.75rem;
}

.nova-select:hover {
  border-color: rgba(165, 180, 252, 0.6) !important;
}

.nova-select:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 0.85) !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35), inset 0 1px 0 rgba(129, 140, 248, 0.4);
}

.nova-select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.nova-select::-ms-expand {
  display: none;
}

html[data-theme='dark'] .nova-select {
  color-scheme: dark;
}

html[data-theme='dark'] .nova-select option {
  background-color: #050816;
  color: #e2e8f0;
}

html[data-theme='light'] .nova-select {
  background: linear-gradient(130deg, rgba(255, 255, 255, 0.92), rgba(226, 232, 240, 0.88)) !important;
  border-color: rgba(148, 163, 184, 0.4) !important;
  color: #0f172a !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 18px 42px -28px rgba(148, 163, 184, 0.45);
  color-scheme: light;
}

html[data-theme='light'] .nova-select:hover {
  border-color: rgba(99, 102, 241, 0.55) !important;
}

html[data-theme='light'] .nova-select:focus {
  border-color: rgba(79, 70, 229, 0.85) !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25), inset 0 1px 0 rgba(99, 102, 241, 0.35);
}

html[data-theme='light'] .nova-select option {
  background-color: #ffffff;
  color: #0f172a;
}
