:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --panel: #ffffff;
  --ink: #162321;
  --muted: #61716c;
  --line: #d9e0d7;
  --brand: #0b7a67;
  --brand-dark: #07584b;
  --accent: #d89a2b;
  --warn: #a86614;
  --danger: #b42318;
  --ok: #18794e;
  --soft: #e9f5ef;
  --sidebar: #102625;
  --sidebar-2: #173633;
  --sidebar-text: #eef7f3;
  --gold: #f2b84b;
  --bg-glow-a: rgba(11, 122, 103, 0.07);
  --bg-glow-b: rgba(216, 154, 43, 0.10);
  --scroll-thumb: rgba(216, 154, 43, 0.72);
  --scroll-track: rgba(16, 38, 37, 0.08);
  --shadow: 0 14px 34px rgba(27, 40, 36, 0.09);
  --shadow-soft: 0 8px 18px rgba(27, 40, 36, 0.07);
  --font-body: Aptos, "Segoe UI Variable Text", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Trebuchet MS", "Segoe UI Variable Display", "Segoe UI", ui-sans-serif, sans-serif;
  --font-data: Bahnschrift, "Arial Narrow", "Segoe UI", ui-sans-serif, sans-serif;
}

body[data-theme="ocean"] {
  --bg: #f2f7fb;
  --ink: #142431;
  --muted: #5f7180;
  --line: #d4e0e7;
  --brand: #0a6f9b;
  --brand-dark: #074f72;
  --accent: #d59a2f;
  --soft: #e8f4f8;
  --sidebar: #0d2635;
  --sidebar-2: #123a4c;
  --sidebar-text: #edf7fb;
  --gold: #e6ae45;
  --bg-glow-a: rgba(10, 111, 155, 0.08);
  --bg-glow-b: rgba(213, 154, 47, 0.12);
  --scroll-thumb: rgba(213, 154, 47, 0.76);
}

body[data-theme="graphite"] {
  --bg: #f4f5f4;
  --ink: #1c2221;
  --muted: #68716f;
  --line: #d9dddd;
  --brand: #25645b;
  --brand-dark: #1d4d46;
  --accent: #bd8b37;
  --soft: #edf2ef;
  --sidebar: #181f1f;
  --sidebar-2: #293232;
  --sidebar-text: #f1f5f4;
  --gold: #d7a64f;
  --bg-glow-a: rgba(37, 100, 91, 0.07);
  --bg-glow-b: rgba(189, 139, 55, 0.11);
  --scroll-thumb: rgba(189, 139, 55, 0.76);
}

body[data-theme="royal"] {
  --bg: #f8f5f5;
  --ink: #241d1f;
  --muted: #75686c;
  --line: #e0d7d9;
  --brand: #8b2f43;
  --brand-dark: #642232;
  --accent: #c99634;
  --soft: #f5ecef;
  --sidebar: #2d1620;
  --sidebar-2: #47202d;
  --sidebar-text: #fff4f6;
  --gold: #e1ad48;
  --bg-glow-a: rgba(139, 47, 67, 0.08);
  --bg-glow-b: rgba(201, 150, 52, 0.12);
  --scroll-thumb: rgba(201, 150, 52, 0.78);
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  background:
    linear-gradient(135deg, var(--bg-glow-a), transparent 34%),
    linear-gradient(315deg, var(--bg-glow-b), transparent 38%),
    var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

body.locked {
  overflow: hidden;
}

body.locked .app-shell,
body.locked dialog {
  display: none;
}

body:not(.locked) .app-lock {
  display: none;
}

.app-lock {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.lock-card {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 5px solid var(--brand);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 14px;
}

.lock-card #forgotPasswordBtn { width: 100%; margin-top: 10px; }
.lock-card #switchAccountBtn { width: 100%; margin-top: 10px; }
.lock-card [hidden] { display: none !important; }

.lock-card .brand-mark {
  width: 58px;
  height: 58px;
}

.lock-card h1 {
  font-size: 34px;
}

.lock-card .primary {
  width: 100%;
  min-height: 48px;
}

.lock-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.lock-error[data-state="info"] { color: #76d9ff; }
.lock-error[data-state="success"] { color: #62e3b5; }
.lock-card .primary.is-loading { cursor: progress; opacity: .9; }
.lock-card .primary.is-loading::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 9px;
  vertical-align: -3px;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cloud-sync-spin .75s linear infinite;
}

.app-shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 12px;
  flex-shrink: 0;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: var(--sidebar);
  font-weight: 900;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12);
  overflow: hidden;
  flex: 0 0 auto;
}

.brand-logo {
  background: transparent;
  overflow: visible;
  position: relative;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  transform-origin: center;
  animation: logo-float 4.2s ease-in-out infinite, logo-glow 5.4s ease-in-out infinite;
}

.brand-logo::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(242, 184, 75, .5);
  border-radius: inherit;
  pointer-events: none;
  animation: logo-ring 3.2s ease-out infinite;
}

.brand strong, .brand span {
  display: block;
}

.brand span, .sidebar-footer small {
  color: #b8c9c2;
  font-size: 12px;
}

.brand strong {
  font-size: 15px;
  letter-spacing: 0;
  font-family: var(--font-display);
}

.nav {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.32) transparent;
}

.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

.nav button {
  position: relative;
  width: 100%;
  padding: 12px;
  color: #eaf5f1;
  background: transparent;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-weight: 720;
}

.nav button:hover, .nav button.active {
  background: rgba(255, 255, 255, 0.11);
}

.nav button.active {
  background: rgba(242, 184, 75, 0.18);
  color: #ffffff;
  box-shadow: inset 4px 0 0 var(--gold);
}

.nav button.active::after {
  content: "";
  position: absolute;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(242, 184, 75, 0.16);
}

.nav .nav-icon {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #cfebe2;
  flex: 0 0 auto;
}

.nav .nav-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav button:hover .nav-icon,
.nav button.active .nav-icon {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--sidebar);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  gap: 4px;
  flex-shrink: 0;
}

.clock-label {
  font-size: 24px;
  color: var(--gold);
  line-height: 1;
  letter-spacing: 0;
}

.main {
  padding: 26px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(217, 224, 215, 0.92);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 {
  font-family: var(--font-display);
}
h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 860;
  line-height: 1.05;
}
h2 {
  margin-bottom: 14px;
  font-size: 21px;
  line-height: 1.2;
}
h3 { margin-bottom: 8px; }

.top-actions, .row-actions, .modal-actions, .toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.primary, .secondary, .danger, .ghost, .icon-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 780;
}

.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-soft);
}
.primary:hover { background: var(--brand-dark); }
.secondary { background: #eef2ec; color: var(--ink); }
.danger { background: #fee2e2; color: var(--danger); }
.delete-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(180, 35, 24, 0.18);
  color: var(--danger);
  white-space: nowrap;
}

.delete-action span {
  font-size: 15px;
  line-height: 1;
}

.delete-action:hover {
  background: #fecaca;
}
.ghost { background: transparent; color: var(--ink); }
.icon-button {
  width: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: #eef2ec;
  color: var(--ink);
  font-size: 20px;
}

.file-button input { display: none; }
.view { display: none; }
.view.active { display: block; }
.view.active[aria-busy="true"] { min-height: 180px; }
.view.active[aria-busy="true"]::before {
  content: "Ouverture de l'onglet...";
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  color: var(--muted);
  font-weight: 850;
}
.view.active[aria-busy="true"]:not(:empty)::before { display: none; }
.table-load-more { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; padding: 16px 8px 4px; color: var(--muted); font-weight: 800; }

.marquee-panel {
  overflow: hidden;
  border: 1px solid rgba(11, 122, 103, 0.18);
  border-radius: 8px;
  background: var(--sidebar);
  color: #fff;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.marquee-track {
  display: flex;
  width: max-content;
  gap: 16px;
  padding: 11px 0;
  animation: title-marquee 28s linear infinite;
}

.marquee-track span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  color: #f9fbf8;
  font-weight: 850;
  white-space: nowrap;
}

.marquee-track span:nth-child(3n) {
  color: var(--gold);
}

@keyframes title-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.grid {
  display: grid;
  gap: 16px;
}

.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat, .panel, .table-wrap, .form-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat {
  padding: 19px;
  border-top: 3px solid rgba(11, 122, 103, 0.22);
  display: grid;
  gap: 10px;
}

/* Repères visuels : les couleurs distinguent les informations sans changer
   leur calcul. Vert = positif, bleu = information, orange = attention, rouge = alerte. */
.stats .stat:nth-child(4n + 1) { border-top-color: #16805b; background: linear-gradient(145deg, #fff, #effaf4); }
.stats .stat:nth-child(4n + 2) { border-top-color: #2878b8; background: linear-gradient(145deg, #fff, #eef7ff); }
.stats .stat:nth-child(4n + 3) { border-top-color: #d68a16; background: linear-gradient(145deg, #fff, #fff8e9); }
.stats .stat:nth-child(4n) { border-top-color: #c43b32; background: linear-gradient(145deg, #fff, #fff1f0); }

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

.stat strong {
  font-size: 29px;
  line-height: 1.05;
}

.stat small {
  color: var(--muted);
}

.layout-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
  align-items: stretch;
}

/* Rapports : lecture verticale, un tableau pleine largeur a la fois. */
.reports-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.reports-stack .panel {
  min-height: 0;
  max-height: none;
}

.full-panel { grid-column: 1 / -1; }

.panel, .form-card {
  padding: 18px;
  border-left: 4px solid var(--gold);
  overflow: auto;
  scrollbar-gutter: stable;
}

.storage-status {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fbfcf8;
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.storage-status strong {
  color: var(--ink);
}

.notice {
  margin: 0;
  font-weight: 800;
  padding: 11px 13px;
  border-radius: 8px;
  background: #eef7ff;
  border-left: 4px solid #2878b8;
}

.notice.danger {
  color: var(--danger);
  background: #fff1f0;
  border-left-color: var(--danger);
}

.theme-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-self: end;
}

.theme-chip {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  font-weight: 850;
  text-align: left;
}

.theme-chip span {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--gold));
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 1px var(--line);
  flex: 0 0 auto;
}

.theme-chip.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
  background: var(--soft);
}

.logo-settings {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.logo-preview {
  width: 92px;
  height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  padding: 10px;
  box-shadow: var(--shadow-soft);
}

.logo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.logo-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.layout-2 > .panel {
  min-height: 360px;
  max-height: min(760px, calc(100vh - 130px));
  display: flex;
  flex-direction: column;
}

.layout-2 > .panel.full-panel {
  min-height: 320px;
  max-height: min(720px, calc(100vh - 130px));
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(242, 184, 75, 0.34);
  border-color: rgba(216, 154, 43, 0.78);
  box-shadow: 0 0 0 1px rgba(216, 154, 43, 0.22);
}

button:focus-visible,
.file-button:focus-within {
  outline: 3px solid rgba(242, 184, 75, 0.42);
  outline-offset: 2px;
}

input[readonly] {
  background: #f7faf6;
  color: var(--muted);
}

input[disabled] {
  background: #edf0eb;
  color: var(--muted);
  cursor: not-allowed;
}

textarea { min-height: 82px; resize: vertical; }
label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-label {
  display: block;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.seg-option {
  position: relative;
  display: block;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
}

.seg-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  opacity: 0;
  cursor: pointer;
}

.seg-option span {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 10px;
  text-align: center;
}

.seg-option input:checked + span {
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--gold), var(--accent));
  color: var(--sidebar);
}

.seg-option input:focus-visible + span {
  outline: 3px solid rgba(242, 184, 75, 0.34);
  outline-offset: 2px;
}

.credit-tabs {
  display: flex;
  gap: 10px;
  margin: 0 0 18px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 7px 20px rgba(27, 40, 36, .05);
  overflow-x: auto;
  scrollbar-gutter: stable;
}

.credit-tabs button {
  flex: 0 0 auto;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: #f4f7f2;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 780;
  padding: 0 15px;
  white-space: nowrap;
}

.credit-tabs button:hover,
.credit-tabs button.active {
  border-color: rgba(216, 154, 43, 0.65);
  background: linear-gradient(180deg, var(--gold), var(--accent));
  color: var(--sidebar);
  box-shadow: inset 4px 0 0 rgba(11, 122, 103, 0.48);
}

/* Reperes colores : chaque sous-onglet reste identifiable d'un seul regard. */
.credit-tabs button:nth-child(4n + 1) { border-top: 4px solid #138a72; background-color: #eefaf6; }
.credit-tabs button:nth-child(4n + 2) { border-top: 4px solid #2f7fc1; background-color: #eef6fd; }
.credit-tabs button:nth-child(4n + 3) { border-top: 4px solid #dc8b12; background-color: #fff7e7; }
.credit-tabs button:nth-child(4n) { border-top: 4px solid #7b59be; background-color: #f6f1ff; }
.credit-tabs button.active { border-top-color: var(--gold); }

.dashboard-stat { padding: 0; overflow: hidden; }
.dashboard-stat summary { min-height: 158px; padding: 18px; display: grid; align-content: end; gap: 7px; cursor: pointer; list-style: none; position: relative; isolation: isolate; }
.dashboard-stat summary::-webkit-details-marker { display: none; }
.dashboard-stat-heading { display: flex; align-items: center; gap: 10px; padding-right: 34px; }
.dashboard-stat-label { color: #fff; font-size: 12px; font-weight: 900; line-height: 1.2; text-shadow: 0 1px 2px rgba(0,0,0,.18); text-transform: uppercase; letter-spacing: .06em; }
.dashboard-stat summary > strong { font-size: clamp(1.15rem, 2vw, 1.65rem); }
.dashboard-stat summary > small { color: rgba(255,255,255,.9); }
.dashboard-stat summary > i { position: absolute; right: 14px; top: 14px; width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.18); color: #fff; font-style: normal; transition: transform .2s ease; }
.dashboard-stat .dashboard-stat-icon { flex: 0 0 38px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: rgba(255,255,255,.2); color: #fff; }
.dashboard-stat .dashboard-stat-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.dashboard-stat::before { content: ""; position: absolute; z-index: 0; width: 150px; height: 150px; right: -55px; bottom: -75px; border-radius: 50%; background: rgba(255,255,255,.10); }
.dashboard-stat::after { width: 96px; height: 96px; right: 26px; top: -47px; background: rgba(255,255,255,.08) !important; }
.dashboard-stat.dashboard-card-berry { background: linear-gradient(135deg, #8d1748, #b52561) !important; color: #fff; }
.dashboard-stat.dashboard-card-green { background: linear-gradient(135deg, #13875e, #24a875) !important; color: #fff; }
.dashboard-stat.dashboard-card-gold { background: linear-gradient(135deg, #c18b09, #e0ad20) !important; color: #fff; }
.dashboard-stat.dashboard-card-blue { background: linear-gradient(135deg, #285d87, #397cad) !important; color: #fff; }
.dashboard-stat.dashboard-card-violet { background: linear-gradient(135deg, #67469b, #8765bc) !important; color: #fff; }
.dashboard-stat[open] summary > i { transform: rotate(180deg); }
.dashboard-stat-details { position: relative; z-index: 2; border-top: 1px solid var(--line); padding: 10px 14px 14px; background: #fff; max-height: 190px; overflow: auto; }
.dashboard-stat-details div { padding: 8px 2px; border-bottom: 1px dashed var(--line); color: var(--muted); font-size: 12px; }
.dashboard-stat-details div:last-child { border-bottom: 0; }

.dashboard-tabs { display: grid; grid-template-columns: repeat(6, minmax(105px, 1fr)); gap: 12px; padding: 0; margin-bottom: 16px; border: 0; background: transparent; box-shadow: none; overflow-x: auto; }
.dashboard-tabs button { position: relative; overflow: hidden; min-height: 96px; padding: 12px; display: grid; justify-items: start; align-content: space-between; gap: 5px; border: 1px solid var(--line); border-top: 0 !important; background: #fff !important; color: var(--ink) !important; box-shadow: var(--shadow-soft); }
.dashboard-tabs button::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; border-radius: 11px 11px 0 0; background: var(--tile-color, #138a72); }
.dashboard-tabs button:nth-child(2) { --tile-color: #279765; }
.dashboard-tabs button:nth-child(3) { --tile-color: #c23b49; }
.dashboard-tabs button:nth-child(4) { --tile-color: #397cad; }
.dashboard-tabs button:nth-child(5) { --tile-color: #da9413; }
.dashboard-tabs button:nth-child(6) { --tile-color: #7654ae; }
.dashboard-tabs button.active { transform: translateY(-2px); border-color: color-mix(in srgb, var(--tile-color) 48%, var(--line)); box-shadow: 0 12px 26px color-mix(in srgb, var(--tile-color) 22%, transparent); }
.dashboard-tab-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: color-mix(in srgb, var(--tile-color) 14%, white); color: var(--tile-color); }
.dashboard-tab-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.dashboard-tab-label { font-size: 13px; font-weight: 850; text-align: left; }
.dashboard-tabs button small { color: var(--muted); font-size: 10px; }

.contact-financial-state { margin-top: 7px; min-height: 24px; }
.install-help { line-height: 1.65; }
.install-help ol { padding-left: 22px; }

.credit-quick-action {
  display: flex;
  justify-content: flex-end;
  margin: 12px 0;
}

.credit-tab-content {
  display: grid;
  gap: 16px;
}

.history-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.history-block h3 {
  margin: 0 0 10px;
}

.line-disclosure {
  min-width: 150px;
}

.line-disclosure summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7f2;
  color: var(--ink);
  font-weight: 850;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.line-disclosure summary::-webkit-details-marker {
  display: none;
}

.line-disclosure[open] summary {
  border-color: rgba(216, 154, 43, 0.65);
  background: linear-gradient(180deg, var(--gold), var(--accent));
  color: var(--sidebar);
}

.line-disclosure[open] .disclosure-arrow {
  transform: rotate(180deg);
}

.disclosure-arrow {
  display: inline-block;
  transition: transform 0.16s ease;
}

.line-disclosure-body {
  margin-top: 8px;
  max-height: 160px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  scrollbar-gutter: stable;
}

.line-disclosure-item {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  gap: 8px;
  align-items: start;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}

.line-disclosure-item:last-child {
  border-bottom: 0;
}

.line-disclosure-item small {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.operation-grid,
.payment-accounts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.payment-account {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(180deg, #fff, #f7faf5);
  display: grid;
  align-content: center;
  gap: 5px;
  overflow: auto;
}

.payment-account:nth-child(1) { border-top: 4px solid #16805b; }
.payment-account:nth-child(2) { border-top: 4px solid #2878b8; }
.payment-account:nth-child(3) { border-top: 4px solid #d68a16; }
.payment-account:nth-child(4) { border-top: 4px solid #7a5bb7; }
.payment-account:nth-child(5) { border-top: 4px solid #3f6f9f; }

.payment-account span,
.payment-account small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.payment-account strong {
  color: var(--ink);
  font-size: clamp(20px, 2.3vw, 30px);
  line-height: 1.05;
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

.account-formula {
  display: block;
  line-height: 1.45;
  font-weight: 650 !important;
  min-height: 34px;
}

.account-history-link {
  justify-self: start;
  margin-top: 4px;
  padding: 7px 10px;
  border: 1px solid var(--brand);
  border-radius: 7px;
  background: #fff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 850;
}

.account-history-link:hover {
  background: var(--soft);
}

.cash-history-panel {
  margin-top: 16px;
}

.account-history-tabs {
  margin: 14px 0;
}

.account-history-summary {
  display: grid;
  gap: 5px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  background: #f7faf5;
  color: var(--muted);
}

.account-history-summary strong {
  color: var(--ink);
  font-size: 16px;
}

.bilan-intro {
  display: grid;
  gap: 5px;
  margin-bottom: 16px;
}

.bilan-intro strong {
  font-size: 18px;
  color: var(--ink);
}

.bilan-stats {
  margin-bottom: 16px;
}

.bilan-grid {
  align-items: start;
  gap: 16px;
}

.bilan-panel {
  min-width: 0;
}

.bilan-panel .table-wrap {
  max-height: 430px;
}

.notes-history-filters {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) minmax(190px, 1fr) minmax(145px, .7fr) minmax(145px, .7fr);
  gap: 10px;
  margin: 14px 0;
  align-items: end;
}

.notes-history-filters label {
  margin: 0;
}

.note-history-text {
  min-width: 260px;
  max-width: 520px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.rank-position {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--soft);
  color: var(--brand);
  font-weight: 900;
}

.rank-1 {
  background: #f8d568;
  color: #5e4300;
}

.rank-2 {
  background: #dfe5e7;
  color: #3e4a4d;
}

.rank-3 {
  background: #e8b487;
  color: #653512;
}

.product-search-wrap {
  position: relative;
}

.product-suggestions {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 230px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  scrollbar-gutter: stable;
}

.product-suggestions.open {
  display: grid;
}

.product-suggestions button {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 4px 10px;
  min-height: 48px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.product-suggestions button:hover {
  background: #f7faf5;
}

.product-suggestions button span {
  color: var(--muted);
  font-size: 12px;
}

.product-suggestions button small {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  color: var(--brand);
  font-weight: 850;
  white-space: nowrap;
}

.product-suggestion-empty {
  padding: 12px;
  color: var(--muted);
  font-weight: 800;
}

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

.form-grid .full { grid-column: 1 / -1; }

.is-hidden { display: none !important; }

.mode-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

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

.table-wrap {
  overflow: auto;
  max-height: min(700px, calc(100vh - 200px));
  scrollbar-gutter: stable;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f3f6f2;
  color: #40514d;
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #fbfcf8;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef2ec;
  color: #3c4749;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.warn { background: #fef3c7; color: var(--warn); }
.badge.danger { background: #fee2e2; color: var(--danger); }
.badge.info { background: var(--soft); color: var(--brand); }

.mini {
  color: var(--muted);
  font-size: 12px;
}

.money { font-weight: 850; white-space: nowrap; }
.negative { color: var(--danger); }
.positive { color: var(--ok); }

.progress {
  height: 9px;
  background: #edf0eb;
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  width: var(--w, 0%);
  background: var(--brand);
}

.sale-lines {
  display: grid;
  gap: 10px;
}

.purchase-lines {
  display: grid;
  gap: 12px;
}

.purchase-line {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 0.5fr) minmax(170px, 0.55fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.supplier-folders {
  display: grid;
  gap: 14px;
}

.supplier-folder {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.purchase-line .full {
  grid-column: 1 / -1;
}

.line-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.line-title strong {
  color: var(--ink);
}

.sale-line {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 76px 140px 130px 118px 38px;
  gap: 8px;
  align-items: end;
}

.product-search-wrap {
  display: grid;
  gap: 6px;
}

.line-product-search {
  border-color: rgba(11, 122, 103, 0.28);
  background: linear-gradient(180deg, #fff, var(--soft));
  font-weight: 780;
}

.technical-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.credit-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.credit-box {
  background: #f7faf5;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 96px;
  display: grid;
  align-content: center;
  overflow: auto;
}

.credit-summary .credit-box:nth-child(1) { background: #eefaf3; border-color: #b9e4ca; }
.credit-summary .credit-box:nth-child(2) { background: #eef7ff; border-color: #bfdcef; }
.credit-summary .credit-box:nth-child(3) { background: #fff8e8; border-color: #f1d79d; }
.credit-summary .credit-box:nth-child(4) { background: #fff1f0; border-color: #f2c1bd; }

tbody tr:has(.negative) { background: #fff7f6; }
tbody tr:has(.positive) { background: #f5fcf7; }
tbody tr:has(.badge.warn) { background: #fffaf0; }

.empty-state {
  flex: 1;
  min-height: 260px;
  padding: 34px;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-state p {
  max-width: 560px;
  margin-bottom: 0;
}

.empty-art {
  height: 90px;
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.empty-art span {
  width: 54px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(#0b7a67, #8fb9aa);
}
.empty-art span:nth-child(1) { height: 54px; }
.empty-art span:nth-child(2) { height: 80px; background: linear-gradient(#d89a2b, #f2c65d); }
.empty-art span:nth-child(3) { height: 66px; }

.modal {
  width: min(860px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(13, 22, 24, 0.58);
}

.modal-card {
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 0;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.modal-body {
  max-height: 68vh;
  overflow: auto;
  scrollbar-gutter: stable;
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.toast-stack {
  position: fixed;
  z-index: 2147483647;
  top: max(18px, env(safe-area-inset-top));
  right: 18px;
  width: min(460px, calc(100vw - 36px));
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 12px;
  border: 2px solid #1b8f72;
  border-left-width: 7px;
  border-radius: 14px;
  background: #ffffff;
  color: #102536;
  box-shadow: 0 18px 50px rgba(4, 23, 35, .32);
  font-size: 15px;
  font-weight: 750;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in .22s ease-out both;
}

.toast-error { border-color: #d6404f; background: #fff5f5; color: #7e1724; }
.toast-info { border-color: #138a72; background: #f2fff9; }
.toast-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #138a72; color: #fff; font-size: 19px; font-weight: 950; }
.toast-error .toast-icon { background: #d6404f; }
.toast-message { overflow-wrap: anywhere; }
.toast-close { width: 30px; height: 30px; min-height: 30px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 8px; background: rgba(16, 37, 54, .08); color: currentColor; font-size: 21px; }
.toast-close:hover { background: rgba(16, 37, 54, .15); }

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

.cloud-sync-gate { position: fixed; inset: 0; z-index: 2147483646; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); background: rgba(3,18,27,.74); backdrop-filter: blur(7px); }
.cloud-sync-gate[hidden] { display: none !important; }
.cloud-sync-card { width: min(440px, 100%); max-height: calc(100dvh - 20px); margin: auto 0; padding: 30px 26px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid rgba(255,255,255,.55); border-radius: 24px; background: #fff; color: #102837; box-shadow: 0 28px 80px rgba(0,0,0,.35); text-align: center; }
.cloud-sync-card h2 { margin: 14px 0 8px; font-size: clamp(1.25rem, 4vw, 1.65rem); }
.cloud-sync-card p { margin: 0 0 9px; color: #23495d; font-weight: 800; line-height: 1.45; }
.cloud-sync-card small { display: block; margin-top: 12px; color: #657b87; line-height: 1.45; }
.cloud-sync-spinner { width: 54px; height: 54px; margin: 0 auto; border: 6px solid #d9eee8; border-top-color: #07875f; border-radius: 50%; animation: cloud-sync-spin .8s linear infinite; }
.cloud-sync-success { display: none; width: 56px; height: 56px; margin: 0 auto; place-items: center; border-radius: 50%; background: #e0f8ec; color: #087b58; font-size: 32px; font-weight: 950; }
.cloud-sync-gate.has-error .cloud-sync-spinner { border-color: #f8d7da; border-top-color: #c52f45; animation-duration: 1.3s; }
.cloud-sync-gate.has-error .cloud-sync-card { border-color: #f0a7b1; }
.cloud-sync-gate.is-confirmed .cloud-sync-spinner { display: none; }
.cloud-sync-gate.is-confirmed .cloud-sync-success { display: grid; }
.cloud-sync-gate.is-confirmed .cloud-sync-card { border-color: #7ed3ae; }
.cloud-sync-card #cloudSyncRetryBtn { width: 100%; min-height: 46px; margin-top: 14px; position: sticky; bottom: 0; z-index: 2; }
@keyframes cloud-sync-spin { to { transform: rotate(360deg); } }

@media (max-height: 600px), (max-width: 360px) {
  .cloud-sync-card { padding: 16px 14px; border-radius: 18px; }
  .cloud-sync-spinner, .cloud-sync-success { width: 40px; height: 40px; }
  .cloud-sync-spinner { border-width: 5px; }
  .cloud-sync-card h2 { margin: 8px 0 6px; font-size: 1.15rem; }
  .cloud-sync-card p { margin-bottom: 6px; font-size: .92rem; }
  .cloud-sync-card small { margin-top: 8px; font-size: .76rem; }
  .cloud-sync-card #cloudSyncRetryBtn { margin-top: 10px; }
}

.receipt {
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
  color: #111;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.receipt-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  border-bottom: 2px solid var(--sidebar);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.receipt-brand {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.receipt-logo {
  width: 230px;
  max-width: 100%;
  height: auto;
  display: block;
}

.receipt-head h2 {
  margin-bottom: 4px;
}

.receipt-head p,
.receipt-client p {
  margin-bottom: 0;
}

.receipt-meta {
  display: grid;
  gap: 3px;
  text-align: right;
}

.receipt-client {
  background: #f7faf6;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.receipt .table-wrap {
  box-shadow: none;
  border-radius: 8px;
  max-height: none;
}

.receipt table {
  min-width: 0;
}

.receipt-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.receipt-totals div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 3px;
}

.receipt-totals span,
.receipt-lines span {
  color: var(--muted);
}

.receipt-lines {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.receipt-lines p {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.receipt-welcome {
  margin-top: 12px;
  padding: 9px 11px;
  border: 1px solid #c9dfd3;
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: #f3faf6;
  color: #48635a;
  font-size: 11px;
  line-height: 1.4;
}

.print-ticket {
  display: none;
}

@media (max-width: 980px) {
  .dashboard-tabs { grid-template-columns: repeat(6, minmax(125px, 1fr)); }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
  }
  .nav {
    overflow: visible;
    padding-right: 0;
  }
  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .stats, .layout-2, .credit-summary { grid-template-columns: 1fr 1fr; }
  .notes-history-filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .main { padding: 16px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .nav { grid-template-columns: 1fr 1fr; }
  .stats, .layout-2, .credit-summary, .form-grid { grid-template-columns: 1fr; }
  .notes-history-filters { grid-template-columns: 1fr; }
  .segmented { grid-template-columns: 1fr 1fr; }
  .embedded-grid, .purchase-line { grid-template-columns: 1fr; }
  .sale-line { grid-template-columns: 1fr 72px; }
  .sale-line .line-price-mode, .sale-line .line-price, .sale-line .line-discount, .sale-line .remove-line { grid-column: auto; }
}

@media print {
  body * { visibility: hidden; }
  .print-ticket, .print-ticket * { visibility: visible; }
  .print-ticket {
    display: block;
    position: absolute;
    inset: 0;
    padding: 20px;
    color: #000;
    background: #fff;
  }
  .print-ticket .receipt {
    max-width: none;
    border: 0;
    padding: 0;
  }
  .print-ticket .table-wrap {
    box-shadow: none;
  }
}

/* === FHIRATEL PWA 2026 · direction visuelle "centre de controle" === */
:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --ink: #102332;
  --muted: #6c7c89;
  --line: #dce5ed;
  --brand: #0d8a68;
  --brand-dark: #096b52;
  --accent: #f0a229;
  --warn: #b86a08;
  --danger: #d33d4a;
  --ok: #0d8a68;
  --soft: #e8f7f1;
  --sidebar: #071b2b;
  --sidebar-2: #0b2d3f;
  --sidebar-text: #f4fbff;
  --gold: #f0a229;
  --blue: #3478f6;
  --violet: #7c5ce7;
  --cyan: #11a8ba;
  --shadow: 0 18px 46px rgba(28, 52, 70, .12);
  --shadow-soft: 0 8px 24px rgba(28, 52, 70, .08);
  --radius-lg: 18px;
  --radius-md: 12px;
}

body[data-theme="ocean"] {
  --brand: #1378ad;
  --brand-dark: #0c5e8c;
  --soft: #e7f4fb;
  --sidebar: #061d31;
  --sidebar-2: #0b3653;
}

body[data-theme="graphite"] {
  --brand: #386e6a;
  --brand-dark: #27524f;
  --soft: #edf5f3;
  --sidebar: #121b21;
  --sidebar-2: #26343b;
}

body[data-theme="royal"] {
  --brand: #9b3857;
  --brand-dark: #752742;
  --soft: #f9eaf0;
  --sidebar: #271321;
  --sidebar-2: #4a1f36;
}

html { background: var(--bg); }

body {
  font-size: 16px;
  background:
    radial-gradient(circle at 72% -10%, rgba(52, 120, 246, .11), transparent 31rem),
    radial-gradient(circle at 18% 105%, rgba(13, 138, 104, .09), transparent 28rem),
    var(--bg);
  min-height: 100dvh;
}

.app-shell { grid-template-columns: 272px minmax(0, 1fr); }

.sidebar {
  padding: 20px 14px 16px;
  background:
    radial-gradient(circle at 30% 0%, rgba(37, 193, 151, .16), transparent 18rem),
    linear-gradient(165deg, var(--sidebar), var(--sidebar-2));
  box-shadow: 10px 0 30px rgba(6, 23, 35, .13);
  z-index: 40;
}

.brand { padding: 8px 8px 18px; }
.brand-mark { border-radius: 14px; }
.brand strong { font-size: 18px; letter-spacing: .04em; }
.brand span { font-size: 13px; margin-top: 3px; }

.nav { gap: 4px; }
.nav button {
  min-height: 44px;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 650;
  color: rgba(244, 251, 255, .78);
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav button:hover { transform: translateX(2px); color: #fff; }
.nav button.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(27, 190, 143, .28), rgba(27, 190, 143, .08));
  box-shadow: inset 3px 0 0 #25c197;
}
.nav-icon {
  width: 31px;
  height: 31px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .07);
}
.nav button.active .nav-icon { background: rgba(37, 193, 151, .2); color: #65e5c0; }
.sidebar-footer {
  border-top-color: rgba(255,255,255,.11);
  background: rgba(255,255,255,.045);
  border-radius: 12px;
  padding: 13px;
}
.sidebar-close { display: none; }

.main { padding: 0 30px 40px; max-width: 1800px; width: 100%; margin-inline: auto; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  min-height: 92px;
  margin: 0 -30px 24px;
  padding: 18px 30px;
  background: rgba(238, 243, 248, .86);
  border-bottom: 1px solid rgba(190, 205, 216, .72);
  backdrop-filter: blur(18px) saturate(1.35);
}
.topbar-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.section-title-shell { width: min(470px, 43vw); min-width: 0; overflow: hidden; }
.topbar h1 {
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(1.45rem, 2.3vw, 2rem);
  letter-spacing: -.035em;
  margin-bottom: 0;
  white-space: nowrap;
}
.section-title-track { display: inline-flex; align-items: center; width: max-content; will-change: transform; }
.section-title-track > span { display: inline-block; }
.section-title-track > span + span { display: none; }
#sectionTitle.is-scrolling .section-title-track { gap: 56px; animation: section-title-scroll 10s linear infinite; }
#sectionTitle.is-scrolling .section-title-track > span + span { display: inline-block; }
.topbar .eyebrow { margin-bottom: 4px; color: var(--brand); }
.top-actions { display: flex; align-items: center; gap: 9px; }
.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(31, 55, 70, .05);
}
.icon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sync-chip {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.8);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.sync-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(13,138,104,.12); }
.install-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  background: var(--sidebar);
  color: #fff;
  font-weight: 750;
}
.install-button:hover { background: var(--brand); }
.mobile-menu-button { display: none; }

.panel, .table-wrap, .form-card, .stat {
  border: 1px solid rgba(208, 220, 229, .9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}
.panel, .form-card { padding: 20px; }
.toolbar { gap: 14px; }
.toolbar h2, .panel h2 { letter-spacing: -.025em; }

.primary, .secondary, .danger, .ghost, .icon-button {
  border-radius: 10px;
  min-height: 42px;
}
.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 8px 20px rgba(13, 138, 104, .2);
}
.secondary { background: #edf3f6; border: 1px solid #d9e4ea; }
input, select, textarea { min-height: 44px; border-radius: 10px; background: #fbfdfe; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }

.marquee-panel { display: none; }
.grid.stats { grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 14px; }
.stat {
  min-height: 130px;
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-top: 0;
  background: #fff !important;
}
.stat::after {
  content: "";
  position: absolute;
  width: 74px;
  height: 74px;
  right: -24px;
  top: -25px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand) 11%, transparent);
}
.stats .stat:nth-child(5n + 2)::after { background: rgba(52,120,246,.11); }
.stats .stat:nth-child(5n + 3)::after { background: rgba(240,162,41,.15); }
.stats .stat:nth-child(5n + 4)::after { background: rgba(211,61,74,.10); }
.stats .stat:nth-child(5n)::after { background: rgba(124,92,231,.11); }
.stat span { font-size: 13px; text-transform: none; letter-spacing: .01em; color: var(--muted); }
.stat strong {
  font-family: var(--font-data);
  font-size: clamp(1.15rem, 1.7vw, 1.65rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.025em;
}
.stat small { line-height: 1.35; }

.money, .clock-label, .credit-box h2, .stock-gauge-content strong {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

@keyframes section-title-scroll {
  0%, 12% { transform: translateX(0); }
  88%, 100% { transform: translateX(calc(-50% - 28px)); }
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  50% { transform: translateY(-4px) rotate(2deg) scale(1.04); }
}

@keyframes logo-glow {
  0%, 100% { filter: drop-shadow(0 5px 9px rgba(3, 18, 28, .2)); }
  50% { filter: drop-shadow(0 8px 15px rgba(242, 184, 75, .42)); }
}

@keyframes logo-ring {
  0% { opacity: .7; transform: scale(.88); }
  70%, 100% { opacity: 0; transform: scale(1.28); }
}

.executive-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .72fr); gap: 16px; margin: 16px 0; }
.chart-panel { min-height: 354px; }
.panel-kicker { margin: 0 0 5px; color: var(--brand); font-size: 12px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-head h2 { margin-bottom: 4px; }
.panel-head p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.chart-legend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; font-weight: 700; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; background: var(--brand); }
.chart-legend .expense-dot { background: var(--accent); }
.sales-chart { width: 100%; min-height: 238px; display: block; overflow: visible; }
.sales-chart .grid-line { stroke: #e6edf2; stroke-width: 1; }
.sales-chart .axis-label { fill: #84919b; font-size: 11px; font-weight: 650; }
.sales-chart .area { fill: url(#salesArea); }
.sales-chart .line { fill: none; stroke: var(--brand); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.sales-chart .expense-line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-dasharray: 7 7; stroke-linecap: round; }
.sales-chart .point { fill: #fff; stroke: var(--brand); stroke-width: 3; }
.chart-total { font-size: 13px; color: var(--muted); }
.chart-total strong { display: block; font-size: 22px; color: var(--ink); margin-top: 2px; }

.health-panel { display: flex; flex-direction: column; }
.stock-gauge {
  --gauge-value: 0;
  width: 168px;
  aspect-ratio: 1;
  margin: 10px auto 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--brand) calc(var(--gauge-value) * 1%), #e7edf1 0);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.02);
}
.stock-gauge::before { content: ""; position: absolute; inset: 16px; border-radius: 50%; background: #fff; box-shadow: 0 7px 26px rgba(30,50,60,.08); }
.stock-gauge-content { position: relative; z-index: 1; text-align: center; }
.stock-gauge-content strong { display: block; font-size: 2rem; letter-spacing: -.05em; }
.stock-gauge-content span { color: var(--muted); font-size: 12px; font-weight: 750; }
.health-list { display: grid; gap: 12px; margin-top: auto; }
.health-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.health-row strong { font-size: 13px; }
.health-track { grid-column: 1 / -1; height: 7px; background: #edf1f4; border-radius: 99px; overflow: hidden; }
.health-track i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.health-row.warn .health-track i { background: var(--accent); }
.health-row.danger .health-track i { background: var(--danger); }

.insight-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.mini-insight { min-height: 178px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.category-donut { width: 112px; aspect-ratio: 1; border-radius: 50%; position: relative; flex: 0 0 auto; }
.category-donut::after { content: ""; position: absolute; inset: 18px; border-radius: 50%; background: #fff; }
.donut-legend { display: grid; gap: 7px; min-width: 0; }
.donut-legend span { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.donut-legend i { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-action {
  min-height: 64px;
  padding: 12px;
  border-radius: 12px;
  background: #f5f8fa;
  border: 1px solid #e1e9ee;
  text-align: left;
  color: var(--ink);
  font-weight: 750;
}
.quick-action span { display: block; margin-bottom: 5px; color: var(--brand); font-size: 18px; }
.quick-action:hover { border-color: var(--brand); background: var(--soft); }
.pulse-metric { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid #edf1f4; }
.pulse-metric:last-child { border-bottom: 0; }
.pulse-metric span { color: var(--muted); font-size: 13px; }
.pulse-metric strong { font-size: 15px; }

.offline-banner {
  display: none;
  position: fixed;
  z-index: 100;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  padding: 9px 14px;
  border-radius: 999px;
  background: #3a2810;
  color: #fff4dc;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 750;
}
body.is-offline .offline-banner { display: block; }
.sidebar-scrim { display: none; }

.lock-card {
  border: 1px solid rgba(255,255,255,.13);
  border-top: 0;
  border-radius: 22px;
  padding: 34px;
  color: #f7fbfd;
  background: linear-gradient(145deg, rgba(17,49,66,.98), rgba(7,27,43,.99));
  box-shadow: 0 30px 80px rgba(3,20,30,.32);
}
.app-lock { background: radial-gradient(circle at 50% 0, rgba(37,193,151,.25), transparent 34rem), #071b2b; }
.lock-card .mini { color: #acc2ce; }
.lock-card input { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.14); }
.lock-card input::placeholder { color: #8da4af; }
.lock-intro { color: #bdd0da; margin: -6px 0 4px; line-height: 1.55; }
.lock-card label { color: #dce8ee; font-weight: 750; font-size: 13px; }
.lock-card label input { display: block; width: 100%; margin-top: 7px; }

.user-chip {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 11px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.86);
  color: var(--ink);
  text-align: left;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}
.user-copy { display: grid; line-height: 1.15; }
.user-copy strong { font-size: 12px; }
.user-copy small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.logout-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
}
.logout-button:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.logout-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.user-management-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.user-management-head p { margin-bottom: 0; }
.account-grid { display: grid; gap: 10px; }
.account-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.25fr) minmax(130px, .8fr) minmax(120px, .7fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbfc;
}
.account-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.account-identity strong, .account-identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-identity small { color: var(--muted); margin-top: 3px; }
.role-badge { justify-self: start; padding: 6px 9px; border-radius: 999px; background: var(--soft); color: var(--brand); font-size: 12px; font-weight: 800; }
.account-status { color: var(--muted); font-size: 12px; font-weight: 750; }
.account-status.active { color: var(--ok); }
.account-actions { display: flex; gap: 6px; }
.account-actions button { min-height: 36px; padding: 0 10px; border-radius: 9px; font-size: 12px; }
.security-note { margin-top: 14px; padding: 12px 14px; border-radius: 11px; background: #fff8e8; border: 1px solid #efd9a5; color: #75520d; font-size: 13px; line-height: 1.5; }

@media (max-width: 1200px) {
  .grid.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .insight-grid { grid-template-columns: 1fr 1fr; }
  .mini-insight:last-child { grid-column: 1 / -1; }
}

@media (max-width: 980px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform .23s ease;
    overflow: hidden;
  }
  body.menu-open { overflow: hidden; }
  body.menu-open .sidebar { transform: translateX(0); }
  .sidebar-close { display: grid; place-items: center; margin-left: auto; width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.08); color: #fff; font-size: 24px; }
  .nav { grid-template-columns: 1fr; overflow-y: auto; }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 35; border: 0; background: rgba(3,16,24,.56); backdrop-filter: blur(2px); }
  body.menu-open .sidebar-scrim { display: block; }
  .mobile-menu-button { width: 42px; height: 42px; border-radius: 11px; background: #fff; border: 1px solid var(--line); display: grid; place-content: center; gap: 4px; }
  .mobile-menu-button span { width: 18px; height: 2px; border-radius: 2px; background: var(--ink); }
  .main { padding-inline: 20px; }
  .topbar { margin-inline: -20px; padding-inline: 20px; }
  .executive-grid { grid-template-columns: 1fr; }
  .health-panel { min-height: 300px; }
  .health-list { margin-top: 0; }
}

@media (max-width: 720px) {
  .dashboard-tabs { display: flex; padding: 3px 1px 10px; scroll-snap-type: x mandatory; }
  .dashboard-tabs button { flex: 0 0 128px; min-height: 90px; scroll-snap-align: start; }
  .toast-stack { left: 12px; right: 12px; width: auto; top: max(12px, env(safe-area-inset-top)); }
  .toast { grid-template-columns: 30px minmax(0, 1fr) 28px; min-height: 58px; padding: 10px; font-size: 14px; }
  .toast-icon { width: 28px; height: 28px; font-size: 17px; }
  .main { padding: 0 14px 26px; }
  .topbar { margin: 0 -14px 18px; padding: 12px 14px; min-height: 76px; flex-direction: row; align-items: center; }
  .topbar-title { min-width: 0; }
  .section-title-shell { width: 40vw; }
  .topbar h1 { max-width: 100%; }
  .topbar .eyebrow { font-size: 10px; }
  .sync-chip { display: none; }
  .user-copy { display: none; }
  .user-chip { padding-right: 6px; }
  .logout-button { display: none; }
  .install-button { width: 42px; padding: 0; font-size: 0; }
  .install-button::before { content: "+"; font-size: 22px; }
  .grid.stats { grid-template-columns: 1fr 1fr; }
  .stat { min-height: 116px; padding: 15px; }
  .stat strong { font-size: 1.1rem; }
  .executive-grid, .insight-grid { grid-template-columns: 1fr; }
  .mini-insight:last-child { grid-column: auto; }
  .panel, .form-card { padding: 16px; }
  .panel-head { flex-direction: column; }
  .sales-chart { min-height: 205px; }
  .donut-wrap { align-items: flex-start; }
}

@media (max-width: 430px) {
  .grid.stats { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
  .top-actions { gap: 5px; }
  .icon-button { width: 39px; height: 39px; }
  .mobile-menu-button { width: 39px; height: 39px; }
}

@media (max-width: 720px) {
  .account-row { grid-template-columns: 1fr auto; }
  .account-row .role-badge, .account-row .account-status { grid-column: auto; }
  .account-actions { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
