/* PEDEM Camboriú · Linear DS · Light + Dark */
:root, [data-theme="light"] {
  color-scheme: light;

  --bg: #ffffff;
  --surface: #fafafa;
  --surface-2: #f4f4f5;
  --surface-3: #e9e9ec;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --border-subtle: #f1f1f3;

  --text: #18181b;
  --text-2: #3f3f46;
  --text-3: #52525b;
  --muted: #71717a;
  --disabled: #a1a1aa;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-active: #3730a3;
  --accent-soft: #eef2ff;
  --accent-text: #3730a3;
  --accent-rgb: 79, 70, 229;

  --success: #16a34a;
  --success-hover: #15803d;
  --success-soft: #f0fdf4;
  --success-text: #166534;
  --success-border: #bbf7d0;

  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-text: #991b1b;
  --danger-border: #fecaca;

  --warning: #d97706;
  --warning-soft: #fffbeb;
  --warning-text: #92400e;
  --warning-border: #fed7aa;

  --info: #2563eb;
  --info-soft: #eff6ff;
  --info-text: #1e40af;
  --info-border: #bfdbfe;

  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 2px 0 rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(16, 24, 40, 0.08), 0 1px 2px -1px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 10px 15px -3px rgba(16, 24, 40, 0.08), 0 4px 6px -4px rgba(16, 24, 40, 0.04);
  --ring: 0 0 0 3px rgba(var(--accent-rgb), 0.18);

  --dur: 180ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0a0a0b;
  --surface: #111114;
  --surface-2: #18181c;
  --surface-3: #27272a;
  --border: #27272a;
  --border-strong: #3f3f46;
  --border-subtle: #1f1f23;

  --text: #fafafa;
  --text-2: #d4d4d8;
  --text-3: #a1a1aa;
  --muted: #71717a;
  --disabled: #52525b;

  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-active: #6366f1;
  --accent-soft: #1e1b4b;
  --accent-text: #c7d2fe;
  --accent-rgb: 129, 140, 248;

  --success: #4ade80;
  --success-hover: #22c55e;
  --success-soft: #052e16;
  --success-text: #86efac;
  --success-border: #14532d;

  --danger: #f87171;
  --danger-hover: #ef4444;
  --danger-soft: #450a0a;
  --danger-text: #fca5a5;
  --danger-border: #7f1d1d;

  --warning: #fbbf24;
  --warning-soft: #451a03;
  --warning-text: #fcd34d;
  --warning-border: #78350f;

  --info: #60a5fa;
  --info-soft: #172554;
  --info-text: #93c5fd;
  --info-border: #1e3a8a;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.30);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.40), 0 1px 2px -1px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.40), 0 4px 6px -4px rgba(0, 0, 0, 0.30);
}

html, body, .card, .stat-card, .item-card, .item-card__header, .input, .select, .textarea, .btn, .btn-primary, .btn-secondary, .btn-danger, .btn-ghost, .table th, .table td, .badge, .alert, .app__sidebar, .app__nav a {
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  html, body, .card, .stat-card, .item-card, .input, .select, .textarea, .btn, .btn-primary, .btn-secondary, .btn-danger, .btn-ghost, .table th, .table td, .badge, .alert, .app__sidebar, .app__nav a {
    transition: none;
  }
}

* { box-sizing: border-box; }
*, *::before, *::after { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text-2);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { color: var(--text); font-weight: 600; line-height: 1.2; }
h1 { font-size: 1.875rem; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; letter-spacing: -0.015em; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }

a { color: var(--accent); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { color: var(--accent-hover); }

p { margin: 0; }
small, .text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.muted { color: var(--muted); }

/* === Layout === */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.app__sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.app__brand {
  font-weight: 600;
  color: var(--text);
  font-size: 1rem;
  letter-spacing: -0.015em;
  padding: 0.5rem 0.75rem;
}
.app__brand small { color: var(--muted); font-weight: 400; display: block; font-size: 0.75rem; }
.app__nav { display: flex; flex-direction: column; gap: 0.125rem; flex: 1; }
.app__nav a {
  color: var(--text-2);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.app__nav a:hover { background: var(--surface-2); color: var(--text); }
.app__nav a.is-active { background: var(--accent-soft); color: var(--accent-text); }
.app__user {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--muted);
}
.app__user strong { display: block; color: var(--text); font-weight: 500; font-size: 0.875rem; }
.app__user form { margin-top: 0.5rem; }

.app__main {
  padding: 2rem 2.5rem;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 1023px) {
  .app { grid-template-columns: 1fr; }
  .app__sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .app__nav { flex-direction: row; flex-wrap: wrap; }
  .app__user { border-top: 0; border-left: 1px solid var(--border); padding: 0 0.75rem; margin-left: auto; }
  .app__main { padding: 1.5rem 1rem; }
}

/* === Page header === */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.5rem; }
.page-header .subtitle { color: var(--muted); font-size: 0.875rem; }

.crumbs { font-size: 0.875rem; color: var(--muted); margin-bottom: 0.5rem; }
.crumbs a { color: var(--text-3); }
.crumbs span { margin: 0 0.375rem; color: var(--disabled); }

/* === Cards / Surface === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-xs);
}
.card + .card { margin-top: 1rem; }
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.card__title { font-weight: 600; color: var(--text); font-size: 1rem; }

.grid { display: grid; gap: 1rem; }
.grid--2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 767px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
}

/* === Stat cards (dashboard) === */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.stat-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.stat-card__label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.stat-card__value { font-size: 1.75rem; font-weight: 600; color: var(--text); line-height: 1.1; }
.stat-card__hint { font-size: 0.8125rem; color: var(--muted); }

/* === Progress bar === */
.progress {
  background: var(--surface-2);
  border-radius: var(--radius-full);
  height: 8px;
  overflow: hidden;
  margin-top: 0.5rem;
}
.progress__bar {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width var(--dur) var(--ease);
}
.progress--success .progress__bar { background: var(--success); }

/* === Buttons === */
.btn, .btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius);
  border: 1px solid transparent;
  min-height: 40px;
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur), color var(--dur);
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-primary:active { background: var(--accent-active); }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-3); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn:focus-visible, .btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-danger:focus-visible {
  outline: none; box-shadow: var(--ring);
}
.btn--sm { min-height: 32px; padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn:disabled { background: var(--disabled); color: #fff; cursor: not-allowed; }

/* === Forms === */
.form-row { display: flex; flex-direction: column; gap: 0.375rem; }
.form-row + .form-row { margin-top: 1rem; }
.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
}
.input, .select, .textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text);
  min-height: 44px;
  width: 100%;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.help { font-size: 0.75rem; color: var(--muted); }
.checkbox { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--text-2); cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }

/* === Tables === */
.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table th, .table td {
  text-align: left;
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
.table th { color: var(--text-3); font-weight: 500; font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.03em; background: var(--surface-2); }
.table tr:hover td { background: var(--surface-2); }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline; }

/* === Badge === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.badge--success { background: var(--success-soft); color: var(--success-text); }
.badge--warning { background: var(--warning-soft); color: var(--warning-text); }
.badge--danger { background: var(--danger-soft); color: var(--danger-text); }
.badge--muted { background: var(--surface-2); color: var(--text-3); }

/* === Alert === */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 0.9375rem;
  margin-bottom: 1rem;
}
.alert--success { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }
.alert--error   { background: var(--danger-soft);  border-color: var(--danger-border);  color: var(--danger-text); }
.alert--info    { background: var(--info-soft);    border-color: var(--info-border);    color: var(--info-text); }
.alert--warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning-text); }

/* === Login === */
.page-public {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  position: relative;
}
.page-public .theme-toggle { position: absolute; top: 1rem; right: 1rem; }
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}
.auth-card__brand { text-align: center; margin-bottom: 1.5rem; }
.auth-card__brand h1 { font-size: 1.5rem; }
.auth-card__brand small { color: var(--muted); font-size: 0.8125rem; }

/* === Plano show / edit === */
.plano-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.plano-meta dt { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; font-weight: 500; }
.plano-meta dd { color: var(--text); font-size: 0.9375rem; white-space: pre-wrap; }

.item-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  margin-top: 1rem;
  overflow: hidden;
}
.item-card__header {
  background: var(--surface-2);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  color: var(--text);
}
.item-card__body { padding: 0.5rem 0.75rem 0.75rem; }

.passo {
  display: grid;
  grid-template-columns: 1.5fr 1fr 0.7fr 0.9fr auto;
  gap: 0.5rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--border-subtle);
  align-items: center;
  font-size: 0.9375rem;
  transition: background var(--dur) var(--ease);
}
.passo:last-child { border-bottom: 0; }
.passo--head {
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0 0.375rem;
}
.passo--concluido { background: rgba(22, 163, 74, 0.04); }
.passo--andamento { background: rgba(217, 119, 6, 0.05); }
.passo--bloqueado { background: rgba(220, 38, 38, 0.04); }
@media (max-width: 1023px) {
  .passo { grid-template-columns: 1fr 1fr; }
  .passo--head { display: none; }
}

/* Inputs inline (sem borda visível até hover/focus) */
.input--inline, .select--inline {
  min-height: 34px;
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  border-color: transparent;
  background: transparent;
}
.input--inline:hover, .select--inline:hover {
  border-color: var(--border);
  background: var(--bg);
}
.input--inline:focus, .select--inline:focus {
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: var(--ring);
}
.input--inline[readonly] { color: var(--text-2); cursor: default; }
.input--inline[readonly]:hover { border-color: transparent; background: transparent; }

[x-cloak] { display: none !important; }

/* === Theme toggle === */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}
.theme-toggle__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.theme-toggle__btn:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle__btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.theme-toggle__btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* === Status bar (dashboard) === */
.status-bar {
  display: flex;
  height: 16px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.status-bar__seg {
  display: block;
  height: 100%;
  transition: width var(--dur) var(--ease);
}
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 0.25rem;
  vertical-align: middle;
}

/* === Error page === */
.page-error {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--surface);
}
.error-card { text-align: center; padding: 3rem 2rem; max-width: 480px; }
.error-card h1 { font-size: 4rem; color: var(--accent); }
.error-card p { margin: 1rem 0 1.5rem; }

/* === Misc utilities === */
.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; } .mb-4 { margin-bottom: 1rem; }
.flex-1 { flex: 1 1 0; }
.text-right { text-align: right; }
.empty-state { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* === Skip link for a11y === */
.skip-link {
  position: absolute;
  left: -10000px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 var(--radius) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
