/* RotaMeta — tema claro */
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap");

:root {
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #eef2f7;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-ring: rgba(37, 99, 235, 0.25);
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --max-w: 1120px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body:not(.auth-page) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body:not(.auth-page) .main-wrap {
  flex: 1 0 auto;
}

body:not(.auth-page) .topbar {
  flex-shrink: 0;
}

body:not(.auth-page) .site-footer {
  flex-shrink: 0;
  margin-top: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 100% -20%, rgba(37, 99, 235, 0.07), transparent 50%),
    radial-gradient(ellipse 80% 60% at 0% 100%, rgba(5, 150, 105, 0.05), transparent 45%);
  background-attachment: fixed;
}

a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

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

/* ——— Top bar ——— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.65rem 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text) !important;
}

.brand:hover {
  text-decoration: none;
  color: var(--accent) !important;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.nav a {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.nav a.nav-logout {
  color: var(--muted);
  border: 1px solid var(--border);
  margin-left: 0.35rem;
}

.nav a.nav-logout:hover {
  border-color: var(--border-strong);
  background: var(--bg);
  color: var(--danger);
}

/* ——— Main layout ——— */
.main-wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-title {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.page-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 52ch;
}

/* ——— Cards ——— */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
}

.card--flat {
  box-shadow: var(--shadow-sm);
}

.card--success {
  border-color: #a7f3d0;
  background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%);
}

.card h2,
.card h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ——— Stats / dashboard ——— */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}

.stat-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.info-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  padding: 1rem 1.15rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.info-strip code {
  font-size: 0.8rem;
  padding: 0.15rem 0.45rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  font-weight: 500;
}

/* ——— Tables ——— */
.table-card {
  padding: 0;
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.12s ease;
}

.data-table tbody tr:hover {
  background: #fafbfc;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table code {
  font-size: 0.78rem;
  padding: 0.2rem 0.45rem;
  background: #f1f5f9;
  border-radius: 6px;
  color: var(--text-secondary);
}

.empty-cell {
  text-align: center;
  padding: 2.5rem 1rem !important;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ——— Badges ——— */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-pending {
  background: var(--warning-soft);
  color: #b45309;
}

.badge-processing {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge-completed {
  background: var(--success-soft);
  color: var(--success);
}

.badge-failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill-ok {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--success);
}

.pill-ok::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.pill-off {
  color: var(--muted);
  font-size: 0.8rem;
}

/* ——— Forms ——— */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem 1.5rem;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
}

label.field span.hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  max-width: none;
  padding: 0.65rem 0.85rem;
  margin-top: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

textarea {
  min-height: 100px;
  resize: vertical;
}

label.field-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

label.field-check input {
  width: auto;
  accent-color: var(--accent);
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0;
  padding: 0.6rem 1.15rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

button:hover,
.btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  text-decoration: none;
  color: #fff;
}

button:active,
.btn:active {
  transform: translateY(1px);
}

a.btn {
  color: #fff !important;
  text-decoration: none !important;
}

a.btn:hover {
  color: #fff !important;
  text-decoration: none !important;
}

button.secondary,
.btn.secondary {
  background: #fff;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

button.secondary:hover,
.btn.secondary:hover {
  background: #f8fafc;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

a.btn.secondary {
  color: var(--text-secondary) !important;
}

a.btn.secondary:hover {
  color: var(--text) !important;
}

.btn-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.link-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 1.25rem;
}

.link-back:hover {
  color: var(--accent);
}

.error {
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0.5rem 0 0;
  padding: 0.65rem 0.85rem;
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  border: 1px solid #fecaca;
}

.ok {
  color: var(--success);
  font-weight: 600;
  margin: 0.5rem 0 0;
}

pre.api-key {
  margin: 0.75rem 0 0;
  padding: 1rem 1.1rem;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  border: 1px solid #334155;
  font-size: 0.8rem;
  line-height: 1.5;
  word-break: break-all;
  max-width: 100%;
  overflow-x: auto;
}

/* ——— Auth (login) ——— */
body.auth-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

body.auth-page .auth-shell {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

@media (min-width: 900px) {
  body.auth-page .auth-shell {
    grid-template-columns: 1fr 1fr;
    max-width: 1000px;
    margin: 2rem auto;
    min-height: auto;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
  }
}

.auth-aside {
  display: none;
  background: linear-gradient(145deg, #1e40af 0%, #3730a3 45%, #4f46e5 100%);
  color: #fff;
  padding: 2.5rem 2rem;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
}

@media (min-width: 900px) {
  .auth-aside {
    display: flex;
  }
}

.auth-aside h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.auth-aside p {
  margin: 0;
  opacity: 0.92;
  font-size: 0.95rem;
  line-height: 1.6;
  max-width: 36ch;
}

.auth-aside code {
  font-size: 0.88em;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
}

.auth-panel {
  background: var(--surface);
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (min-width: 900px) {
  .auth-panel {
    padding: 2.5rem 2.25rem;
  }
}

.auth-panel h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-panel .lead {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-panel form label.field {
  margin-bottom: 0.25rem;
}

.auth-panel button[type="submit"] {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
}

/* ——— Footer ——— */
.site-footer {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.25rem 1.5rem 1.75rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

body:not(.auth-page) .site-footer {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.6);
}

/* ——— Utility ——— */
.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
