/* Tonton Giovanni — esthétique inspirée Apple.com */

:root {
  --bg: #ffffff;
  --bg-alt: #f5f5f7;
  --bg-dark: #000000;
  --text: #1d1d1f;
  --muted: #86868b;
  --line: #d2d2d7;
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --blue-soft: rgba(0, 113, 227, 0.08);
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --max: 980px;
  --max-wide: 1200px;
  --nav-h: 48px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.47059;
  font-size: 17px;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.is-hidden { display: none !important; }
.bg-mesh { display: none; }

/* ========== NAV Apple-like ========== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 max(16px, calc((100% - var(--max-wide)) / 2 + 16px));
  background: rgba(251, 251, 253, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.brand {
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  text-decoration: none !important;
  flex-shrink: 0;
}
.brand:hover { opacity: 0.7; }
.top-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
  justify-content: center;
}
.top-nav a {
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  opacity: 0.88;
  padding: 0.35rem 0.7rem;
  border-radius: 980px;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background 0.2s, opacity 0.2s;
}
.top-nav a:hover,
.top-nav a.is-active {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
}
.user-info .role {
  display: inline-flex;
  padding: 0.15rem 0.5rem;
  border-radius: 980px;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
}
.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text);
  position: relative;
  transition: 0.2s;
}
.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
}
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 90;
}

/* ========== Layout ========== */
.layout { min-height: 100vh; display: flex; flex-direction: column; }
.main {
  flex: 1;
  width: min(var(--max-wide), 100%);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

/* ========== Typo / hero ========== */
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.page-head {
  text-align: center;
  padding: 1.5rem 0 2.5rem;
  max-width: 720px;
  margin: 0 auto;
}
.page-head h1 {
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin: 0 0 0.6rem;
}
.page-head .sub {
  font-size: 19px;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: -0.01em;
  max-width: 34em;
  margin: 0 auto;
}
.page-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ========== Buttons Apple ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.65rem 1.35rem;
  border-radius: 980px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--blue);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none !important;
  transition: background 0.2s, color 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--blue-soft); }
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-primary:hover {
  background: var(--blue-hover);
  color: #fff;
}
.btn-secondary {
  background: var(--bg-alt);
  color: var(--text);
  border-color: transparent;
}
.btn-secondary:hover { background: #ebebed; }
.btn-ghost {
  color: var(--text);
  border-color: var(--line);
  background: #fff;
  min-height: 36px;
  padding: 0.4rem 0.9rem;
  font-size: 13px;
}
.btn-ghost:hover { background: var(--bg-alt); }
.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-block { width: 100%; }
.btn-sm {
  min-height: 34px;
  padding: 0.35rem 0.85rem;
  font-size: 13px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.text-link {
  color: var(--blue);
  font-weight: 400;
  font-size: 15px;
  text-decoration: none;
}
.text-link:hover { text-decoration: underline; }

/* ========== Cards / panels ========== */
.grid-3, .grid-2 {
  display: grid;
  gap: 1rem;
}
.grid-3 { grid-template-columns: repeat(3, 1fr); margin-bottom: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card, .panel {
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  border: none;
  box-shadow: none;
}
.card.glow { background: var(--bg-alt); }
.card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}
.card h3 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0.15rem 0 0.45rem;
  line-height: 1.15;
}
.card p {
  color: var(--muted);
  font-size: 15px;
  margin: 0 0 1rem;
}
.panel {
  background: var(--bg-alt);
  margin-bottom: 1rem;
}
.panel h2 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* ========== Forms ========== */
.stack { display: grid; gap: 1rem; }
.stack.tight { gap: 0.5rem; margin-top: 0.5rem; }
.field { display: grid; gap: 0.4rem; }
.field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  outline: none;
  font-size: 16px; /* évite zoom iOS */
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2);
}
.field.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding-top: 0.4rem;
  min-height: 44px;
}
.field.check input {
  width: 18px;
  height: 18px;
  min-height: 0;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  align-items: end;
}
.form-actions { display: flex; align-items: end; }

/* ========== Alerts ========== */
.alert {
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  font-size: 14px;
}
.alert-error { background: #fff2f1; color: #8b1e18; }
.alert-ok { background: #eafaf0; color: #0d5c2e; }
.alert-info { background: #f0f6ff; color: #003d99; }
.api-limits {
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}
.api-limits strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

/* ========== Tables ========== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  background: #fff;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 560px;
}
th, td {
  text-align: left;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #fafafa;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.inline { display: inline; }
.inline-details summary { list-style: none; cursor: pointer; }
.empty {
  text-align: center;
  padding: 3rem 1.25rem;
  color: var(--muted);
  display: grid;
  gap: 1.25rem;
  justify-items: center;
}
.badge {
  display: inline-flex;
  padding: 0.2rem 0.55rem;
  border-radius: 980px;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.badge.ok { background: #eafaf0; color: #0d5c2e; }
.badge.warn { background: #fff6e5; color: #8a5a00; }
.code-block {
  display: block;
  margin: 0.8rem 0 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 13px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.muted { color: var(--muted); }
.fineprint { color: var(--muted); font-size: 13px; margin-top: 1.25rem; text-align: center; }

/* ========== Controls / stats ========== */
.controls {
  background: var(--bg-alt);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 0;
  margin-bottom: 1.25rem;
}
.controls-head {
  background: var(--bg-dark);
  color: #f5f5f7;
  padding: 1rem 1.35rem;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.controls-body { padding: 1.35rem; }
.history-row {
  display: flex;
  gap: 0.85rem;
  align-items: end;
  margin-top: 1.15rem;
  padding-top: 1.15rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-wrap: wrap;
}
.history-row .field { flex: 1; min-width: 200px; }
.status-line {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  border: 1px solid var(--line);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  margin: 1.25rem 0;
}
.kpi {
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  padding: 1rem 1.05rem;
}
.kpi .l {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.kpi .v {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 0.25rem;
  color: var(--text);
}
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 0.15rem; }

.page-identity {
  display: flex;
  gap: 1rem;
  align-items: center;
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-top: 0.5rem;
}
.page-identity img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
}
.page-identity h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page-identity p { margin: 0.2rem 0 0; color: var(--muted); font-size: 14px; }

.tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 1.25rem 0;
  justify-content: center;
}
.tab {
  border: 0;
  background: var(--bg-alt);
  color: var(--text);
  border-radius: 980px;
  padding: 0.55rem 1rem;
  min-height: 40px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  transition: background 0.2s, color 0.2s;
}
.tab.is-active {
  background: var(--text);
  color: #fff;
}
.tab-panel { display: none; }
.tab-panel.is-active { display: grid; gap: 1rem; }
.tab-panel .panel { background: var(--bg-alt); }

/* ========== LOGIN Apple ========== */
.auth-body {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.auth-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.25rem 4rem;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}
.auth-visual {
  text-align: center;
  margin-bottom: 2.5rem;
  width: 100%;
}
.auth-visual .eyebrow { color: var(--blue); }
.auth-visual h1 {
  font-size: clamp(40px, 10vw, 56px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin: 0.35rem 0 0.75rem;
}
.auth-visual .lede {
  color: var(--muted);
  font-size: 19px;
  max-width: 22em;
  margin: 0 auto;
}
.feature-list {
  list-style: none;
  margin: 1.5rem auto 0;
  display: grid;
  gap: 0.55rem;
  text-align: left;
  max-width: 280px;
  font-size: 14px;
  color: var(--muted);
}
.feature-list li {
  padding-left: 1.35rem;
  position: relative;
}
.feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
}
.auth-panel { width: 100%; }
.auth-card {
  background: var(--bg-alt);
  border-radius: 28px;
  padding: 2rem 1.5rem;
  width: 100%;
}
.auth-card-head { text-align: center; margin-bottom: 1.5rem; }
.auth-card-head h2 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0.5rem 0 0.3rem;
}
.auth-card-head p { color: var(--muted); font-size: 15px; }
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-block;
  background: linear-gradient(180deg, #3a3a3c 0%, #1d1d1f 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

/* ========== Responsive tablet ========== */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 2rem 1.15rem 3.5rem; }
}

/* ========== Responsive phone / small tablet ========== */
@media (max-width: 768px) {
  :root { --nav-h: 48px; }

  .nav-toggle { display: inline-flex; }

  .top-nav,
  .user-info {
    display: none;
  }

  .topbar.is-open .top-nav,
  .topbar.is-open .user-info {
    display: flex;
  }

  .topbar.is-open {
    flex-wrap: wrap;
    height: auto;
    padding-top: 0.35rem;
    padding-bottom: 0.85rem;
    align-items: flex-start;
  }
  .topbar.is-open .brand {
    height: 40px;
    display: flex;
    align-items: center;
  }
  .topbar.is-open .nav-toggle { margin-left: auto; }
  .topbar.is-open .top-nav {
    order: 3;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    padding-top: 0.5rem;
  }
  .topbar.is-open .top-nav a {
    font-size: 17px;
    padding: 0.75rem 0.85rem;
    border-radius: 12px;
  }
  .topbar.is-open .user-info {
    order: 4;
    width: 100%;
    flex-wrap: wrap;
    padding: 0.5rem 0.35rem 0;
    font-size: 14px;
    border-top: 1px solid rgba(0,0,0,0.06);
    margin-top: 0.35rem;
    padding-top: 0.75rem;
  }
  .nav-backdrop.is-open { display: block; }

  .grid-3,
  .grid-2,
  .kpi-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .page-head { padding: 1rem 0 1.75rem; text-align: left; }
  .page-head h1 { font-size: 32px; }
  .page-head .sub { font-size: 17px; margin: 0; }
  .page-actions { justify-content: flex-start; }

  .card h3 { font-size: 24px; }
  .card, .panel, .controls-body, .auth-card { padding: 1.35rem 1.15rem; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi .v { font-size: 20px; }

  .tabs { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.25rem; }
  .tab { flex-shrink: 0; }

  .page-identity { flex-direction: column; align-items: flex-start; text-align: left; }
  .history-row { flex-direction: column; align-items: stretch; }
  .history-row .btn { width: 100%; }

  .auth-layout { padding: 2rem 1rem 3rem; }
  .auth-visual h1 { font-size: 40px; }
  .auth-visual .lede { font-size: 17px; }
  .auth-card { border-radius: 22px; }

  table { min-width: 520px; font-size: 13px; }
  th, td { padding: 0.7rem 0.75rem; }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .btn { width: auto; }
  .page-actions .btn { width: 100%; }
}

/* Safe areas iPhone */
@supports (padding: max(0px)) {
  .topbar {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .main {
    padding-bottom: max(4rem, calc(2rem + env(safe-area-inset-bottom)));
  }
}
