:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --line: #334155;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-2: #1d4ed8;
  --danger: #ef4444;
  --ok: #10b981;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button {
  font: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 8px 14px;
  border-radius: 6px;
}
button:hover { background: var(--accent-2); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.ghost:hover { background: var(--panel-2); }
button.danger { background: var(--danger); }
button.danger:hover { background: #b91c1c; }
button.icon { background: transparent; color: var(--muted); padding: 4px 8px; font-size: 18px; }

input, select {
  font: inherit;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 6px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 18px; margin: 6px 0 0; }

/* ----- login ----- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at 30% 30%, #1e293b 0%, var(--bg) 60%);
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card label { display: block; margin: 18px 0 6px; }
.login-card button { width: 100%; margin-top: 18px; padding: 10px; }

/* ----- topbar ----- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 28px !important; width: auto !important; border-radius: 4px; object-fit: contain; }
.login-logo {
  display: block;
  margin: 0 auto 14px;
  height: 90px !important;
  width: auto !important;
  max-width: 100%;
  object-fit: contain;
  border-radius: 6px;
}
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input[type="search"] { width: 280px; }

/* ----- grid ----- */
main { padding: 12px; }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  max-height: calc(100vh - 130px);
}
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
thead th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  font-weight: 600;
}
thead th.actions-col { cursor: default; }
thead th .arrow { color: var(--muted); margin-left: 4px; }
tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid #1e293b;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
tbody tr:hover { background: #16213a; }
.row-actions { display: flex; gap: 4px; }
.row-actions button {
  padding: 3px 8px;
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.row-actions button:hover { background: var(--panel-2); }
.row-actions .del { color: #fca5a5; }
.row-actions .del:hover { background: #3b0d0d; border-color: #7f1d1d; }
.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--line);
}
.pill.activo { color: #86efac; border-color: #14532d; background: #052e16; }
.pill.inactivo { color: #fca5a5; border-color: #7f1d1d; background: #2a0a0a; }

.status-bar {
  display: flex;
  justify-content: space-between;
  padding: 8px 4px;
  color: var(--muted);
  font-size: 12px;
}

/* ----- modal ----- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.modal[hidden] { display: none !important; }
.toast[hidden] { display: none !important; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: min(900px, 96vw);
  max-height: 92vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-card.small { width: min(420px, 96vw); }
.modal-card header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.modal-card header h2 { margin: 0; font-size: 16px; }
.modal-card form, .modal-card .confirm-text {
  padding: 16px;
  overflow: auto;
}
.modal-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--panel-2);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px 16px;
}
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.field .hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.field.full { grid-column: 1 / -1; }

/* ----- toast ----- */
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 8px;
  z-index: 20;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.ok { border-color: #14532d; }
.toast.err { border-color: #7f1d1d; color: #fecaca; }
