:root {
  --ink: #1a1a1a;
  --bg: #f5f5f5;
  --white: #ffffff;
  --border: #dbdbdb;
  --danger: #c0392b;
  --gold: #a9842c;
  --gold-soft: #f6efdf;
}

* { box-sizing: border-box; }

html, body {
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: var(--ink); }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 220px;
  background: var(--ink);
  color: var(--white);
  overflow-y: auto;
  padding: 20px 0;
}

.sidebar .brand {
  text-align: center;
  padding: 0 16px 16px;
}

.sidebar .brand-logo {
  max-width: 150px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto 8px;
}

.sidebar .brand-title {
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 13px;
  opacity: 0.85;
}

.sidebar .user-info {
  padding: 0 20px 16px;
  font-size: 12.5px;
  opacity: 0.75;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  margin-bottom: 8px;
}

.sidebar nav a {
  display: block;
  padding: 10px 20px;
  color: var(--white);
  text-decoration: none;
  font-size: 14px;
  opacity: 0.9;
}

.sidebar nav a:hover { background: rgba(255, 255, 255, 0.08); opacity: 1; }
.sidebar nav a.active { background: rgba(255, 255, 255, 0.14); opacity: 1; font-weight: 600; }

.sidebar .nav-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  font-size: 14px;
  opacity: 0.9;
  cursor: pointer;
  user-select: none;
}
.sidebar .nav-group-title:hover { background: rgba(255, 255, 255, 0.08); }

.sidebar .nav-caret { transition: transform 0.15s ease; font-size: 11px; }
.sidebar .nav-caret.open { transform: rotate(180deg); }

.sidebar .nav-subitems { display: none; }
.sidebar .nav-subitems.open { display: block; }
.sidebar .nav-subitems a { padding-left: 36px; font-size: 13.5px; }

body.with-sidebar { margin-left: 220px; }

@media (max-width: 720px) {
  .sidebar { position: static; width: 100%; }
  body.with-sidebar { margin-left: 0; }
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
}

h1, h2, h3 { margin-top: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
}

th { color: #555; font-weight: 600; font-size: 13px; }

td.num, th.num { text-align: center; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-block;
  background: var(--ink);
  color: var(--white);
  border: none;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn.secondary {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn.danger { background: var(--danger); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #444;
}

input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

textarea { resize: vertical; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px;
  width: 320px;
}

.error { color: var(--danger); font-size: 13px; margin-bottom: 10px; }

.item-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
  position: relative;
}

.item-row .remove-item {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 999px;
  width: 26px;
  height: 26px;
  cursor: pointer;
}

.item-row .form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.item-row .form-row-4 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.thumb {
  max-width: 80px;
  max-height: 80px;
  border-radius: 4px;
  border: 1px solid var(--border);
  display: block;
  margin-top: 6px;
  cursor: zoom-in;
}

.stage-tracker {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  padding: 8px 0;
}

.stage-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
  text-align: center;
}

.stage-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #999;
}

.stage-step.done .stage-dot {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}

.stage-step.current .stage-dot {
  border-color: var(--ink);
  color: var(--ink);
}

.stage-label {
  font-size: 13px;
  font-weight: 600;
  margin-top: 6px;
}

.stage-step.done .stage-label,
.stage-step.current .stage-label {
  color: var(--ink);
}

.stage-step:not(.done):not(.current) .stage-label {
  color: #999;
}

.stage-date {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
  min-height: 14px;
}

.stage-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin-top: 15px;
  min-width: 20px;
}

.stage-line.done {
  background: var(--ink);
}

.picker-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.picker-box {
  background: var(--white);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 900px;
  max-height: 80vh;
  overflow-y: auto;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.picker-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.picker-card:hover { border-color: var(--ink); }

.picker-card img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 4px;
}

.picker-card-noimg {
  width: 100%;
  height: 110px;
  background: var(--bg);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 12px;
}

.picker-card-name {
  font-weight: 600;
  font-size: 13px;
  margin: 8px 0 2px;
}

.picker-card-vendor {
  font-size: 11px;
  color: #666;
  margin: 0;
}

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.pdf-frame {
  width: 100%;
  height: 80vh;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* --- 打卡時鐘卡片 --- */
.clock-card {
  text-align: center;
  padding: 28px 24px 24px;
}
.clock-card .clock-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  margin-bottom: 18px;
}
.clock-card .clock-date {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #888;
}
.clock-card .clock-radius {
  font-size: 11px;
  color: #999;
}
.clock-live {
  font-family: "SF Mono", "JetBrains Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 56px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.clock-punches {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 14px 0 20px;
}
.clock-punches .p {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.clock-punches .p .lab {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #999;
}
.clock-punches .p .val {
  font-family: "SF Mono", "JetBrains Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.clock-punches .p .val.pending { color: #bbb; font-weight: 500; }
.clock-actions { display: flex; gap: 10px; }
.clock-actions form { flex: 1; }
.clock-actions .btn { width: 100%; padding: 13px 18px; font-size: 15px; }
.clock-verified {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
}

/* --- 自訂確認視窗 --- */
.kcasa-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.kcasa-modal {
  background: var(--white);
  border-radius: 14px;
  padding: 24px 22px 20px;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.kcasa-modal-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.kcasa-modal-msg {
  font-size: 16px;
  color: var(--ink);
  line-height: 1.5;
  margin-bottom: 20px;
}
.kcasa-modal-actions {
  display: flex;
  gap: 10px;
}
.kcasa-modal-actions .btn {
  flex: 1;
  padding: 11px 16px;
}
