/* ====== Base / Theme vars ====== */
:root {
  --bg: #0b0e12;
  --card: #12161c;
  --muted: #8ea0b3;
  --text: #e8eef6;
  --brand: #4f8cff;
  --brand-press: #3a6cce;
  --success: #15b374;
  --danger: #f44336;
  --border: #1f2630;
  --radius: 16px;
  --shadow: 0 10px 25px rgba(0,0,0,.25);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fb;
    --card: #ffffff;
    --muted: #5a6776;
    --text: #0d1117;
    --brand: #2563eb;
    --brand-press: #1e4bb3;
    --success: #0ea66a;
    --danger: #e53935;
    --border: #e6eaf0;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ====== Layout ====== */
.container {
  width: 100%;
  max-width: 960px;
  padding: 0 16px;
  margin: 0 auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(120%) blur(8px);
  background: color-mix(in hsl, var(--bg) 80%, transparent);
  border-bottom: 1px solid var(--border);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: 12px;
}

.brand {
  text-decoration: none;
  font-weight: 800;
  letter-spacing: .3px;
  color: var(--text);
  font-size: 1.1rem;
}

.auth {
  display: flex;
  align-items: center;
  gap: 10px;
}

.welcome { color: var(--muted); font-size: .95rem; }

.page-content {
  padding: 16px 0 80px;
}

/* ====== Cards ====== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 12px 0;
}

/* ====== Typography ====== */
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h2 { font-size: 1.25rem; }
p { margin: 8px 0 12px; color: var(--muted); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .06s ease, background .2s ease, border-color .2s ease;
  user-select: none;
}

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

.btn-primary {
  background: var(--brand);
  color: white;
}
.btn-primary:hover { background: var(--brand-press); }

.btn-light {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-light:hover { background: rgba(127,127,127,.08); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}

/* Turn plain <button> into nice buttons too */
button {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .06s ease, background .2s ease;
}
button:hover { background: var(--brand-press); }
button:active { transform: translateY(1px); }
button[disabled] { opacity: .6; cursor: not-allowed; }

/* ====== Forms ====== */
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  font-size: 1rem;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
}

label { display: block; margin: 12px 0 6px; color: var(--muted); font-weight: 600; }

form .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ====== Lists & links ====== */
ul { padding-left: 16px; }
ul li + li { margin-top: 6px; }

/* ====== Tables (responsive-as-cards on mobile) ====== */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

thead th {
  text-align: left;
  font-size: .9rem;
  color: var(--muted);
  font-weight: 700;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child td { border-bottom: none; }

/* Scroll horizontal por defecto (por si la tabla es grande) */
.table-wrap { width: 100%; overflow-x: auto; }

/* En móviles, “cardificar” las tablas (si agregas la clase .table-stack a la tabla) */
@media (max-width: 640px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td {
    display: block; width: 100%;
  }
  .table-stack tr {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    margin: 10px 0;
    box-shadow: var(--shadow);
  }
  .table-stack td {
    border: 0;
    padding: 6px 0;
  }
  .table-stack td::before {
    content: attr(data-label);
    display: block;
    font-size: .8rem;
    color: var(--muted);
    margin-bottom: 2px;
  }
}

/* ====== Helpers ====== */
.hr { border-top: 1px solid var(--border); margin: 16px 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.right { text-align: right; }
