:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #16191d;
  --muted: #646c76;
  --accent: #1b5e4a;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --ok: #1b5e4a;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1d2125;
    --border: #2f353b;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --accent: #8bd8b8;
    --accent-text: #002014;
    --danger: #f2b8b5;
    --ok: #8bd8b8;
  }
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.ok { color: var(--ok); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: -6px 0 4px; }

/* ------------------------------------------------------------- login */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: min(100%, 380px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-box h1 { margin: 0; font-size: 24px; }
.login-box p { margin: 0 0 16px; }

/* ------------------------------------------------------------ layout */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

header h1 { margin: 0; font-size: 20px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.pill {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill.online { color: var(--ok); border-color: currentColor; }
.pill.offline { color: var(--danger); border-color: currentColor; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

main { padding: 24px 20px 64px; max-width: 860px; margin: 0 auto; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.section-head h2, main > section > h2 { margin: 0; font-size: 18px; }

/* ------------------------------------------------------------ botones */

button {
  font: inherit;
  border-radius: 8px;
  cursor: pointer;
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
button:hover { border-color: var(--muted); }

.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 600;
}
.primary:hover { opacity: 0.9; }

.ghost { background: transparent; }

.danger { color: var(--danger); border-color: var(--danger); background: transparent; }

/* ----------------------------------------------------------- tarjetas */

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

.card h3 { margin: 0 0 12px; font-size: 16px; }

.reminder-card { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }
.reminder-card .info { flex: 1 1 320px; min-width: 0; }
.reminder-card h3 { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.reminder-card .message { color: var(--muted); margin: 0 0 10px; overflow-wrap: anywhere; }
.reminder-card .meta { font-size: 14px; color: var(--muted); margin: 2px 0; }
.reminder-card .actions { display: flex; gap: 8px; align-items: flex-start; }

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.off { color: var(--danger); border-color: currentColor; }

/* ----------------------------------------------------------- formulario */

.form { display: flex; flex-direction: column; gap: 6px; }

label { font-size: 14px; font-weight: 600; margin-top: 10px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; margin: 0; }

input[type=text], input[type=password], input[type=time], input[type=date],
input[type=number], select, textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}

input[type=range] { width: 100%; accent-color: var(--accent); }
output { font-weight: 400; color: var(--muted); }

textarea { resize: vertical; }

.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 auto; }
.row.two > div { flex: 1 1 160px; }
.row button { flex: 0 0 auto; }

/* -------------------------------------------------------------- chips */

.chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 38px; align-items: center; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 8px 5px 12px;
  font-variant-numeric: tabular-nums;
}
.chip button {
  border: none;
  background: none;
  padding: 0 4px;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
}
.chip button:hover { color: var(--danger); }

/* --------------------------------------------------------------- dias */

.days { display: flex; flex-wrap: wrap; gap: 6px; }

.days label {
  margin: 0;
  font-weight: 400;
  cursor: pointer;
}
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days span {
  display: inline-block;
  min-width: 44px;
  text-align: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.days input:checked + span {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 600;
}
.days input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* -------------------------------------------------------------- modal */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 24px;
  width: min(100%, 560px);
  max-height: 90dvh;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog h2 { margin: 0 0 8px; font-size: 18px; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ----------------------------------------------------------- eventos */

.event {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  flex-wrap: wrap;
}
.event:last-child { border-bottom: none; }
.event time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.event .kind { font-weight: 600; }
.event .kind.acknowledged { color: var(--ok); }
.event .kind.missed { color: var(--danger); }

.empty { color: var(--muted); text-align: center; padding: 40px 20px; }
