:root {
  --bg: #f5efe0;
  --card: #fffdf7;
  --ink: #1a1a1a;
  --sub: #8c8074;
  --line: #e6dcc6;
  --brand: #c8102e;
  --brand2: #a30d25;
  --on: #c8102e;
  --on-bg: #fbe6e9;
  --off: #b3a896;
  --danger: #c8102e;
  --accent: #f4c430;
  --paper: #fffdf7;
  --good: #3f7a2e;
  --warn: #9a6b00;
  --shadow: 0 1px 2px rgba(80, 50, 20, .05), 0 10px 26px rgba(120, 80, 30, .07);
}

html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body,
button,
input,
select,
textarea {
  font-family: Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: block;
  padding: 0;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar .bar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar .logo {
  display: flex;
  align-items: center;
  gap: 9px;
}

.topbar .logo strong {
  color: var(--ink);
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -.01em;
}

.store-tag,
.badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 20px;
  background: var(--on-bg);
  color: var(--brand);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.role-tag {
  background: var(--ink);
  color: #fff;
}

.sync {
  margin-left: 4px;
  color: var(--sub);
  font-size: 11px;
  white-space: nowrap;
}

.clock {
  margin-left: auto;
  text-align: right;
  line-height: 1.15;
  white-space: nowrap;
}

.clock .t {
  font-size: 23px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.clock .d {
  color: var(--sub);
  font-size: 12px;
}

.lockbtn,
.ghost,
.icon,
.kiosk-button {
  padding: 8px 11px;
  border: 0;
  border-radius: 10px;
  background: #efe6d3;
  color: var(--sub);
  font-size: 13px;
  font-weight: 700;
}

#adminNav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 12px 10px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

#adminNav button {
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--sub);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

#adminNav button.active {
  background: var(--brand);
  color: #fff;
}

.kiosk-mode #adminNav,
.kiosk-mode .role-tag {
  display: none;
}

.workspace {
  display: block;
  min-height: 0;
}

.sidebar {
  display: none;
}

.content,
.page,
.app-main {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px;
}

.panel {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-head > div:first-child {
  flex: 1;
}

.section-head h1 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}

.primary,
.btn {
  padding: 11px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.primary:hover,
.btn:hover {
  background: var(--brand2);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.clock-section {
  margin-bottom: 22px;
}

.clock-section-head {
  margin: 0 2px 12px;
  padding-bottom: 9px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  border-bottom: 2px solid var(--line);
}

.clock-section-head .name {
  font-size: 19px;
  font-weight: 900;
}

.clock-section-head .count {
  color: var(--sub);
  font-size: 13px;
  font-weight: 700;
}

.clock-section-head .count b {
  color: var(--brand);
  font-size: 15px;
}

.employee-cards,
.clock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 16px;
  align-content: start;
}

.employee-card,
.clock-card {
  position: relative;
  padding: 22px 16px;
  text-align: center;
  user-select: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  transition: transform .08s, box-shadow .15s;
}

.employee-card:active,
.clock-card:active {
  transform: scale(.97);
}

.employee-card.working,
.clock-card.working {
  border-color: var(--on);
  box-shadow: 0 0 0 2px rgba(200, 16, 46, .15), var(--shadow);
}

.employee-card .avatar,
.clock-card .avatar {
  width: 84px;
  height: 84px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;
  background: #f3ebd9;
  color: var(--brand);
  font-size: 32px;
  font-weight: 800;
}

.employee-card h3,
.clock-card .name {
  margin: 0;
  color: var(--ink);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.3px;
}

.employee-card p,
.clock-card .type {
  margin: 3px 0 0;
  color: var(--sub);
  font-size: 13px;
}

.employee-card [data-clock],
.clock-card .clock-status {
  width: 100%;
  margin-top: 14px;
  padding: 11px 0;
  border-radius: 11px;
  background: #efe6d3;
  color: var(--off);
  font-size: 16px;
  font-weight: 800;
}

.employee-card.working [data-clock],
.clock-card.working .clock-status {
  background: var(--on-bg);
  color: var(--on);
}

.employee-card [data-clock] small {
  display: block;
  margin-top: 1px;
  font-size: 12px;
  font-weight: 600;
}

.clock-status small {
  display: block;
  margin-top: 1px;
  font-size: 12px;
  font-weight: 600;
  opacity: .8;
}

.employee-card [data-history],
.clock-card .history-button {
  width: 100%;
  margin-top: 9px;
  padding: 7px 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}

.hero {
  display: none;
}

.center {
  margin-top: 22px;
  text-align: center;
}

.summary-grid,
.summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.summary-grid .summary,
.summary > .stat,
.summary-grid > div {
  min-width: 120px;
  flex: 1;
  margin: 0;
  padding: 14px 18px;
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.summary-grid .summary span {
  display: block;
  color: var(--sub);
  font-size: 12px;
  font-weight: 600;
}

.summary-grid .summary b {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

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

th,
td {
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

th {
  background: #faf6ea;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.form-grid,
.stack {
  display: grid;
  gap: 14px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--sub);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 15px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(200, 16, 46, .12);
  border-color: var(--brand);
}

.notice {
  padding: 12px 14px;
  color: #6b5400;
  background: #fff7e3;
  border: 1px solid #f0d98a;
  border-radius: 12px;
}

.settings-card,
.contract-item,
.contract-form {
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.contract-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.schedule-actions,
.preset-bar {
  margin-bottom: 12px;
}

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.preset-bar button {
  padding: 9px 14px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #f6ece2;
  color: #9c6b3f;
  font-size: 13px;
  font-weight: 700;
}

.preset-bar button.active {
  border-color: var(--ink);
}

.week-label {
  min-width: 150px;
  margin: 10px 0;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
}

.schedule-grid {
  display: grid;
  grid-template-columns: minmax(84px, auto) repeat(7, minmax(76px, 1fr));
  overflow: auto;
  background: #fff;
  border: 1px solid #ece8e1;
  border-radius: 12px;
}

.schedule-grid > div {
  min-height: 56px;
  padding: 8px 4px;
  text-align: center;
  border-right: 1px solid #f2efe9;
  border-bottom: 1px solid #f2efe9;
  font-size: 12px;
  font-weight: 700;
}

.schedule-grid .head {
  background: #fafaf8;
  color: #8a857b;
}

.schedule-grid .slot {
  cursor: pointer;
}

.schedule-grid .slot.filled {
  background: #edeaef;
  color: #5f5570;
}

.empty-state,
#clockSections > p {
  padding: 48px 20px;
  text-align: center;
  color: var(--sub);
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 16px;
}

.gate {
  background: var(--bg);
}

.gate-card {
  max-width: 480px;
  padding: 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.brand-mark {
  color: var(--ink);
  border-color: var(--brand);
  font-size: 20px;
  font-weight: 900;
}

.gate-tabs {
  background: #efe6d3;
}

.gate-tabs button.active {
  color: var(--brand);
}

dialog {
  width: min(94vw, 540px);
  max-height: 92vh;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(10, 15, 40, .3);
}

dialog::backdrop {
  background: rgba(18, 22, 40, .45);
}

.dialog-card,
.sign-card {
  padding: 24px;
  background: #fff;
}

#toast {
  top: auto;
  bottom: 24px;
  padding: 13px 22px;
  border-radius: 30px;
  background: var(--ink);
}

#toast.error {
  background: var(--danger);
}

@media (max-width: 1100px) {
  .employee-cards,
  .clock-grid {
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    gap: 13px;
  }
}

@media (max-width: 640px) {
  .topbar .bar {
    gap: 8px;
    padding: 10px 13px;
  }

  .topbar .logo strong {
    font-size: 17px;
  }

  .sync,
  #refreshBtn {
    display: none;
  }

  .clock .t {
    font-size: 15px;
  }

  .clock .d {
    font-size: 10px;
  }

  .store-tag,
  .badge {
    padding: 4px 9px;
    font-size: 11px;
  }

  .lockbtn {
    padding: 7px 9px;
    font-size: 12px;
  }

  #adminNav {
    gap: 2px;
    padding: 0 10px 9px;
  }

  #adminNav button {
    padding: 8px 11px;
    font-size: 14px;
  }

  .content,
  .page {
    padding: 14px 12px;
  }

  .employee-cards,
  .clock-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }

  .employee-card .avatar,
  .clock-card .avatar {
    width: 64px;
    height: 64px;
    font-size: 24px;
  }

  .employee-card h3,
  .clock-card .name {
    font-size: 18px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 10px;
  }
}
