:root {
  --bg: #0c0c0d;
  --surface: #17171a;
  --surface-2: #1f1f23;
  --surface-3: #29292e;
  --gold: #d4af37;
  --gold-bright: #e9c96b;
  --gold-dim: rgba(212, 175, 55, 0.18);
  --text: #f2f0ea;
  --text-muted: #9b9a97;
  --danger: #d97a5f;
  --ok: #6fbf8a;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(212, 175, 55, 0.07), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(212, 175, 55, 0.05), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, select, button {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.08);
}

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: var(--radius-md);
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 15px;
  font-weight: 600;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow-soft);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-gold {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #1a1508;
  border: none;
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.22), var(--shadow-soft);
}
.btn-gold:hover { filter: brightness(1.08); box-shadow: 0 6px 20px rgba(212, 175, 55, 0.32), var(--shadow-soft); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(217, 122, 95, 0.35);
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
}

.btn-block { width: 100%; }
.btn-lg { padding: 20px 28px; font-size: 18px; border-radius: var(--radius-lg); }

/* ---------------- Cards / surfaces ---------------- */

.card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px;
}

.panel {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 20px;
}

/* ---------------- Forms ---------------- */

.field {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.field:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }

input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

label.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: .02em;
}

/* ---------------- Branch select page ---------------- */

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.center-screen.branch-select-screen {
  position: relative;
  background:
    radial-gradient(700px 420px at 50% 0%, rgba(200, 30, 30, 0.12), transparent 65%),
    radial-gradient(600px 600px at 90% 100%, rgba(212, 175, 55, 0.08), transparent 60%),
    linear-gradient(160deg, #1c1210 0%, #120d0c 55%, #0c0c0d 100%);
  overflow: hidden;
}
.center-screen.branch-select-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cg stroke='%23c9a24b' stroke-width='0.75' fill='none' opacity='0.09'%3E%3Crect x='30' y='30' width='60' height='60' transform='rotate(45 60 60)'/%3E%3Crect x='30' y='30' width='60' height='60'/%3E%3Ccircle cx='60' cy='60' r='6'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}
.branch-select-content {
  width: 100%;
  min-width: 0;
  max-width: clamp(380px, 40vw, 860px);
}

.brand-flame {
  display: block;
  width: clamp(56px, 9vw, 160px);
  height: clamp(56px, 9vw, 160px);
  margin: 0 auto 4px;
  filter: drop-shadow(0 4px 10px rgba(200, 30, 30, 0.35));
  position: relative;
}

.brand-sub {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: clamp(32px, 4vw, 64px);
  font-size: clamp(14px, 1.6vw, 24px);
  letter-spacing: .04em;
  text-transform: uppercase;
  position: relative;
}

.branch-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(16px, 2vw, 32px);
  width: 100%;
  max-width: clamp(380px, 40vw, 860px);
}

.branch-card {
  --accent: var(--gold);
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-lg);
  padding: clamp(22px, 2vw, 34px) clamp(24px, 2.2vw, 38px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  width: 100%;
  transition: border-color .15s ease, transform .12s ease, box-shadow .15s ease;
  color: var(--text);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px);
  animation: cardIn .5s ease forwards;
}
.branch-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent);
  opacity: .7;
  transition: opacity .15s ease, width .15s ease;
}
.branch-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 20%, transparent), var(--shadow-soft); }
.branch-card:hover::before { opacity: 1; width: 5px; }
.branch-card .name-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.branch-card .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-card .pin-icon { color: var(--accent); opacity: .9; flex-shrink: 0; width: clamp(18px, 1.6vw, 28px); height: clamp(18px, 1.6vw, 28px); }
.branch-card .name { font-size: clamp(18px, 1.8vw, 28px); font-weight: 600; color: #ffffff; }
.branch-card .go { color: var(--accent); font-size: clamp(22px, 2vw, 32px); transition: transform .15s ease; }
.branch-card:hover .go { transform: translateX(3px); }

@keyframes cardIn {
  to { opacity: 1; transform: translateY(0); }
}

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

.app-shell {
  display: flex;
  min-height: 100vh;
}

.side-menu {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
}

.side-menu .branch-name {
  font-size: 15px;
  color: var(--text-muted);
  padding: 0 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 14px;
  position: relative;
}
.side-menu .branch-name::before {
  content: "";
  position: absolute;
  left: 0; top: -2px;
  width: 28px; height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--gold-bright), var(--gold));
}
.side-menu .branch-name strong { color: var(--gold-bright); display: block; font-size: 19px; letter-spacing: .01em; }

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  color: var(--text);
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.menu-item:hover { background: var(--surface-2); transform: translateX(2px); }
.menu-item.active {
  background: linear-gradient(180deg, rgba(212,175,55,0.16), rgba(212,175,55,0.08));
  border-color: var(--gold-dim);
  color: var(--gold-bright);
  box-shadow: inset 0 0 0 1px rgba(212,175,55,0.12);
}
.menu-item.locked { color: var(--text-muted); }
.menu-item .lock-icon { opacity: .7; }
.menu-label { display: flex; align-items: center; gap: 10px; }
.menu-icon { font-size: 15px; opacity: .9; }

.menu-spacer { flex: 1; }

.lock-btn {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.lock-btn:hover { background: rgba(217,122,95,0.08); }

.update-info-btn {
  width: 100%;
  padding: 8px 12px;
  margin-top: 8px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}
.update-info-btn:hover { border-color: var(--gold-dim); color: var(--gold-bright); }

.timer-line {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 14px 0;
}

.main-area {
  flex: 1;
  padding: 32px 40px;
  max-width: 1100px;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}

.view-title { font-size: 24px; font-weight: 700; letter-spacing: .01em; }
.date-badge {
  background: var(--surface-2);
  color: var(--gold);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
}

/* ---------------- Today board controls ---------------- */

.clock-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  max-width: 420px;
  margin-bottom: 28px;
}

.clock-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ---------------- Tables ---------------- */

table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
}
table.data-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: 12px 16px;
  background: var(--surface-2);
}
table.data-table td {
  padding: 13px 16px;
  background: var(--surface);
  border-top: 1px solid rgba(255,255,255,0.04);
  font-size: 14px;
}
table.data-table tr:nth-child(even) td { background: var(--surface-2); }
table.data-table .incomplete { color: var(--danger); font-weight: 600; }
table.data-table .row-actions { display: flex; gap: 8px; }

.week-block { margin-bottom: 26px; }
.week-header {
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 10px;
  font-size: 15px;
  padding-left: 10px;
  border-left: 3px solid var(--gold-dim);
}
.week-total-row td { background: var(--gold-dim) !important; font-weight: 700; color: var(--gold-bright); }
.week-total-row td:last-child,
.week-total-row td:nth-last-child(2) { color: var(--gold-bright); }

/* ---------------- View toolbar / filters ---------------- */

.view-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar { position: relative; }

.filter-toggle.active {
  border-color: var(--gold-dim);
  color: var(--gold-bright);
}

.filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 16px;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.filter-actions { display: flex; gap: 10px; margin-top: 2px; }
.filter-actions .btn { flex: 1; padding: 10px 14px; font-size: 13px; }

/* ---------------- Rollover warning banner ---------------- */

.rollover-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, rgba(217,122,95,0.16), rgba(217,122,95,0.06));
  border: 1px solid rgba(217,122,95,0.35);
  color: var(--danger);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
.rollover-banner:hover { background: rgba(217,122,95,0.14); }
.rollover-caret { opacity: .8; }

.rollover-details {
  background: var(--surface-2);
  border: 1px solid rgba(217,122,95,0.2);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-top: -10px;
  margin-bottom: 18px;
  font-size: 14px;
}
.rollover-row { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.rollover-row:last-child { border-bottom: none; }

/* ---------------- Modal / overlay ---------------- */

.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}
.modal h3 { margin-top: 0; }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-3);
  border: 1px solid var(--gold-dim);
  color: var(--text);
  padding: 14px 22px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
  font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { border-color: var(--danger); color: var(--danger); }

.hidden { display: none !important; }

.empty-state {
  color: var(--text-muted);
  padding: 30px;
  text-align: center;
  background: var(--surface-2);
  border-radius: var(--radius-md);
}

.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 16px; }

@media (max-width: 800px) {
  .app-shell { flex-direction: column; }
  .side-menu { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 14px; }
  .side-menu .branch-name { display: none; }
  .menu-item { width: auto; flex: 1 1 auto; }
  .menu-spacer { display: none; }
  .lock-btn { order: 99; margin-top: 8px; }
  .main-area { padding: 20px; }
  .clock-btn-row { grid-template-columns: 1fr; }
  .filter-panel { width: calc(100vw - 72px); left: 0; }
}
