/* === Tini Time Tracker — webapp (réplica del look de la app Android) === */
:root {
  --accent: #4F46E5;
  --accent-700: #4338CA;
  --accent-50: #EEF0FE;
  --accent-100: #E0E4FF;

  --positive: #30A46C;
  --warning: #D98A0B;
  --negative: #E5484D;

  --bg: #F4F6F9;
  --bg-dim: #EAEDF2;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --ink1: #15181E;
  --ink2: #353A45;
  --ink3: #5A6171;
  --ink4: #9AA1AC;
  --line: #E3E6EB;
  --line-strong: #D2D6DD;

  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
  --shadow-lg: 0 8px 30px rgba(16,24,40,.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1216;
    --bg-dim: #1A1F26;
    --surface: #181C22;
    --surface-2: #20252D;
    --ink1: #F2F4F8;
    --ink2: #C8CDD6;
    --ink3: #969DAA;
    --ink4: #6B7280;
    --line: #2B313A;
    --line-strong: #2B313A;
    --accent-50: #20223A;
    --accent-100: #2A2E54;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.35);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink1);
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { font-size: 18px; font-weight: 700; white-space: nowrap; }
.brand .brand-sub { color: var(--ink4); font-size: 14px; white-space: nowrap; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
.topbar-actions { display: flex; gap: 10px; }

/* ---- Layout ---- */
.screen { padding: 22px; max-width: 1180px; margin: 0 auto; }
.screen-head { margin-bottom: 18px; }
.screen-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -.3px; margin: 0 0 4px; }
.screen-head p { color: var(--ink3); margin: 0; font-size: 16px; }

/* ---- Buttons ---- */
.btn {
  appearance: none; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink1); font-family: var(--font); font-size: 16px; font-weight: 600;
  padding: 11px 18px; border-radius: 12px; cursor: pointer; display: inline-flex;
  align-items: center; gap: 8px; transition: transform .04s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-ghost { background: var(--surface); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-700); border-color: var(--accent-700); }
.btn-warning { color: var(--warning); border-color: var(--line-strong); }
.btn-lg { font-size: 19px; padding: 16px 26px; border-radius: 14px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Worker grid (login) ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.worker-card {
  display: flex; align-items: center; gap: 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  cursor: pointer; box-shadow: var(--shadow); text-align: left;
  transition: transform .05s ease, border-color .15s ease, box-shadow .15s ease;
}
.worker-card:hover { border-color: var(--accent-100); box-shadow: var(--shadow-lg); }
.worker-card:active { transform: scale(.985); }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px;
}
.worker-card .name { font-weight: 700; font-size: 17px; color: var(--ink1); line-height: 1.2; }
.worker-card .sub { font-size: 13px; color: var(--ink4); text-transform: uppercase; letter-spacing: .3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Selection cards (project / group / operation) ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.select-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; cursor: pointer; box-shadow: var(--shadow); font-size: 20px; font-weight: 700;
  color: var(--ink1); text-align: left; min-height: 84px; display: flex; align-items: center;
  transition: transform .05s ease, border-color .15s ease, box-shadow .15s ease;
}
.select-card:hover { border-color: var(--accent-100); box-shadow: var(--shadow-lg); }
.select-card:active { transform: scale(.99); }
.select-card.selected { border: 2px solid var(--accent); background: var(--accent-50); color: var(--accent); }

/* ---- Breadcrumb ---- */
.crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.crumb { padding: 8px 16px; border-radius: 999px; background: var(--bg-dim); color: var(--ink3);
  font-weight: 600; font-size: 15px; }
.crumb.active { background: var(--accent); color: #fff; }
.crumb.done { background: var(--accent-50); color: var(--accent); }
.crumb-sep { color: var(--ink4); }

/* ---- Running session ---- */
.run-wrap { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
@media (max-width: 820px) { .run-wrap { grid-template-columns: 1fr; } }
.run-card { background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 26px; }
.run-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.run-title { font-size: 24px; font-weight: 700; }
.run-op { color: var(--ink3); text-transform: uppercase; font-size: 14px; letter-spacing: .4px; margin-top: 2px; }
.badge { background: var(--accent-50); color: var(--accent); font-weight: 700; font-size: 14px;
  padding: 6px 14px; border-radius: 999px; white-space: nowrap; }
.badge.extra { background: #FBEFD6; color: var(--warning); }
.timer { text-align: center; padding: 48px 0 26px; }
.timer .clock { font-family: var(--mono); font-size: clamp(56px, 12vw, 104px); font-weight: 700;
  letter-spacing: -2px; line-height: 1; }
.timer .since { color: var(--ink3); margin-top: 10px; font-size: 16px; }
.run-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; }
.side-card h3 { margin: 0 0 14px; font-size: 19px; font-weight: 700; }
.info-line { display: flex; justify-content: space-between; padding: 7px 0; color: var(--ink2); font-size: 16px; }
.info-line .v { font-variant-numeric: tabular-nums; color: var(--ink1); font-weight: 600; }

/* ---- Footer summary (operation step) ---- */
.footer-bar { position: sticky; bottom: 0; margin-top: 18px; display: flex; align-items: center;
  justify-content: space-between; gap: 16px; background: var(--accent-50); border: 1px solid var(--accent-100);
  border-radius: var(--radius); padding: 16px 20px; }
.footer-bar .sum-title { font-weight: 700; font-size: 18px; }
.footer-bar .sum-sub { color: var(--ink3); font-size: 14px; text-transform: uppercase; letter-spacing: .3px; }

/* ---- Empty home ---- */
.empty { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 48px 28px; text-align: center; max-width: 560px; margin: 24px auto; }
.empty .emoji { font-size: 44px; }
.empty h2 { margin: 12px 0 6px; font-size: 24px; }
.empty p { color: var(--ink3); margin: 0 0 24px; }

/* ---- PIN modal ---- */
.overlay { position: fixed; inset: 0; background: rgba(15,18,22,.45); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 360px; max-width: 100%; padding: 22px; }
.modal .modal-top { display: flex; justify-content: flex-start; }
.modal .who { text-align: center; margin: 6px 0 4px; }
.modal .who .avatar { margin: 0 auto 10px; width: 56px; height: 56px; }
.modal .who .name { font-weight: 700; font-size: 20px; }
.modal .who .hint { color: var(--ink3); font-size: 14px; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 16px 0 18px; }
.pin-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--line-strong); transition: background .1s; }
.pin-dot.filled { background: var(--accent); }
.pin-dot.error { background: var(--negative); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pad button { font-family: var(--font); font-size: 26px; font-weight: 600; padding: 16px 0;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink1);
  cursor: pointer; transition: transform .04s ease, background .15s; }
.pad button:active { transform: scale(.96); background: var(--bg-dim); }
.pad .key-back { background: var(--surface-2); }

/* ---- Misc ---- */
.loading { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 80px 0; color: var(--ink3); }
.spinner { width: 38px; height: 38px; border: 4px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 80;
  background: var(--ink1); color: #fff; padding: 13px 20px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: 15px; max-width: 90%; }
.toast.error { background: var(--negative); }
.toast.success { background: var(--positive); }
.error-banner { background: #FCE7E7; color: #B42318; border: 1px solid #F3C0C0; border-radius: 12px;
  padding: 14px 18px; margin: 16px auto; max-width: 560px; text-align: center; }
