:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1f26;
  --muted: #6b7280;
  --primary: #2d6a4f;
  --primary-dark: #1b4332;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --success: #166534;
  --success-bg: #dcfce7;
  --warn-bg: #fef9c3;
  --warn-text: #854d0e;
  --border: #e5e7eb;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.wrap { width: 100%; max-width: 420px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.06);
}

h1 { margin: 0 0 20px; font-size: 22px; text-align: center; }

.brand-logo {
  height: 28px;
  width: auto;
  max-width: 140px;
  vertical-align: middle;
  margin-right: 8px;
  border-radius: 4px;
  object-fit: contain;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 16px 0 6px;
}

select, input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
}

select:focus, input:focus {
  outline: none;
  border-color: var(--primary);
}

.status-line {
  margin-top: 14px;
  font-size: 14px;
  color: var(--muted);
  min-height: 18px;
}

.btn-primary {
  width: 100%;
  margin-top: 20px;
  padding: 15px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { background: #cbd5e1; cursor: not-allowed; }
.btn-primary.clock-out { background: var(--danger); }
.btn-primary.clock-out:hover:not(:disabled) { background: #7f1d1d; }

.btn-install {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 11px;
  border: 1px dashed var(--primary);
  border-radius: 10px;
  background: #eef6f1;
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-install:hover { background: #e0efe6; }

.result {
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.5;
}
.result .msg { padding: 12px 14px; border-radius: 10px; }
.result .msg.success { background: var(--success-bg); color: var(--success); }
.result .msg.error { background: var(--danger-bg); color: var(--danger); }
.result .msg.warn { background: var(--warn-bg); color: var(--warn-text); }

.footnote {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 16px;
}

/* ---- Admin ---- */
.admin-shell { width: 100%; max-width: 1800px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 48px) 60px; }
.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.admin-header h1 { font-size: 20px; margin: 0; }
.tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
  padding: 9px 16px; border: 1px solid var(--border); background: #fff;
  border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted);
}
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.tab-dropdown { position: relative; display: inline-block; }
.tab-caret { font-size: 10px; margin-left: 2px; display: inline-block; transition: transform 0.15s; }
.tab-dropdown:hover .tab-caret { transform: rotate(180deg); }

.tab-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 6px;
  min-width: 180px;
  flex-direction: column;
  gap: 4px;
}
.tab-dropdown:hover .tab-dropdown-menu,
.tab-dropdown:focus-within .tab-dropdown-menu {
  display: flex;
}
.tab-dropdown-menu .tab-btn {
  width: 100%;
  text-align: left;
  border-radius: 8px;
  border-color: transparent;
  background: transparent;
}
.tab-dropdown-menu .tab-btn:hover { background: #f3f4f6; }
.tab-dropdown-menu .tab-btn.active { background: var(--primary); color: #fff; }

.panel { background: var(--card); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.panel h2 { margin-top: 0; font-size: 16px; }
.panel h3 { font-size: 14px; color: var(--muted); margin: 18px 0 8px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable .sort-arrow { opacity: 0.5; margin-left: 3px; font-size: 10px; }
tr.flagged { background: var(--warn-bg); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.stat-card {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.stat-card .stat-value { font-size: 24px; font-weight: 700; color: var(--primary-dark); }
.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.btn-sm {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 13px; margin-right: 6px;
}
.btn-sm.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-sm.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

.form-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.form-row label { margin: 0; white-space: nowrap; }
.form-row input, .form-row select { width: auto; flex: 1; min-width: 140px; }

.method-block {
  border: 1px dashed var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #fafafa;
}
.method-block .remove { float: right; color: var(--danger); cursor: pointer; font-size: 13px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ip { background: #dbeafe; color: #1e40af; }
.badge.gps { background: #ede9fe; color: #5b21b6; }
.badge.qr { background: #fce7f3; color: #9d174d; }
.badge.manual { background: #f3f4f6; color: #374151; }
.badge.pending { background: var(--warn-bg); color: var(--warn-text); }
.badge.approved { background: var(--success-bg); color: var(--success); }
.badge.denied { background: var(--danger-bg); color: var(--danger); }
.badge.none { background: #f3f4f6; color: var(--muted); }
.badge.pending { background: #fef9c3; color: #854d0e; }
.badge.approved { background: #dcfce7; color: #166534; }
.badge.denied { background: #fee2e2; color: #b91c1c; }
.badge.none { background: #f3f4f6; color: #6b7280; }

.qr-box { text-align: center; padding: 16px; }
.qr-box img { max-width: 260px; }

.login-box { max-width: 360px; margin: 80px auto; }

/* ---- Shifts ---- */
.role-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.role-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.role-legend-item { font-size: 13px; display: inline-flex; align-items: center; }

.shift-layout { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.shift-employee-panel { flex: 0 0 200px; min-width: 180px; }
.shift-grid-panel { flex: 1 1 500px; overflow-x: auto; }

.shift-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: grab;
  margin: 0 0 8px 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  text-shadow: 0 1px 1px rgba(0,0,0,0.25);
  width: fit-content;
}
.shift-chip:active { cursor: grabbing; }
.shift-chip.placed { margin: 0 4px 4px 0; }
.chip-remove { cursor: pointer; opacity: 0.8; font-size: 11px; }
.chip-remove:hover { opacity: 1; }

.shift-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.shift-table th, .shift-table td { border: 1px solid var(--border); vertical-align: top; padding: 6px; }
.shift-table th { background: #fafafa; font-size: 12px; text-transform: none; letter-spacing: normal; padding: 8px 6px; }
.shift-block-label { font-weight: 700; font-size: 13px; background: #fafafa; white-space: nowrap; }
.shift-cell { min-width: 110px; min-height: 60px; transition: background 0.1s; }
.shift-cell.drag-over { background: #eef6f1; }

/* ---- Files / feature publishing ---- */
.feature-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #fafafa;
}
.feature-card .feature-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.feature-card h3 { margin: 0; font-size: 15px; }
.feature-card p { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.feature-status { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.feature-status.live { background: var(--success-bg); color: var(--success); }
.feature-status.draft { background: var(--warn-bg); color: var(--warn-text); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: #fff; border-radius: var(--radius); padding: 24px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.modal-box h2 { margin-top: 0; font-size: 18px; }
.modal-box label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.modal-box input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; }
