:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e2e6ef;
  --border-strong: #d1d6e0;
  --text: #1a1f2e;
  --muted: #5a6275;
  --muted-soft: #8a93a6;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.15);
  --danger: #b91c1c;
  --success: #15803d;
  --warning: #92400e;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 32px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

[hidden] { display: none !important; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.card-header h2 {
  margin: 0;
}

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  height: 36px;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
  background: #eef0f5;
  border-color: var(--border-strong);
}

@media (max-width: 480px) {
  .btn-secondary {
    height: 32px;
    padding: 0 14px;
  }
}

header {
  text-align: center;
  margin-bottom: 28px;
}

header h1 {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  font-size: 15px;
}

.who {
  font-size: 13px;
  color: var(--muted);
  margin-top: 12px;
}
.who strong { color: var(--text); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 32px;
  margin: 0 auto 20px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
}

#form-section .card,
#list-section .card,
#schedules-section .card {
  max-width: 820px;
}

.card h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.card-desc {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 14px;
}

label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="password"],
select {
  display: block;
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 14px;
  background: white;
  color: var(--text);
  margin-top: 4px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder { color: var(--muted-soft); }

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  height: 42px;
  padding: 0 22px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

button:hover { background: var(--primary-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.link-btn {
  background: none;
  color: var(--primary);
  height: auto;
  padding: 0;
  font-weight: 400;
}
.link-btn:hover { background: none; text-decoration: underline; }

/* Auth row: input + button alineados horizontalmente en desktop */
.auth-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.auth-row input { margin-top: 0; flex: 1; }

.auth-row button {
  flex: 0 0 140px;
}

@media (max-width: 520px) {
  .auth-row {
    flex-direction: column;
    gap: 10px;
  }
  .auth-row button { flex: 1; width: 100%; }
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 12px;
}

.error { color: var(--danger); margin: 12px 0 0; font-size: 13px; }
.success { color: var(--success); }
.warning { color: var(--warning); }

.result {
  margin-top: 14px;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  display: none;
}

.result.show { display: block; }
.result.success { background: #ecfdf5; color: var(--success); border: 1px solid #a7f3d0; }
.result.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.list-header h2 { margin: 0; }

ul#event-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#event-list li {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.ev-title { font-weight: 600; margin-bottom: 4px; }
.ev-meta { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.ev-cron { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-style: italic; }
.ev-actions { display: flex; gap: 8px; margin-top: 6px; }

.btn-cancel {
  background: white;
  color: var(--danger);
  border: 1px solid #fecaca;
  font-size: 13px;
  height: 32px;
  padding: 0 14px;
}
.btn-cancel:hover { background: #fef2f2; }

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.tag-start { background: #dcfce7; color: #15803d; }
.tag-stop { background: #fee2e2; color: #b91c1c; }
.tag-auto { background: #e0e7ff; color: #4338ca; }

.muted-soft { color: var(--muted-soft); font-size: 12px; }

.table-wrap { overflow-x: auto; }

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.schedule-table th,
.schedule-table td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.schedule-table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #fafbfd;
  position: sticky;
  top: 0;
}

.schedule-table th:first-child,
.schedule-table td:first-child {
  width: 40px;
  text-align: right;
  color: var(--muted-soft);
}

.schedule-table tbody tr:last-child td { border-bottom: none; }
.schedule-table tbody tr:hover { background: #fafbfd; }

.schedule-table td.muted { color: var(--muted-soft); }

.schedule-line { display: block; }
.schedule-line + .schedule-line { margin-top: 2px; }

footer {
  margin-top: auto;
  padding-top: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--muted-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.footer-meta { color: var(--muted-soft); }

@media (max-width: 600px) {
  main { padding: 28px 14px 20px; }
  header h1 { font-size: 21px; }
  .subtitle { font-size: 14px; }
  .card { padding: 22px 18px; border-radius: 12px; }
  .row { grid-template-columns: 1fr; }
}
