:root {
  --bg: #0f1115;
  --card: #171a21;
  --panel: #0d0f13;
  --border: #262b36;
  --text: #e8eaed;
  --muted: #9aa3af;
  /* níveis de cor — não mudam entre os temas */
  --accent: #3fa9f5;
  --ok: #35c37b;
  --yellow: #d8c92d;
  --warn: #f5a623;
  --danger: #f24f4f;
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --card: #ffffff;
  --panel: #eef0f3;
  --border: #dde1e7;
  --text: #14171c;
  --muted: #5b6472;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

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

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; font-size: 18px; }
.topbar nav a { margin-left: 16px; color: var(--muted); }
.topbar nav a:hover { color: var(--text); }

/* Layout com menu lateral */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; flex-shrink: 0; background: var(--card);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 20px; font-weight: 700; font-size: 18px; }
.sidebar-group { padding: 0 12px; margin-bottom: 4px; }
.sidebar-group-label { padding: 10px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: var(--muted); font-size: 14px; margin-bottom: 2px;
}
.sidebar-link:hover { background: var(--panel); color: var(--text); }
.sidebar-link.active { background: var(--panel); color: var(--text); font-weight: 600; border-left: 3px solid var(--accent); padding-left: 9px; }
.sidebar-link.locked { color: var(--muted); cursor: not-allowed; opacity: .6; }
.sidebar-link-admin { color: var(--warn); }
.sidebar-link-admin:hover { color: var(--warn); }
.sidebar-sublink { padding-left: 34px; font-size: 13px; }
.sidebar-footer {
  margin-top: auto; padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sidebar-footer a { color: var(--muted); position: relative; font-size: 16px; }
.sidebar-footer a:hover { color: var(--text); }

.mobile-topbar {
  display: none; align-items: center; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); background: var(--card); position: sticky; top: 0; z-index: 40;
}
.mobile-topbar button {
  background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  font-size: 18px; padding: 6px 10px; cursor: pointer;
}
.mobile-topbar .brand { font-weight: 700; font-size: 16px; }

.sidebar-backdrop { display: none; }

.main-content { flex: 1; min-width: 0; }

@media (max-width: 900px) {
  .mobile-topbar { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 45;
  }
}

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px; margin-bottom: 16px;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 600; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge-ok { background: rgba(53,195,123,.15); color: var(--ok); }
.badge-yellow { background: rgba(216,201,45,.15); color: var(--yellow); }
.badge-warn { background: rgba(245,166,35,.15); color: var(--warn); }
.badge-danger { background: rgba(242,79,79,.15); color: var(--danger); }

.btn {
  display: inline-block; background: var(--accent); color: #05131f;
  border: none; padding: 10px 18px; border-radius: 8px; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }

.input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
}
label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 14px; }
.field { margin-bottom: 14px; }

.hero { text-align: center; padding: 80px 24px 60px; }
.hero h1 { font-size: 40px; margin-bottom: 12px; }
.hero p { color: var(--muted); font-size: 18px; max-width: 600px; margin: 0 auto 28px; }

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.plan-card { text-align: center; }
.plan-price { font-size: 32px; font-weight: 700; margin: 10px 0; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: rgba(242,79,79,.12); color: var(--danger); border: 1px solid rgba(242,79,79,.3); }

.chat-box { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; margin-bottom: 16px; }
.msg { padding: 10px 14px; border-radius: 10px; max-width: 80%; font-size: 14px; }
.msg-user { background: var(--accent); color: #05131f; align-self: flex-end; }
.msg-assistant { background: var(--card); border: 1px solid var(--border); align-self: flex-start; white-space: pre-wrap; }

@media (max-width: 700px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
