:root {
  --bg: #0b0b0f;
  --bg-panel: #131318;
  --bg-input: #0e0e13;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f4f6;
  --muted: #9a9aa6;
  --faint: #6a6a78;
  --accent: #ed2027;
  --accent-2: #ff3b45;
  --accent-pink: #c8141b;
  --danger: #f87171;
  --success: #34d399;
  --radius: 12px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* امضای Railway: گرید نقطه‌ای + درخشش بنفش بالا */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
}
body::after {
  content: "";
  position: fixed;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 70vmax;
  height: 50vmax;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle, rgba(237, 32, 39, 0.20), rgba(255, 59, 69, 0.07) 40%, transparent 70%);
  filter: blur(20px);
}

/* کارت */
.card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 392px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 24px 60px -24px rgba(0, 0, 0, 0.8);
  padding: 34px 30px 28px;
}

.logo {
  display: block;
  height: 46px;
  width: auto;
  margin: 2px 0 26px;
}
.welcome .logo { margin: 0 auto 20px; height: 40px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 7px;
}
.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 26px;
  line-height: 1.65;
}

.field { margin-bottom: 15px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.field input::placeholder { color: var(--faint); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(237, 32, 39, 0.18);
}

.btn {
  width: 100%;
  padding: 12px;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 9px;
  cursor: pointer;
  margin-top: 8px;
  transition: filter 0.16s, transform 0.1s, opacity 0.16s;
  box-shadow: 0 8px 24px -10px var(--accent);
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-ghost {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
.btn-ghost:hover { filter: none; background: rgba(255, 255, 255, 0.05); }

.alt {
  margin-top: 22px;
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
}
.alt a { color: var(--text); text-decoration: none; font-weight: 600; border-bottom: 1px solid var(--accent); padding-bottom: 1px; }
.alt a:hover { color: var(--accent); }

/* پیام‌ها */
.msg {
  display: none;
  font-size: 13px;
  padding: 10px 13px;
  border-radius: 9px;
  margin-bottom: 18px;
  line-height: 1.55;
}
.msg.show { display: block; }
.msg.error   { background: rgba(248, 113, 113, 0.1); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.28); }
.msg.success { background: rgba(52, 211, 153, 0.1); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.28); }

/* صفحه خوش‌آمد */
.welcome { text-align: center; }
.welcome .check {
  width: 68px; height: 68px;
  margin: 0 auto 22px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-pink));
  display: grid; place-items: center;
  box-shadow: 0 16px 40px -12px var(--accent);
  animation: pop 0.45s cubic-bezier(.2,.9,.3,1.3);
}
.welcome .check svg { width: 32px; height: 32px; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.welcome .uname { font-family: var(--mono); color: var(--accent); font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  .welcome .check { animation: none; }
}

/* ===================== Dashboard ===================== */
.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}
body.dash { display: block; padding: 0; place-items: initial; overflow: auto; }

.topbar {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(11,11,15,0.7);
  backdrop-filter: blur(10px);
  position: sticky; top: 0;
}
.topbar .logo { height: 30px; margin: 0; }
.topbar .who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.topbar .who b { color: var(--text); font-weight: 600; }
.btn-mini {
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  color: var(--text); background: var(--bg-input);
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 7px 12px; cursor: pointer;
}
.btn-mini:hover { background: rgba(255,255,255,0.06); }

.wrap { padding: 22px 18px 60px; }
.head { margin-bottom: 18px; }
.head h1 { font-size: 22px; margin-bottom: 4px; }
.head .date { font-family: var(--mono); font-size: 12.5px; color: var(--accent); letter-spacing: 0.4px; }

/* فرم تنظیم نام */
.namecard {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 22px;
}
.namecard h2 { font-size: 16px; margin-bottom: 6px; }
.namecard p { color: var(--muted); font-size: 13.5px; margin-bottom: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px){ .row2 { grid-template-columns: 1fr; } }

/* لیست کارگرها */
.roster { display: flex; flex-direction: column; gap: 10px; }
.worker {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
}
.worker .name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.worker.me .name::after { content: "You"; font-family: var(--mono); font-size: 10px; color: var(--accent); border: 1px solid var(--accent); border-radius: 5px; padding: 1px 5px; }
.status { display: flex; gap: 18px; margin-top: 10px; flex-wrap: wrap; }
.stat { font-size: 12.5px; color: var(--muted); }
.stat .lbl { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); margin-bottom: 3px; }
.stat .val { color: var(--text); }
.stat.done .val { color: var(--success); }
.stat .tick { color: var(--success); font-weight: 700; }
.stat .loc { color: var(--muted); font-size: 11.5px; }
.pending { color: var(--faint); }

.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions .btn { margin-top: 0; padding: 10px; font-size: 13.5px; }
.actions .btn.out { background: var(--bg-input); color: var(--text); border: 1px solid var(--border-strong); box-shadow: none; }
.actions .btn.out:hover { background: rgba(255,255,255,0.06); filter: none; }

/* ===================== Modal ===================== */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 18px;
}
.overlay.show { display: flex; }
.modal {
  width: 100%; max-width: 440px; max-height: 88vh; overflow: auto;
  background: var(--bg-panel); border: 1px solid var(--border-strong);
  border-radius: 16px; padding: 24px;
  box-shadow: 0 30px 70px -20px rgba(0,0,0,0.8);
}
.modal h2 { font-size: 18px; margin-bottom: 4px; }
.modal .eyebrow { margin-bottom: 14px; }
.brief {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 16px;
  font-size: 13.5px; line-height: 1.7; color: var(--muted);
}
.brief ul { margin: 8px 0 0; padding-inline-start: 18px; }
.brief li { margin-bottom: 6px; }
.brief strong { color: var(--text); }
.ack { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--text); margin-bottom: 16px; cursor: pointer; }
.ack input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); flex: 0 0 auto; }
.modal .actions { margin-top: 4px; }

/* ===================== Dashboard ===================== */
.card.board { max-width: 760px; text-align: left; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 4px; }
.board-head .logo { margin: 0; height: 40px; }
.board-head .who { font-size: 12.5px; color: var(--muted); text-align: right; }
.board-head .who b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.board-head .who a { color: var(--accent); cursor: pointer; text-decoration: none; }
.board-head .who a:hover { text-decoration: underline; }

.board-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 18px 0 4px; }
.board-title h1 { font-size: 21px; margin: 0; }
.board-title .today { font-family: var(--mono); font-size: 12px; color: var(--accent); letter-spacing: .4px; white-space: nowrap; }
.board .subtitle { margin-bottom: 18px; }

.addrow { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.addrow input {
  flex: 1; min-width: 120px; padding: 10px 12px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  font-family: var(--sans); font-size: 14px;
}
.addrow input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(237,32,39,.18); }
.addrow .btn { width: auto; margin-top: 0; padding: 10px 16px; }

.table-wrap { overflow-x: auto; }
table.workers { width: 100%; border-collapse: collapse; min-width: 620px; }
table.workers th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
table.workers td { padding: 12px 10px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
table.workers tr:last-child td { border-bottom: none; }
.w-name { font-weight: 600; }
.w-idx { color: var(--faint); font-family: var(--mono); font-size: 12px; margin-right: 10px; }
.w-loc { display: block; font-size: 11.5px; color: var(--faint); font-family: var(--mono); margin-top: 2px; }
.cell-loc { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.cell-loc.empty { color: var(--faint); }
.ts-cell { display: flex; align-items: center; gap: 8px; }
.ts { display: flex; flex-direction: column; line-height: 1.25; }
.ts b { font-size: 13px; font-weight: 600; color: var(--text); }
.ts span { font-size: 10.5px; color: var(--faint); font-family: var(--mono); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  border-radius: 999px; font-size: 12.5px; font-family: var(--mono); white-space: nowrap;
}
.pill.done { background: rgba(52,211,153,.12); color: var(--success); border: 1px solid rgba(52,211,153,.3); }
.pill.wait { color: var(--faint); }
.btn.tiny { width: auto; margin-top: 0; padding: 7px 13px; font-size: 12.5px; }
.btn.tiny.ghost { background: var(--bg-input); color: var(--text); border: 1px solid var(--border-strong); box-shadow: none; }
.btn.tiny:disabled { opacity: .4; }
.del-btn { background: none; border: none; color: var(--faint); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.del-btn:hover { color: var(--danger); background: rgba(248,113,113,.1); }
.empty { text-align: center; color: var(--muted); padding: 28px 0; font-size: 14px; }

/* ===================== Modal ===================== */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.62);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: none; place-items: center; padding: 20px;
}
.overlay.show { display: grid; }
.modal {
  width: 100%; max-width: 470px; background: var(--bg-panel);
  border: 1px solid var(--border-strong); border-radius: 14px; padding: 24px;
  box-shadow: 0 30px 70px -20px #000; max-height: 90dvh; overflow: auto;
}
.modal .eyebrow { margin-bottom: 8px; }
.modal h2 { font-size: 19px; margin-bottom: 6px; }
.modal .lead { color: var(--muted); font-size: 13px; margin-bottom: 16px; line-height: 1.6; }
.modal ul { list-style: none; margin: 0 0 14px; padding: 0; }
.modal li { position: relative; padding: 9px 0 9px 24px; font-size: 13px; color: var(--text); line-height: 1.5; border-bottom: 1px solid var(--border); }
.modal li:last-child { border-bottom: none; }
.modal li::before { content: ""; position: absolute; left: 3px; top: 14px; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); }
.modal .field { margin: 4px 0 12px; }
.ack { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 18px; font-size: 13px; color: var(--text); cursor: pointer; line-height: 1.5; }
.ack input { margin-top: 1px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { margin-top: 0; }

/* ===== Date navigation ===== */
.datenav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.datenav input[type="date"] {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: var(--mono); font-size: 13px; padding: 7px 10px;
  color-scheme: dark;
}
.datenav input[type="date"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(237,32,39,.18); }
.archive-note {
  background: rgba(237,32,39,.08); color: var(--accent-2); border: 1px solid rgba(237,32,39,.25);
  border-radius: 9px; padding: 9px 13px; font-size: 13px; margin-bottom: 16px; font-family: var(--mono);
}

/* ===================== Auth pages (sign in / register) ===================== */
body.auth-page { display: block; place-items: initial; padding: 0; overflow-y: auto; }
.auth-shell { position: relative; z-index: 1; min-height: 100dvh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-visual { position: relative; overflow: hidden; display: block; }
.auth-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.auth-visual .grad { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,11,15,.25) 0%, rgba(11,11,15,.55) 55%, rgba(11,11,15,.96) 100%); }
.auth-visual .copy { position: absolute; left: 44px; right: 44px; bottom: 44px; z-index: 2; }
.auth-visual .copy .eyebrow { color: var(--accent-2); }
.auth-visual .copy h2 { font-size: 26px; font-weight: 700; letter-spacing: -.5px; margin-bottom: 10px; line-height: 1.2; }
.auth-visual .copy p { color: var(--muted); font-size: 13.5px; line-height: 1.6; max-width: 380px; }
.auth-formside { display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-formside .inner { width: 100%; max-width: 392px; }
@media (max-width: 900px) { .auth-shell { grid-template-columns: 1fr; } .auth-visual { display: none; } }

.brand-link { display: inline-flex; text-decoration: none; }
.brand-link:hover .logo { opacity: .85; }
.logo { transition: opacity .15s; }

/* رمز عبور با دکمه چشم */
.pwfield { position: relative; }
.pwfield input { padding-right: 42px; }
.pw-eye {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 30px; height: 30px; display: grid; place-items: center;
  background: none; border: none; color: var(--faint); cursor: pointer; border-radius: 6px;
}
.pw-eye:hover { color: var(--text); background: rgba(255,255,255,.06); }

.capswarn {
  display: none; align-items: center; gap: 6px; font-size: 12px; color: var(--accent-2);
  margin-top: 7px; font-family: var(--mono);
}
.capswarn.show { display: flex; }

.msg.warn { background: rgba(255, 176, 32, .1); color: #ffb020; border: 1px solid rgba(255, 176, 32, .3); }

.security-line {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 11.5px; color: var(--faint); margin-top: 18px; font-family: var(--mono);
}

.auth-footer {
  margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; font-size: 12px; color: var(--faint);
}
.auth-footer a { color: var(--faint); text-decoration: none; }
.auth-footer a:hover { color: var(--muted); }
.auth-footer .sep { opacity: .5; }

/* بنر نصب PWA روی موبایل */
.install-banner {
  display: none; position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 40;
  align-items: center; gap: 12px;
  background: var(--bg-panel); border: 1px solid var(--border-strong); border-radius: 14px;
  padding: 13px 14px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.8);
}
.install-banner.show { display: flex; }
.install-banner .ib-ico {
  width: 36px; height: 36px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; box-shadow: 0 8px 20px -8px var(--accent);
}
.install-banner .ib-text { flex: 1; min-width: 0; }
.install-banner .ib-text b { display: block; font-size: 13px; }
.install-banner .ib-text span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.install-banner .ib-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.install-banner .btn-mini.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none;
}
.install-banner .ib-close {
  background: none; border: none; color: var(--faint); cursor: pointer; font-size: 18px;
  width: 26px; height: 26px; border-radius: 6px; line-height: 1;
}
.install-banner .ib-close:hover { color: var(--text); background: rgba(255,255,255,.06); }
@media (min-width: 640px) { .install-banner { left: auto; right: 20px; bottom: 20px; max-width: 360px; } }
