:root {
  color-scheme: dark;
  --bg: #111315;
  --panel: #1b1f23;
  --panel-2: #22272d;
  --panel-3: #2a3037;
  --ink: #f2f5f7;
  --muted: #a5b0bb;
  --line: #3a424c;
  --blue: #5aa2ff;
  --green: #4fd18b;
  --red: #ff7676;
  --amber: #f6b84a;
  --focus: #6ee7c8;
  --input: #15191d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
}

.period-controls,
.inline-actions,
.panel-head,
.day-tabs,
.panel-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-tools {
  justify-content: flex-end;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input, select, button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

input, select {
  width: 100%;
  padding: 6px 8px;
  background: var(--input);
  color: var(--ink);
}

textarea {
  width: 100%;
  min-height: 56px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input);
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

button {
  padding: 0 12px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--panel-3);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.hidden {
  display: none !important;
}

.install-button {
  border-color: #7bd92e;
  background: linear-gradient(135deg, #132318, #173047);
  color: #d8ff74;
  font-weight: 700;
}

.install-button:hover {
  border-color: #22e7ff;
  color: #7ff5ff;
}

button.danger {
  border-color: #744040;
  color: var(--red);
}

button.danger:hover {
  border-color: var(--red);
  background: #341f22;
}

.button-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink);
  text-decoration: none;
}

.button-link:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--panel-3);
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 10px 24px 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: 0;
}

.tab.active,
.day-tabs button.active,
.panel-tools button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #081018;
}

main {
  padding: 20px 24px 32px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric {
  min-height: 82px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel-head {
  justify-content: space-between;
  min-height: 58px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.compact-field {
  width: 150px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

.voice-entry {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.voice-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.voice-status {
  grid-column: 1 / -1;
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.total-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  min-height: 52px;
  padding: 12px 14px;
  background: var(--panel-2);
  border-top: 1px solid var(--line);
  font-size: 13px;
  flex-wrap: wrap;
}

.total-bar span {
  margin-right: auto;
  color: var(--muted);
  font-weight: 700;
}

.total-bar strong {
  color: var(--ink);
}

.total-bar:empty {
  display: none;
}

.company-total-row td {
  background: var(--panel-2);
  border-bottom: 2px solid var(--line);
  font-weight: 700;
}

.lock-panel {
  display: grid;
  min-height: 280px;
  place-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.lock-panel.hidden {
  display: none;
}

.lock-box {
  display: grid;
  width: min(320px, 100%);
  gap: 14px;
}

.lock-box h3 {
  margin: 0;
  font-size: 18px;
}

.locked .table-wrap,
.locked #addEmployeeBtn {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

#compareTable {
  min-width: 2200px;
}

caption {
  caption-side: top;
  padding: 12px 14px;
  text-align: left;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-3);
  color: var(--ink);
  font-size: 12px;
}

tfoot td {
  background: var(--panel-2);
  border-top: 2px solid var(--line);
  font-weight: 700;
}

td.number,
th.number {
  text-align: right;
}

.time-tech-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.time-tech-cell > span {
  font-weight: 700;
  margin-right: 4px;
}

.time-off-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.time-off-check input {
  width: auto;
  min-height: 0;
}

.time-day-setting {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
}

.time-day-setting input {
  width: auto;
  min-height: 0;
}

.iaq-entry {
  display: grid;
  grid-template-columns: minmax(84px, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-width: 142px;
}

.iaq-revenue-check {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.iaq-revenue-check input {
  width: auto;
  min-height: 0;
}

.compare-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  color: var(--muted);
  font-size: 13px;
}

.compare-meta strong {
  color: var(--ink);
}

.compare-warning {
  margin-top: 8px;
  color: var(--amber);
  font-weight: 700;
}

tr.missing-prior td {
  color: var(--muted);
}

.delta {
  font-weight: 700;
}

.delta.positive {
  color: var(--green);
}

.delta.negative {
  color: var(--red);
}

.dl-na {
  color: var(--red);
  font-weight: 700;
}

.dl-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dl-note {
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
}

.delta.neutral {
  color: var(--muted);
}

.time-actions {
  display: flex;
  gap: 6px;
}

.time-actions button {
  min-width: 64px;
  padding: 0 8px;
}

td.name-cell {
  font-weight: 700;
  min-width: 160px;
}

.name-heading,
td.name-cell {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--line);
}

th.name-heading {
  z-index: 4;
  background: var(--panel-3);
}

tfoot td.name-cell {
  background: var(--panel-2);
}

td input[type="number"],
td input[type="time"],
td input[type="text"] {
  min-width: 84px;
}

td input.money {
  min-width: 96px;
}

.order-input {
  max-width: 72px;
  min-width: 64px;
  text-align: right;
}

.status {
  display: inline-flex;
  align-items: center;
  min-width: 56px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status.ok {
  background: #173425;
  color: var(--green);
}

.status.warn {
  background: #3d2d12;
  color: var(--amber);
}

.status.off {
  background: #3a2024;
  color: var(--red);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #eef2f6;
  color: #111315;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(9, 14, 24, 0.86);
}

.login-overlay.hidden {
  display: none;
}

.login-box {
  width: min(380px, 100%);
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.login-box h2 {
  margin: 0;
  font-size: 20px;
}

.login-status {
  min-height: 20px;
  color: var(--muted);
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

@media (max-width: 820px) {
  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .period-controls {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  main {
    padding: 14px;
  }

  .tabs {
    padding-left: 14px;
    padding-right: 14px;
  }

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

@media (max-width: 520px) {
  .metrics {
    grid-template-columns: 1fr;
  }
}
