/* ========================================================================== *
 *  ClockPilot — dark "aurora glass" UI
 *  Design tokens, glassmorphism, gradient buttons, micro-interactions.
 * ========================================================================== */

:root {
  /* Base surfaces */
  --bg: #080a12;
  --bg-2: #0b0e1a;
  --ink: #e9ecf7;
  --muted: #99a2bd;
  --faint: #6b7391;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);

  /* Glass */
  --glass: rgba(255, 255, 255, 0.045);
  --glass-2: rgba(255, 255, 255, 0.07);
  --glass-hi: rgba(255, 255, 255, 0.12);

  /* Signature gradient (indigo -> violet -> fuchsia) */
  --g1: #6366f1;
  --g2: #8b5cf6;
  --g3: #d946ef;
  --grad: linear-gradient(135deg, var(--g1), var(--g2) 48%, var(--g3));
  --grad-soft: linear-gradient(135deg, rgba(99, 102, 241, .22), rgba(217, 70, 239, .22));

  /* Semantic accents */
  --accent: #8b5cf6;
  --accent-ink: #c4b5fd;
  --green: #34d399;
  --green-ink: #6ee7b7;
  --red: #fb7185;
  --red-ink: #fda4af;
  --amber: #fbbf24;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, .75);
  --shadow-glow: 0 10px 30px -8px rgba(139, 92, 246, .55);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: .1px;
  position: relative;
  overflow-x: hidden;
}

/* Aurora background — soft coloured blobs fixed behind everything */
body::before {
  content: "";
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 90vh;
  z-index: -1;
  background:
    radial-gradient(46% 55% at 18% 12%, rgba(99, 102, 241, .30), transparent 60%),
    radial-gradient(40% 50% at 82% 8%, rgba(217, 70, 239, .22), transparent 60%),
    radial-gradient(45% 55% at 60% 40%, rgba(34, 211, 238, .12), transparent 60%);
  filter: blur(30px);
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 120% at 50% -10%, transparent 55%, rgba(0, 0, 0, .55) 100%);
  pointer-events: none;
}

a { color: var(--accent-ink); text-decoration: none; transition: color .18s ease; }
a:hover { color: #fff; }

::selection { background: rgba(139, 92, 246, .35); color: #fff; }

/* --------------------------------------------------------------------------
 * Top bar
 * -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(10, 12, 22, .72);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .2px;
  color: var(--ink);
}
.brand:hover { color: var(--ink); }
.brand .logo {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--grad);
  box-shadow: var(--shadow-glow);
  font-size: 15px;
}
.brand .name {
  background: linear-gradient(90deg, #fff, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.topbar nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  position: relative;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 9px;
  transition: color .18s ease, background .18s ease;
}
.topbar nav a:hover { color: var(--ink); background: var(--glass); }
.topbar nav a.active { color: #fff; background: var(--grad-soft); }
.topbar nav a.active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 3px; height: 2px;
  border-radius: 2px;
  background: var(--grad);
}

/* --------------------------------------------------------------------------
 * Layout
 * -------------------------------------------------------------------------- */
.container { max-width: 920px; margin: 32px auto 64px; padding: 0 18px; }
h1 {
  font-size: 26px; font-weight: 800; margin: 0 0 6px; letter-spacing: -.3px;
}
.page-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 14px; letter-spacing: .2px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 680px) { .grid { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
 * Cards (glass)
 * -------------------------------------------------------------------------- */
.card {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  box-shadow: var(--shadow);
  animation: rise .5s cubic-bezier(.2, .7, .2, 1) both;
}
/* subtle top highlight line */
.card::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .14), transparent 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}
.card.narrow { max-width: 440px; margin: 8vh auto; }
.card.hover { transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.card.hover:hover { transform: translateY(-3px); border-color: var(--line-strong); }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.head-actions { display: flex; align-items: center; gap: 10px; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.card:nth-child(2) { animation-delay: .05s; }
.card:nth-child(3) { animation-delay: .1s; }
.card:nth-child(4) { animation-delay: .15s; }

/* --------------------------------------------------------------------------
 * Buttons
 * -------------------------------------------------------------------------- */
button, .btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--grad);
  color: #fff;
  border: 0; border-radius: 11px;
  padding: 11px 18px;
  font: inherit; font-weight: 650; font-size: 14px;
  letter-spacing: .2px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 8px 22px -10px rgba(139, 92, 246, .8), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease, opacity .2s ease;
}
/* shimmer sweep */
button::after, .btn::after {
  content: "";
  position: absolute; top: 0; left: -120%;
  width: 60%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .35), transparent);
  transform: skewX(-18deg);
  transition: left .6s ease;
}
button:hover, .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -10px rgba(139, 92, 246, .95), inset 0 1px 0 rgba(255, 255, 255, .3);
  color: #fff;
}
button:hover::after, .btn:hover::after { left: 130%; }
button:active, .btn:active { transform: translateY(0) scale(.98); }
button:disabled { opacity: .55; cursor: default; transform: none; filter: saturate(.7); }
button:disabled::after { display: none; }

.btn { text-decoration: none; }
.btn.tiny, button.tiny { padding: 6px 12px; font-size: 13px; border-radius: 10px; }

/* Variants */
button.secondary, .btn.secondary {
  background: var(--glass-2);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
button.secondary:hover, .btn.secondary:hover {
  background: var(--glass-hi);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
button.green {
  background: linear-gradient(135deg, #10b981, #34d399);
  box-shadow: 0 8px 22px -10px rgba(16, 185, 129, .85), inset 0 1px 0 rgba(255, 255, 255, .3);
  color: #04160e;
}
button.green:hover { box-shadow: 0 14px 30px -10px rgba(16, 185, 129, 1), inset 0 1px 0 rgba(255, 255, 255, .35); }
button.red {
  background: linear-gradient(135deg, #f43f5e, #fb7185);
  box-shadow: 0 8px 22px -10px rgba(244, 63, 94, .85), inset 0 1px 0 rgba(255, 255, 255, .3);
  color: #1a0509;
}
button.red:hover { box-shadow: 0 14px 30px -10px rgba(244, 63, 94, 1), inset 0 1px 0 rgba(255, 255, 255, .35); }
button.block { width: 100%; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }
.inline { display: inline; }
.mt { margin-top: 14px; }

/* --------------------------------------------------------------------------
 * Forms
 * -------------------------------------------------------------------------- */
label { display: block; margin: 14px 0; color: var(--muted); font-size: 13px; font-weight: 500; }
input, select {
  width: 100%; margin-top: 7px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(6, 8, 16, .6);
  color: var(--ink);
  font: inherit; font-size: 14px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(6, 8, 16, .85);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, .18);
}
select option { background: #0b0e1a; }

.row { display: flex; gap: 14px; }
.row label { flex: 1; }
@media (max-width: 520px) { .row { flex-direction: column; gap: 0; } }

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: 16px 0; padding: 6px 16px 16px;
  background: rgba(255, 255, 255, .02);
}
legend { color: var(--accent-ink); font-size: 12px; font-weight: 600; padding: 0 8px; letter-spacing: .3px; text-transform: uppercase; }

.days { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
/* Weekday chips (styled checkboxes) */
.day {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; margin: 0;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--glass);
  color: var(--muted);
  cursor: pointer; user-select: none;
  transition: all .16s ease;
}
.day:hover { border-color: var(--accent); color: var(--ink); }
.day input { width: auto; margin: 0; accent-color: var(--accent); }
.day:has(input:checked) {
  background: var(--grad-soft);
  border-color: transparent;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, .5);
}

/* iOS-style toggle switch */
.switch {
  display: inline-flex; align-items: center; gap: 12px;
  color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer; margin: 4px 0 18px;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: relative; width: 46px; height: 27px; border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid var(--line-strong);
  transition: background .2s ease, box-shadow .2s ease;
  flex: none;
}
.switch .track::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
  transition: transform .22s cubic-bezier(.3, 1.4, .5, 1);
}
.switch input:checked + .track {
  background: var(--grad);
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}
.switch input:checked + .track::before { transform: translateX(19px); }

/* --------------------------------------------------------------------------
 * Tables
 * -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th, table tr:first-child th {
  color: var(--faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
}
tbody tr, table tr { transition: background .15s ease; }
tbody tr:hover, table tr:hover { background: rgba(255, 255, 255, .03); }
td:last-child, th:last-child { border-bottom: 1px solid var(--line); }
.msg { color: var(--muted); max-width: 340px; }

/* --------------------------------------------------------------------------
 * Text helpers + alerts
 * -------------------------------------------------------------------------- */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.error { color: var(--red-ink); }
.ok { color: var(--green-ink); }
.warn { color: var(--amber); }

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  margin: 0 0 18px; font-size: 14px;
  animation: rise .4s ease both;
}
.alert.ok { background: rgba(16, 185, 129, .12); border-color: rgba(52, 211, 153, .4); color: var(--green-ink); }
.alert.bad { background: rgba(244, 63, 94, .12); border-color: rgba(251, 113, 133, .4); color: var(--red-ink); }
.alert.warn { background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .35); color: var(--amber); }

/* --------------------------------------------------------------------------
 * Status / current state
 * -------------------------------------------------------------------------- */
.state-hero { display: flex; align-items: center; gap: 16px; margin: 4px 0 20px; }
.pulse {
  position: relative; flex: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--faint);
}
.pulse.on { background: var(--green); box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); }
  70% { box-shadow: 0 0 0 14px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.state-label { font-size: 22px; font-weight: 800; letter-spacing: -.2px; }
.state-label.on { color: var(--green-ink); }
.state-label.off { color: var(--muted); }
.state-sub { font-size: 13px; color: var(--faint); margin-top: 2px; }

/* Pills: badge / status / tag */
.badge, .status, .tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .3px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.on, .status.success {
  background: rgba(52, 211, 153, .14); color: var(--green-ink); border-color: rgba(52, 211, 153, .35);
}
.badge.off { background: var(--glass-2); color: var(--muted); border-color: var(--line-strong); }
.status.rejected { background: rgba(251, 191, 36, .14); color: var(--amber); border-color: rgba(251, 191, 36, .35); }
.status.login_failed, .status.error { background: rgba(251, 113, 133, .14); color: var(--red-ink); border-color: rgba(251, 113, 133, .35); }
.status.upcoming { background: rgba(139, 92, 246, .14); color: var(--accent-ink); border-color: rgba(139, 92, 246, .32); }
.status.pending { background: rgba(139, 92, 246, .16); color: var(--accent-ink); border-color: rgba(139, 92, 246, .4); }
.status.pending::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .8s linear infinite;
}
.tag { text-transform: capitalize; }
.tag.entrada { background: rgba(52, 211, 153, .14); color: var(--green-ink); border-color: rgba(52, 211, 153, .3); }
.tag.salida { background: rgba(251, 113, 133, .14); color: var(--red-ink); border-color: rgba(251, 113, 133, .3); }
.tag.manual { background: rgba(148, 163, 184, .16); color: var(--muted); border-color: rgba(148, 163, 184, .32); }

/* --------------------------------------------------------------------------
 * Today's plan — timeline
 * -------------------------------------------------------------------------- */
.plan { list-style: none; padding: 0; margin: 0; position: relative; }
.plan::before {
  content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px;
  width: 2px; background: var(--line-strong);
}
.plan li {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 11px 0 11px 28px;
}
.plan li::before {
  content: ""; position: absolute; left: 2px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg-2); border: 2px solid var(--faint); z-index: 1;
}
.plan li.done::before { background: var(--green); border-color: var(--green); box-shadow: 0 0 10px rgba(52, 211, 153, .6); }
.plan li.missed::before { background: var(--amber); border-color: var(--amber); }
.plan li.upcoming::before { background: var(--bg-2); border-color: var(--accent); }
.plan .time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; min-width: 76px; }
.plan .grow { flex: 1; }

/* --------------------------------------------------------------------------
 * Steps list / misc
 * -------------------------------------------------------------------------- */
.steps { margin: 10px 0 16px; padding-left: 20px; color: var(--muted); font-size: 13.5px; }
.steps li { margin: 6px 0; }
.spinner { display: inline-flex; align-items: center; gap: 7px; margin-left: 10px; color: var(--accent-ink); font-size: 13px; }
.spin-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.preview { margin-top: 16px; font-size: 14px; }
.preview strong { color: var(--accent-ink); }

.kv { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 14px; }
.kv strong { color: var(--ink); }

/* Auth pages get a centered brand mark */
.auth-mark {
  width: 54px; height: 54px; margin: 0 auto 16px;
  display: grid; place-items: center; border-radius: 15px;
  background: var(--grad); box-shadow: var(--shadow-glow); font-size: 26px;
}
.auth-title { text-align: center; }

/* --------------------------------------------------------------------------
 * Scrollbar
 * -------------------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .28); background-clip: padding-box; }

/* --------------------------------------------------------------------------
 * Accessibility
 * -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
