:root {
  --brand-yellow: #f3c11f;
  --brand-yellow-soft: #fff5cf;
  --brand-yellow-muted: #f9e7a3;
  --brand-black: #111827;
  --brand-red: #b91c1c;
  --brand-red-soft: #fee2e2;
  --text: #1f2937;
  --text-strong: #111827;
  --muted: #6b7280;
  --page: #f3f4f6;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --line: #d9dee7;
  --line-strong: #b8c0cc;
  --success: #166534;
  --success-soft: #dcfce7;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.08);
  --shadow-md: 0 14px 32px rgba(17, 24, 39, 0.11);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  width: min(1240px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px;
  background: var(--brand-black);
  color: #ffffff;
  border-bottom: 4px solid var(--brand-yellow);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-md);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-red);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: var(--brand-yellow);
}

h1,
h2 {
  margin: 0;
  color: inherit;
  letter-spacing: 0;
}

h1 {
  font-size: 2.35rem;
  line-height: 1.05;
}

h2 {
  color: var(--text-strong);
  font-size: 1.18rem;
  line-height: 1.25;
}

.topbar h1 {
  color: #ffffff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.clock-panel {
  display: grid;
  gap: 5px;
  min-width: 214px;
  text-align: right;
}

.clock-panel span {
  color: #d1d5db;
  font-size: 0.9rem;
}

.clock-panel strong {
  color: var(--brand-yellow);
  font-size: 1.8rem;
  line-height: 1;
}

.admin-access-button,
.primary-button,
.secondary-button,
.tab-button,
.calendar-detail-button {
  min-height: 40px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.admin-access-button {
  padding: 0 16px;
  border: 1px solid var(--brand-yellow);
  background: var(--brand-yellow);
  color: var(--brand-black);
  box-shadow: 0 8px 18px rgba(243, 193, 31, 0.18);
}

.view-tabs {
  display: flex;
  gap: 4px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-sm);
}

.tab-button {
  padding: 0 16px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.tab-button.active {
  background: var(--brand-black);
  color: #ffffff;
  border-color: var(--brand-black);
}

.tab-button:hover:not(.active) {
  background: var(--surface-alt);
  color: var(--text-strong);
}

.view-panel {
  display: none;
  margin-top: 20px;
}

.view-panel.active {
  display: block;
}

.employee-panel,
.admin-locked,
.records-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.admin-content {
  padding: 0;
}

.admin-shell {
  display: grid;
  gap: 14px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.admin-subnav {
  display: flex;
  gap: 6px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.admin-tab-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.admin-tab-button.active {
  background: var(--brand-black);
  border-color: var(--brand-black);
  color: #ffffff;
}

.admin-tab-button:hover:not(.active) {
  background: var(--surface-alt);
  color: var(--text-strong);
}

.admin-panel {
  display: none;
  padding: 20px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.admin-panel.active {
  display: block;
}

.employee-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 20px;
}

.employee-lookup-wrap {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(300px, 1fr);
  gap: 14px;
  width: min(690px, 100%);
}

.lookup-field {
  margin: 0;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text-strong);
  font-size: 0.84rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
}

input[readonly] {
  background: var(--surface-alt);
  color: var(--muted);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(243, 193, 31, 0.36);
  outline-offset: 2px;
}

.detected-employee {
  display: grid;
  align-content: center;
  min-height: 68px;
  padding: 12px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand-yellow);
  border-radius: var(--radius);
}

.detected-employee strong {
  color: var(--text-strong);
  font-size: 1rem;
}

.detected-employee span,
.helper-copy {
  color: var(--muted);
  line-height: 1.45;
}

.detected-employee.warning {
  background: #fff7f7;
  border-color: #f5b4b4;
  border-left-color: var(--brand-red);
}

.status-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}

.status-card {
  min-height: 124px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.primary-status {
  border-left: 5px solid var(--brand-yellow);
}

.status-card .label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-card strong {
  display: block;
  color: var(--text-strong);
  font-size: 1.65rem;
  line-height: 1.1;
}

.status-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.control-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.action-button {
  display: grid;
  gap: 7px;
  min-height: 104px;
  padding: 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #ffffff;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: opacity 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.action-button:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.action-button span {
  font-size: 1.04rem;
  font-weight: 800;
  line-height: 1.2;
}

.action-button small {
  opacity: 0.86;
}

.time-in {
  background: var(--brand-black);
  border-color: var(--brand-yellow);
}

.coffee-in {
  background: #604900;
}

.coffee-out {
  background: #4b5563;
}

.time-out {
  background: var(--brand-red);
}

.records-section {
  padding: 20px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.toolbar,
.calendar-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.calendar-controls strong {
  min-width: 180px;
  color: var(--text-strong);
  text-align: center;
}

.primary-button,
.secondary-button {
  padding: 0 15px;
}

.primary-button {
  border: 1px solid var(--brand-black);
  background: var(--brand-black);
  color: #ffffff;
}

.primary-button:hover {
  background: #000000;
  border-color: #000000;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--text-strong);
}

.secondary-button:hover {
  border-color: var(--brand-black);
  background: var(--brand-black);
  color: #ffffff;
}

.secondary-button.danger {
  border-color: #ef9a9a;
  color: var(--brand-red);
}

.secondary-button.danger:hover {
  background: var(--brand-red);
  border-color: var(--brand-red);
  color: #ffffff;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(132px, 1fr));
  gap: 8px;
  overflow-x: auto;
}

.calendar-day-name,
.calendar-day {
  min-width: 132px;
}

.calendar-day-name {
  padding: 0 4px 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-day {
  min-height: 142px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.calendar-day.muted {
  background: var(--surface-alt);
  color: var(--muted);
}

.calendar-date {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--text-strong);
  font-weight: 800;
}

.calendar-count {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--brand-yellow-soft);
  color: #5f4700;
  font-size: 0.74rem;
}

.calendar-entry {
  display: grid;
  gap: 2px;
  padding: 7px 0;
  border-top: 1px solid #eceff3;
  font-size: 0.8rem;
}

.calendar-entry strong {
  color: var(--text-strong);
  line-height: 1.25;
}

.calendar-entry span {
  color: var(--muted);
}

.calendar-detail-button {
  width: 100%;
  min-height: 34px;
  margin-top: 8px;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--text-strong);
}

.table-action-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text-strong);
  cursor: pointer;
  font-weight: 800;
}

.table-action-button:hover {
  border-color: var(--brand-black);
  background: var(--brand-black);
  color: #ffffff;
}

.calendar-detail-button:hover {
  border-color: var(--brand-black);
  background: var(--brand-black);
  color: #ffffff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(17, 24, 39, 0.66);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(980px, 100%);
  max-height: min(720px, 90vh);
  overflow: auto;
  padding: 20px;
  background: #ffffff;
  border-top: 5px solid var(--brand-yellow);
  border-radius: var(--radius);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.admin-locked {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 20px;
  padding: 20px;
}

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

.employee-form {
  grid-template-columns: 0.65fr 1.15fr 1fr 1fr 0.8fr 0.9fr auto;
  align-items: end;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.admin-panel .employee-form {
  margin-bottom: 0;
}

.time-card-section {
  margin-bottom: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.time-card-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) 1fr 1fr auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.time-card-summary {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand-black);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 700;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--brand-red);
  font-size: 0.88rem;
  font-weight: 700;
}

.employee-records {
  margin-top: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.count-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.count-pill {
  background: var(--brand-black);
  color: #ffffff;
}

.status-pill.active {
  background: var(--success-soft);
  color: var(--success);
}

.status-pill.resign {
  background: var(--brand-red-soft);
  color: var(--brand-red);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  color: var(--text);
  font-size: 0.92rem;
}

tbody tr:hover td {
  background: #fffdf4;
}

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

.event-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--text-strong);
  font-size: 0.8rem;
  font-weight: 800;
}

.event-badge.red {
  background: var(--brand-red-soft);
  color: var(--brand-red);
}

.event-badge.yellow {
  background: var(--brand-yellow-soft);
  color: #5f4700;
}

.empty-state {
  padding: 30px 12px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1080px) {
  .employee-form {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .employee-form .primary-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .header-actions,
  .employee-panel,
  .section-heading,
  .admin-header,
  .admin-locked {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-locked {
    display: flex;
  }

  .header-actions,
  .clock-panel,
  .employee-lookup-wrap {
    width: 100%;
  }

  .clock-panel {
    text-align: left;
  }

  .employee-lookup-wrap,
  .status-grid,
  .control-panel,
  .time-card-form {
    grid-template-columns: 1fr;
  }

  .calendar-grid {
    grid-template-columns: repeat(7, 144px);
  }

  .admin-subnav {
    overflow-x: auto;
    width: 100%;
  }

  .admin-tab-button {
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 0;
  }

  h1 {
    font-size: 1.85rem;
  }

  .topbar,
  .view-tabs,
  .employee-panel,
  .records-section,
  .admin-locked,
  .admin-header,
  .admin-subnav,
  .admin-panel,
  .modal-panel {
    border-radius: 0;
  }

  .workspace {
    width: 100%;
  }

  .view-tabs {
    overflow-x: auto;
  }

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

  .status-grid,
  .control-panel {
    padding: 0 12px;
  }

  .employee-panel,
  .records-section,
  .admin-locked,
  .admin-panel,
  .admin-header {
    padding: 16px 12px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .topbar,
  .view-tabs,
  .employee-panel,
  .status-grid,
  .control-panel,
  .admin-locked,
  .employee-form,
  .employee-records,
  .time-card-form,
  .admin-header,
  .admin-subnav,
  .toolbar,
  .calendar-controls {
    display: none !important;
  }

  .app-shell,
  .admin-content,
  .records-section {
    padding: 0;
    box-shadow: none;
    border: 0;
  }

  .view-panel {
    display: none !important;
  }

  #adminView,
  #adminContent,
  .time-card-section {
    display: block !important;
  }
}
