:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --ink: #15231c;
  --muted: #65736b;
  --line: #d8e0db;
  --brand: #173f31;
  --brand-2: #275e48;
  --brand-soft: #e7f0eb;
  --blue: #315d78;
  --blue-soft: #e9f1f6;
  --amber: #8a6117;
  --amber-soft: #f8f0dd;
  --slate: #52636a;
  --slate-soft: #edf1f2;
  --danger: #9b3434;
  --shadow: 0 8px 26px rgba(26, 54, 40, .07);
  --radius-lg: 22px;
  --radius-md: 15px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% -10%, rgba(39,94,72,.10), transparent 32rem),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button, input { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; }

.app-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding:
    max(18px, env(safe-area-inset-top))
    16px
    calc(30px + env(safe-area-inset-bottom));
}

.hero {
  padding: 10px 2px 18px;
}

.brand-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(23,63,49,.10);
  box-shadow: 0 7px 18px rgba(23,63,49,.08);
  overflow: hidden;
}

.brand-mark img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  display: block;
}

.eyebrow,
.section-kicker {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .11em;
}

h1 {
  margin: 0;
  color: var(--brand);
  font-size: clamp(1.55rem, 5vw, 2.2rem);
  letter-spacing: -.035em;
  line-height: 1;
}

.hero-copy {
  margin: 14px 0 16px;
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.45;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  white-space: nowrap;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a7b0ab;
}

.sync-badge.live .sync-dot { background: #2e8a5a; }
.sync-badge.live { color: var(--brand-2); }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-box:focus-within {
  border-color: #91aa9d;
  box-shadow: 0 0 0 4px rgba(39,94,72,.08), var(--shadow);
}

.search-box svg {
  width: 21px;
  height: 21px;
  margin-left: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.search-box input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.clear-search {
  width: 42px;
  height: 42px;
  margin-right: 5px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}

.clear-search.visible {
  opacity: 1;
  pointer-events: auto;
}

.section-block { margin-top: 22px; }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 11px;
}

.section-heading.compact { align-items: center; }

.section-heading h2,
.group-heading h3 {
  margin: 0;
  color: var(--ink);
  letter-spacing: -.025em;
}

.section-heading h2 { font-size: 1.2rem; }

.count-pill {
  padding: 5px 9px;
  border-radius: 999px;
  background: #e4ebe7;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 850;
}

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

.quick-card {
  position: relative;
  min-height: 126px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(23,63,49,.12);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}

.quick-card::after {
  content: "";
  position: absolute;
  width: 88px;
  height: 88px;
  right: -28px;
  top: -28px;
  border-radius: 50%;
  background: var(--brand-soft);
  opacity: .7;
}

.quick-card:active,
.tool-card:active { transform: scale(.985); }

.quick-icon,
.tool-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
}

.quick-icon {
  width: 39px;
  height: 39px;
  background: var(--brand-soft);
  color: var(--brand);
  z-index: 1;
}

.quick-icon svg,
.tool-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.quick-card strong {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 92%;
  color: var(--brand);
  font-size: .98rem;
  line-height: 1.18;
  letter-spacing: -.02em;
}

.quick-card small {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: .74rem;
  line-height: 1.25;
}

.recent-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(210px, 72%);
  gap: 9px;
  overflow-x: auto;
  padding: 1px 2px 7px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.recent-grid::-webkit-scrollbar { display: none; }

.recent-card {
  scroll-snap-align: start;
}

.group-filters {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 22px -16px 0;
  padding: 10px 16px;
  background: linear-gradient(to bottom, rgba(243,246,244,.97), rgba(243,246,244,.90));
  backdrop-filter: blur(12px);
  scrollbar-width: none;
}
.group-filters::-webkit-scrollbar { display: none; }

.filter-chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 800;
  cursor: pointer;
}

.filter-chip.active {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

.group-block {
  margin: 0 0 15px;
}

.group-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 2px 8px;
}

.group-heading h3 { font-size: .98rem; }

.group-heading .group-count {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 750;
}

.tool-list {
  display: grid;
  gap: 7px;
}

.tool-card {
  min-height: 68px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-decoration: none;
  box-shadow: 0 3px 12px rgba(26,54,40,.04);
  transition: transform .15s ease, box-shadow .15s ease;
}

.tool-icon {
  width: 40px;
  height: 40px;
  background: var(--brand-soft);
  color: var(--brand);
}

.tool-card.group-commandes .tool-icon {
  background: var(--blue-soft);
  color: var(--blue);
}

.tool-card.group-fournisseurs .tool-icon {
  background: var(--amber-soft);
  color: var(--amber);
}

.tool-card.group-stock .tool-icon {
  background: var(--slate-soft);
  color: var(--slate);
}

.tool-text {
  min-width: 0;
  display: block;
}

.tool-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-size: .94rem;
  line-height: 1.22;
  letter-spacing: -.015em;
}

.tool-description {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.28;
}

.tool-arrow {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #93a099;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.text-button {
  border: 0;
  padding: 6px;
  background: transparent;
  color: var(--brand-2);
  font-weight: 800;
  font-size: .78rem;
  cursor: pointer;
}

.empty-state {
  margin: 36px 0;
  padding: 30px 18px;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  margin: 8px 0 5px;
  color: var(--ink);
  font-size: 1.1rem;
}

.empty-state p {
  margin: 0;
  font-size: .85rem;
}

.empty-icon {
  font-size: 2rem;
  color: #8e9b94;
}

footer {
  padding: 28px 4px 4px;
  color: #7b8881;
  text-align: center;
  font-size: .72rem;
}

footer p { margin: 3px 0; }

.hidden { display: none !important; }

@media (min-width: 680px) {
  .app-shell { padding-left: 24px; padding-right: 24px; }
  .hero { padding-top: 22px; }
  .quick-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .quick-card { min-height: 140px; }
  .tool-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recent-grid { grid-auto-flow: initial; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: visible; }
  .group-filters { margin-left: -24px; margin-right: -24px; padding-left: 24px; padding-right: 24px; }
}

@media (min-width: 1000px) {
  .tool-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
