@view-transition {
  navigation: auto;
}

:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --sidebar-bg: #eeedf1;
  --surface: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --accent: #0071e3;
  --accent-active: #0068d1;
  --destructive: #ff3b30;
  --destructive-text: #d70015;
  --destructive-bg: rgba(255, 59, 48, 0.12);

  --pendente: #9a5b00;
  --pendente-bg: rgba(255, 149, 0, 0.15);
  --pendente-dot: #ff9500;
  --aprovado: #0058ab;
  --aprovado-bg: rgba(0, 113, 227, 0.12);
  --aprovado-dot: #0071e3;
  --publicado: #1a7d34;
  --publicado-bg: rgba(52, 199, 89, 0.15);
  --publicado-dot: #34c759;
  --reprovado: #c81e13;
  --reprovado-bg: rgba(255, 59, 48, 0.12);
  --reprovado-dot: #ff3b30;

  --radius-lg: 12px;
  --radius-md: 8px;
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --fs-display: 1.7rem;
  --fs-title: 1.2rem;
  --fs-reading: 1.02rem;
  --fs-body: 0.92rem;
  --fs-sm: 0.85rem;
  --fs-label: 0.82rem;
  --fs-xs: 0.78rem;
  --fs-2xs: 0.72rem;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px -12px rgba(0, 0, 0, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="claro"]) {
    color-scheme: dark;
    --bg: #1e1e1e;
    --sidebar-bg: #242426;
    --surface: #2c2c2e;
    --border: rgba(255, 255, 255, 0.09);
    --text: #f5f5f7;
    --text-secondary: #98989d;
    --accent: #0a84ff;
    --accent-active: #409cff;
    --destructive: #ff453a;
    --destructive-text: #ff6961;
    --destructive-bg: rgba(255, 69, 58, 0.18);

    --pendente: #ffb340;
    --pendente-bg: rgba(255, 159, 10, 0.18);
    --pendente-dot: #ff9f0a;
    --aprovado: #6cb4ff;
    --aprovado-bg: rgba(10, 132, 255, 0.18);
    --aprovado-dot: #0a84ff;
    --publicado: #5ee184;
    --publicado-bg: rgba(48, 209, 88, 0.18);
    --publicado-dot: #30d158;
    --reprovado: #ff9089;
    --reprovado-bg: rgba(255, 69, 58, 0.18);
    --reprovado-dot: #ff453a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="escuro"] {
  color-scheme: dark;
  --bg: #1e1e1e;
  --sidebar-bg: #242426;
  --surface: #2c2c2e;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f5f5f7;
  --text-secondary: #98989d;
  --accent: #0a84ff;
  --accent-active: #409cff;
  --destructive: #ff453a;
  --destructive-text: #ff6961;
  --destructive-bg: rgba(255, 69, 58, 0.18);

  --pendente: #ffb340;
  --pendente-bg: rgba(255, 159, 10, 0.18);
  --pendente-dot: #ff9f0a;
  --aprovado: #6cb4ff;
  --aprovado-bg: rgba(10, 132, 255, 0.18);
  --aprovado-dot: #0a84ff;
  --publicado: #5ee184;
  --publicado-bg: rgba(48, 209, 88, 0.18);
  --publicado-dot: #30d158;
  --reprovado: #ff9089;
  --reprovado-bg: rgba(255, 69, 58, 0.18);
  --reprovado-dot: #ff453a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-system);
  font-size: 15px;
  line-height: 1.47;
}

h1, h2, h3 {
  font-family: var(--font-system);
  font-weight: 600;
  margin: 0 0 0.5rem;
  letter-spacing: -0.015em;
}

h1 { font-size: var(--fs-display); }
h2 { font-size: var(--fs-title); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-active); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent); color: #fff; }

/* ---------- app shell ---------- */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: block;
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text);
  padding: 0.4rem 0.6rem 1.1rem;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0 0.6rem;
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: 400;
}

.sidebar-item .icon { width: 17px; height: 17px; color: var(--text-secondary); flex-shrink: 0; }

.sidebar-item:hover { background: rgba(0, 0, 0, 0.05); }
@media (prefers-color-scheme: dark) {
  .sidebar-item:hover { background: rgba(255, 255, 255, 0.07); }
}

.sidebar-item.ativo {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  view-transition-name: sidebar-pill;
}

.sidebar-item.ativo .icon { color: #fff; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-pendente { background: var(--pendente-dot); }
.dot-aprovado { background: var(--aprovado-dot); }
.dot-publicado { background: var(--publicado-dot); }
.dot-reprovado { background: var(--reprovado-dot); }
.dot-todos { background: var(--text-secondary); }

.sidebar-item.ativo .dot { background: #fff; }

.sidebar-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--text-secondary);
}

.sidebar-item.ativo .sidebar-count { color: rgba(255, 255, 255, 0.85); }

.theme-switch {
  margin-top: auto;
  margin-left: 0.6rem;
  margin-right: 0.6rem;
  margin-bottom: 0.6rem;
  display: flex;
  gap: 2px;
  background: var(--border);
  padding: 2px;
  border-radius: var(--radius-md);
}

.theme-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--text-secondary);
}

.theme-option svg { width: 15px; height: 15px; }
.theme-option:hover { color: var(--text); }

.theme-option.ativo {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.content-solo .theme-switch {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  margin: 0;
  width: auto;
}

.sidebar-logout { color: var(--text-secondary); }

.content {
  flex: 1;
  min-width: 0;
  padding: 2.25rem 2.5rem 4rem;
  max-width: 760px;
}

.content-solo {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

/* ---------- login ---------- */

.login-card {
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2rem;
}

.login-brand {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 1rem;
}

/* ---------- page header ---------- */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.subtitle {
  color: var(--text-secondary);
  margin: 0.2rem 0 0;
  font-size: var(--fs-body);
}

/* ---------- grouped list (System Settings table) ---------- */

.list-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child { border-bottom: none; }

.list-row-link {
  color: var(--text);
  font-weight: 500;
}

.list-row .meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.list-row .timestamp {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.list-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--fs-body);
}

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
}

.card-narrow { max-width: 420px; }

.card-planning { background: var(--bg); box-shadow: none; }
.card-planning p { margin: 0; font-size: var(--fs-body); color: var(--text-secondary); }
.card-planning p + p { margin-top: 0.4rem; }
.card-planning p.meta-line { color: var(--text); font-weight: 500; }

/* ---------- forms ---------- */

form label {
  display: block;
  font-size: var(--fs-label);
  font-weight: 500;
  color: var(--text);
  margin: 1rem 0 0.35rem;
}

form label:first-child { margin-top: 0; }

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--fs-body);
  font-family: var(--font-system);
  background: var(--surface);
  color: var(--text);
}

input[type="text"],
input[type="password"] {
  min-height: 44px;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
  outline: none;
}

textarea { resize: vertical; }

/* ---------- buttons ---------- */

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 1.25rem;
  padding: 0 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--fs-body);
  font-family: var(--font-system);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease;
}

button:hover, .button:hover { background: var(--accent-active); }
button:active, .button:active { background: var(--accent-active); transform: scale(0.98); }

.button-secondary {
  background: transparent;
  color: var(--destructive-text);
  border: 1px solid var(--border);
}

.button-secondary:hover { background: var(--destructive-bg); }

.button-quiet {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: var(--fs-sm);
  white-space: nowrap;
  margin-top: 0;
}

.button-quiet:hover { background: var(--border); }

.actions { display: flex; gap: 0.6rem; }
.actions button { margin-top: 0; }
.actions-form { margin-top: 1.25rem; }

.alert {
  background: var(--destructive-bg);
  color: var(--destructive-text);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: var(--fs-body);
  margin-bottom: 1rem;
}

/* ---------- status chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
}

.chip-pendente { background: var(--pendente-bg); color: var(--pendente); }
.chip-aprovado { background: var(--aprovado-bg); color: var(--aprovado); }
.chip-publicado { background: var(--publicado-bg); color: var(--publicado); }
.chip-reprovado { background: var(--reprovado-bg); color: var(--reprovado); }

.chip-large { font-size: var(--fs-sm); padding: 0.35rem 0.85rem; }

.observacao {
  font-style: italic;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  font-size: var(--fs-body);
}

/* ---------- article read view ---------- */

.article-body {
  white-space: pre-wrap;
  margin-top: 1rem;
  font-size: var(--fs-reading);
  line-height: 1.7;
  max-width: 66ch;
}

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    padding: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand { padding: 0.85rem 1rem 0.6rem; }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.4rem;
    padding: 0 1rem 0.85rem;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }
  .sidebar-item { flex-shrink: 0; }
  .theme-switch { margin: 0 1rem 0.6rem; }
  .sidebar-logout { margin: 0 1rem 0.85rem; }
  .content { padding: 1.5rem 1.25rem 3rem; max-width: none; }
  .list-row { flex-direction: column; align-items: flex-start; }
  .list-row .meta { width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  button, .button, .sidebar-item { transition: none; }
  @view-transition { navigation: none; }
}
