:root {
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #f4f7f8;
  --panel: #ffffff;
  --brand: #096b72;
  --brand-dark: #064a50;
  --good: #126b45;
  --bad: #a73333;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px 32px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.logo-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
.topbar p, .section-head span, .field-note { color: var(--muted); }

main {
  width: min(1380px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.mobile-main {
  width: min(620px, calc(100% - 20px));
}

.driver-layout {
  width: min(960px, calc(100% - 20px));
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 16px;
  align-items: start;
}

.driver-side-nav {
  position: sticky;
  top: 14px;
  display: grid;
  gap: 8px;
}

.driver-nav-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  text-align: left;
  padding: 0 12px;
}

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

.driver-page {
  display: none;
}

.driver-page.active {
  display: block;
}

.compact-summary {
  grid-template-columns: repeat(2, 1fr);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(480px, 100%);
  margin: 0;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 18px 44px rgba(23, 32, 42, 0.08);
}

.login-panel .brand {
  margin-bottom: 22px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab-button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

.tab-panel {
  display: none;
}

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

.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.subtab-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

.subtab-button.active {
  background: #132238;
  color: #fff;
  border-color: #132238;
}

.overview-subpanel {
  display: none;
}

.overview-subpanel.active {
  display: block;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary article,
.panel,
.mini-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary article {
  padding: 18px;
  min-height: 92px;
}

.summary span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.summary strong {
  font-size: 28px;
  overflow-wrap: anywhere;
}

.result-card {
  border-color: #b7d7ce !important;
  background: #f4fbf8 !important;
}

.panel {
  padding: 20px;
  margin-bottom: 18px;
}

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

.register-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.mini-form {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  min-height: 116px;
  resize: vertical;
}

.field-note {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.import-box {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.salary-result {
  display: grid;
  gap: 6px;
  align-self: end;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7fafb;
  color: #344054;
  font-weight: 700;
}

.adjustment-list {
  display: grid;
  gap: 8px;
}

.adjustment-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.hidden { display: none !important; }
.hidden-panel { display: none; }
.hidden-panel.active { display: block; }

.button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

.button:hover {
  background: var(--brand-dark);
  color: #fff;
}

.wide {
  align-self: end;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7fafb;
  font-size: 13px;
}

.chip button {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--bad);
  font-weight: 700;
}

.inline-check {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.inline-check input {
  width: auto;
}

.chip .lock-button {
  margin-left: 8px;
  color: #334155;
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.compact-table {
  margin-top: 16px;
}

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

th {
  background: #eef3f4;
  font-size: 13px;
}

tfoot td {
  border-top: 2px solid var(--ink);
  font-weight: 700;
  background: #f7fafb;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

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

.invoice-link img {
  width: 74px;
  height: 54px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: block;
}

.qr-box {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.qr-box img {
  width: 160px;
  height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-box a {
  color: var(--brand);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
}

.modal-panel {
  width: min(920px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.invoice-preview {
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 12px;
  background: #fff;
}

.result-json {
  margin-top: 14px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7fafb;
  white-space: pre-wrap;
}

.positive { color: var(--good); }
.negative { color: var(--bad); }

.admin-page .topbar {
  padding: 14px 24px;
  min-height: 82px;
}

.admin-page .logo-mark {
  width: 50px;
  height: 50px;
}

.admin-page h1 {
  font-size: 28px;
}

.admin-page main {
  width: calc(100% - 48px);
  max-width: none;
  margin: 16px 24px 42px;
}

.admin-page .tabs {
  gap: 4px;
  margin-bottom: 12px;
}

.admin-page .tab-button {
  min-height: 42px;
  padding: 0 16px;
  white-space: nowrap;
}

.admin-page .panel {
  padding: 18px 20px;
  margin-bottom: 16px;
}

.admin-page .section-head {
  margin-bottom: 12px;
}

.admin-page .entry-grid {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 12px;
}

.admin-page input,
.admin-page select,
.admin-page textarea {
  min-height: 44px;
}

.admin-page .button {
  min-height: 42px;
}

@media (max-width: 1100px) {
  .summary,
  .register-grid,
  .entry-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .panel {
    overflow-x: auto;
  }

  table {
    min-width: 850px;
  }
}

@media (max-width: 640px) {
  body.mobile-page {
    background: #eef4f5;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  main {
    width: min(100% - 20px, 1380px);
    margin-top: 14px;
  }

  .summary,
  .register-grid,
  .entry-grid {
    grid-template-columns: 1fr;
  }

  .driver-layout {
    display: block;
  }

  .driver-side-nav {
    position: static;
    display: flex;
    overflow-x: auto;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 4px;
  }

  .driver-nav-button {
    flex: 0 0 auto;
    text-align: center;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .mobile-page .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px 14px;
    gap: 10px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(23, 32, 42, 0.08);
  }

  .mobile-page .brand {
    width: 100%;
    justify-content: space-between;
  }

  .mobile-page .brand h1 {
    font-size: 22px;
  }

  .mobile-page .brand p {
    font-size: 13px;
  }

  .mobile-page .logo-mark {
    width: 46px;
    height: 46px;
    border-radius: 8px;
  }

  .mobile-page .top-actions {
    width: 100%;
  }

  .mobile-page .top-actions .button {
    width: auto;
    min-height: 36px;
    padding: 0 12px;
    font-size: 14px;
  }

  .mobile-main.driver-layout {
    width: 100%;
    margin: 0;
    padding: 12px 12px 92px;
  }

  .mobile-page .driver-side-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin: 0;
    padding: 8px 8px max(8px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 28px rgba(23, 32, 42, 0.12);
    overflow: visible;
  }

  .mobile-page .driver-nav-button {
    min-height: 56px;
    padding: 0 6px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.1;
    display: grid;
    place-items: center;
    white-space: normal;
    box-shadow: none;
  }

  .mobile-page .panel {
    margin-bottom: 12px;
    padding: 14px;
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 10px 26px rgba(23, 32, 42, 0.06);
  }

  .mobile-page .section-head {
    display: block;
    margin-bottom: 14px;
  }

  .mobile-page .section-head h2 {
    font-size: 22px;
    margin-bottom: 4px;
  }

  .mobile-page .section-head span {
    font-size: 14px;
  }

  .mobile-page .entry-grid {
    gap: 10px;
  }

  .mobile-page label {
    gap: 6px;
    font-size: 14px;
    font-weight: 800;
  }

  .mobile-page input,
  .mobile-page select,
  .mobile-page textarea {
    min-height: 54px;
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
  }

  .mobile-page input[type="file"] {
    padding-top: 12px;
  }

  .mobile-page .button {
    min-height: 56px;
    border-radius: 8px;
    font-size: 16px;
  }

  .mobile-page #startShiftButton,
  .mobile-page #stopShiftButton {
    width: 100%;
  }

  .mobile-page #startShiftButton {
    font-size: 18px;
    font-weight: 900;
  }

  .mobile-page #syncQueueButton {
    width: 100%;
    margin-top: 8px;
  }

  .mobile-page .field-note {
    font-size: 13px;
    line-height: 1.35;
  }

  .mobile-page .chip-list {
    gap: 7px;
  }

  .mobile-page .chip {
    width: 100%;
    justify-content: flex-start;
    border-radius: 8px;
    padding: 10px 12px;
    line-height: 1.35;
  }

  .mobile-page .summary {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .mobile-page .summary article {
    border-radius: 8px;
    padding: 14px;
  }

  .mobile-table-wrap {
    margin-top: 16px;
  }

  .mobile-table-wrap h3 {
    margin-bottom: 8px;
    font-size: 15px;
  }

  .mobile-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .mobile-table th,
  .mobile-table td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 13px;
  }

  .mobile-table th {
    background: #edf3f4;
  }
}

body.mobile-page {
  background: #eef4f5;
  font-size: 18px;
}

.mobile-page .topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 12px 14px;
  gap: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.1);
}

.mobile-page .brand h1 {
  font-size: 28px;
}

.mobile-page .brand p {
  font-size: 16px;
}

.mobile-page .logo-mark {
  width: 56px;
  height: 56px;
  font-size: 22px;
}

.mobile-page .top-actions .button {
  min-height: 48px;
  padding: 0 18px;
  font-size: 17px;
}

.mobile-main.driver-layout {
  width: 100%;
  max-width: none;
  display: block;
  margin: 0;
  padding: 14px 14px 104px;
}

.mobile-page .driver-side-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 10px 8px max(10px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 32px rgba(23, 32, 42, 0.16);
}

.mobile-page .driver-nav-button {
  min-height: 68px;
  border-radius: 8px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  white-space: normal;
}

.mobile-page .driver-page-shell {
  width: 100%;
}

.mobile-page .panel {
  width: 100%;
  margin: 0 0 14px;
  padding: 18px;
  border-radius: 8px;
  overflow: visible;
  box-shadow: 0 10px 26px rgba(23, 32, 42, 0.07);
}

.mobile-page .section-head {
  display: block;
  margin-bottom: 18px;
}

.mobile-page .section-head h2 {
  font-size: 28px;
  margin-bottom: 6px;
}

.mobile-page .section-head span,
.mobile-page .field-note {
  font-size: 16px;
  line-height: 1.4;
}

.mobile-page .entry-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.mobile-page label {
  gap: 8px;
  font-size: 18px;
  font-weight: 900;
}

.mobile-page input,
.mobile-page select,
.mobile-page textarea {
  min-height: 64px;
  border-radius: 8px;
  font-size: 20px;
  padding: 0 16px;
}

.mobile-page input[type="file"] {
  padding: 16px;
}

.mobile-page .button {
  width: 100%;
  min-height: 66px;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 900;
}

.mobile-page #startShiftButton {
  min-height: 76px;
  font-size: 22px;
}

.mobile-page .summary {
  grid-template-columns: 1fr;
  gap: 12px;
}

.mobile-page .summary article {
  border-radius: 8px;
  padding: 18px;
}

.mobile-page .summary strong {
  font-size: 32px;
}

.mobile-page .chip {
  width: 100%;
  justify-content: flex-start;
  padding: 14px;
  font-size: 17px;
  line-height: 1.35;
}

.mobile-page .mobile-table {
  min-width: 0;
}

.mobile-page .mobile-table th,
.mobile-page .mobile-table td {
  padding: 14px 10px;
  font-size: 16px;
}

body.mobile-page {
  min-height: 100vh;
  background: #121212 !important;
  color: #f3f4f6;
  font-size: 22px;
}

.mobile-page .topbar {
  position: static;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 18px 22px 8px;
  background: #121212;
  border: 0;
  box-shadow: none;
}

.mobile-page .brand {
  gap: 14px;
}

.mobile-page .brand h1 {
  color: #f8fafc;
  font-size: 34px;
  line-height: 1;
}

.mobile-page .brand p {
  color: #aeb6c2;
  font-size: 18px;
}

.mobile-page .logo-mark {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  font-size: 25px;
}

.mobile-page .top-actions {
  margin-left: auto;
}

.mobile-page .top-actions .button {
  min-height: 48px;
  width: auto;
  padding: 0 18px;
  border-color: #3a3a3a;
  background: #232323;
  color: #e5e7eb;
  font-size: 17px;
}

.mobile-main.driver-layout {
  width: 100vw;
  max-width: none;
  display: block;
  margin: 0;
  padding: 16px 24px 116px;
}

.mobile-page .driver-page-shell,
.mobile-page .driver-page.active {
  width: 100%;
}

.mobile-page .panel {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #f3f4f6;
  box-shadow: none;
}

.mobile-page .section-head {
  display: block;
  margin: 8px 0 26px;
}

.mobile-page .section-head h2 {
  color: #ffffff;
  font-size: 34px;
  line-height: 1.1;
  margin: 0 0 8px;
}

.mobile-page .section-head span,
.mobile-page .field-note {
  color: #aeb6c2;
  font-size: 18px;
  line-height: 1.35;
}

.mobile-page .entry-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.mobile-page label {
  color: #e8edf3;
  font-size: 21px;
  font-weight: 900;
  gap: 10px;
}

.mobile-page input,
.mobile-page select,
.mobile-page textarea {
  min-height: 78px;
  border: 2px solid #44474d;
  border-radius: 22px;
  background: #1c1c1c;
  color: #f8fafc;
  font-size: 26px;
  font-weight: 700;
  padding: 0 24px;
}

.mobile-page input::placeholder,
.mobile-page textarea::placeholder {
  color: #aeb6c2;
}

.mobile-page input:focus,
.mobile-page select:focus,
.mobile-page textarea:focus {
  outline: none;
  border-color: #d8a75f;
  box-shadow: 0 0 0 2px rgba(216, 167, 95, 0.25);
}

.mobile-page input[type="file"] {
  padding: 20px;
}

.mobile-page .button {
  min-height: 78px;
  border: 0;
  border-radius: 22px;
  background: #086d70;
  color: #ffffff;
  font-size: 25px;
  font-weight: 900;
}

.mobile-page .button.secondary {
  border: 0;
  background: #353535;
  color: #e8f7f7;
}

.mobile-page #startShiftButton {
  min-height: 84px;
  margin-top: 4px;
  font-size: 27px;
}

.mobile-page #syncQueueButton {
  margin-top: 28px;
}

.mobile-page .driver-side-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 10px 8px max(10px, env(safe-area-inset-bottom));
  background: #1b1b1b;
  border-top: 1px solid #363636;
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.45);
}

.mobile-page .driver-nav-button {
  min-height: 74px;
  border: 0;
  border-radius: 10px;
  background: #494949;
  color: #ffffff;
  font-size: 19px;
  font-weight: 900;
}

.mobile-page .driver-nav-button.active {
  background: #06686b;
  color: #ffffff;
}

.mobile-page .summary {
  grid-template-columns: 1fr;
  gap: 14px;
}

.mobile-page .summary article {
  border: 1px solid #3f4248;
  background: #1c1c1c;
  border-radius: 22px;
  padding: 24px;
}

.mobile-page .summary article span {
  color: #aeb6c2;
  font-size: 20px;
}

.mobile-page .summary strong {
  color: #ffffff;
  font-size: 40px;
}

.mobile-page .mobile-table {
  background: #1c1c1c;
  border: 1px solid #3f4248;
  border-radius: 18px;
}

.mobile-page .mobile-table th,
.mobile-page .mobile-table td {
  color: #f3f4f6;
  padding: 18px 14px;
  font-size: 18px;
}

.mobile-page .mobile-table th {
  background: #2a2a2a;
}

.mobile-page .chip {
  background: #1c1c1c;
  border-color: #3f4248;
  color: #f3f4f6;
  font-size: 19px;
  padding: 18px;
  border-radius: 18px;
}

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

  .button,
  .small-button,
  form,
  .chip button {
    display: none !important;
  }

  .topbar,
  .panel,
  .summary article {
    border-color: #bbb;
  }

  main {
    width: 100%;
    margin: 12px 0;
  }

  .panel {
    break-inside: avoid;
    overflow: visible;
  }

  table {
    min-width: 0;
    font-size: 11px;
  }

  .tab-panel,
  .overview-subpanel {
    display: none !important;
  }

  .tab-panel.active,
  .overview-subpanel.active {
    display: block !important;
  }

  .tabs {
    display: none;
  }
}
