:root {
  --bg: #f4f6f6;
  --surface: #ffffff;
  --surface-soft: #eef3f2;
  --ink: #202428;
  --muted: #65717b;
  --line: #d8dee2;
  --brand: #c9212c;
  --brand-dark: #9e1721;
  --teal: #007f78;
  --amber: #b86f00;
  --danger: #b42424;
  --sidebar: #30323e;
  --sidebar-soft: #3a3d49;
  --shadow: 0 18px 42px rgba(23, 29, 36, 0.09);
  --soft-shadow: 0 8px 22px rgba(23, 29, 36, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  overflow: hidden;
}

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

button,
.button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

button:hover,
.button:hover {
  border-color: #aeb8bf;
  box-shadow: 0 2px 8px rgba(23, 29, 36, 0.06);
}

button:focus-visible,
.button:focus-visible {
  outline: 2px solid rgba(201, 33, 44, 0.32);
  outline-offset: 2px;
}

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

.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.secondary {
  background: #edf6f5;
  border-color: #b7d7d4;
  color: #075b55;
}

.ghost {
  background: transparent;
}

.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.login-screen {
  height: 100vh;
  min-height: 100vh;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(201, 33, 44, 0.11), rgba(0, 127, 120, 0.08)),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 30px;
}

.login-logo {
  display: block;
  width: 190px;
  max-width: 70%;
  height: auto;
  margin: 0 auto 22px;
}

.login-copy {
  color: var(--muted);
  margin-bottom: 18px;
}

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

h1 {
  font-size: 24px;
  line-height: 1.2;
  margin-bottom: 6px;
}

h2 {
  font-size: 18px;
  margin-bottom: 0;
}

h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(0, 127, 120, 0.18);
  border-color: var(--teal);
}

.form-error,
.error-text {
  color: var(--danger);
  min-height: 20px;
  margin: 0;
}

.app-shell {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  background: var(--sidebar);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 22px 16px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 22px;
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
}

.brand-lockup {
  display: flex;
  justify-content: center;
  padding: 6px 4px 16px;
}

.brand-lockup img {
  width: 150px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
}

.nav-list {
  display: grid;
  align-content: start;
  gap: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 18px;
}

.nav-list button {
  justify-content: flex-start;
  background: transparent;
  border-color: transparent;
  color: #e4e8eb;
  min-height: 42px;
  padding: 0 12px;
  font-weight: 600;
}

.nav-list button:hover,
.nav-list button.active {
  background: var(--sidebar-soft);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 3px 0 0 var(--brand);
}

.nav-list button:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.35);
  outline-offset: -2px;
}

.workspace {
  min-width: 0;
  min-height: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(0, 127, 120, 0.04), rgba(0, 127, 120, 0) 260px),
    var(--bg);
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 18px 24px;
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.view {
  display: none;
  flex: 1 1 auto;
  padding: 24px;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.view.active {
  display: block;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  min-width: 0;
  padding: 18px;
}

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

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  padding: 16px;
  min-height: 94px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 28px;
  margin-top: 8px;
}

.metric.warn strong {
  color: var(--amber);
}

.metric.good strong {
  color: var(--teal);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
  align-items: start;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.insight-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
}

.insight-tile span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.insight-tile strong {
  display: block;
  font-size: 22px;
  margin-top: 4px;
}

.split-view {
  display: grid;
  grid-template-columns: minmax(310px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.list-column {
  align-self: start;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 136px);
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.search-row {
  margin-bottom: 12px;
}

.customer-list {
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}

.customer-row {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-left-width: 4px;
  min-height: 76px;
  white-space: normal;
}

.customer-row:hover {
  border-color: #b8c2c8;
  box-shadow: var(--soft-shadow);
}

.customer-row.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(201, 33, 44, 0.12);
}

.customer-row.healthy {
  border-left-color: var(--teal);
}

.customer-row.expiry {
  border-left-color: var(--amber);
}

.customer-row.low {
  border-left-color: var(--brand);
}

.customer-row strong {
  display: block;
  line-height: 1.2;
}

.customer-row-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.customer-row-main .badge-row {
  margin-top: 2px;
}

.customer-balance-pill {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
  padding: 4px 8px;
}

.row-meta,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: var(--surface-soft);
  color: var(--muted);
}

.badge.warn {
  background: #fff4df;
  color: #8d5700;
}

.badge.good {
  background: #e7f5f3;
  color: #075b55;
}

.badge.danger {
  background: #fde7e7;
  color: #9c1c1c;
}

.detail-pane {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  padding: 24px;
  text-align: center;
}

.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.balance-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  min-width: 170px;
  padding: 14px;
  text-align: right;
}

.balance-card.healthy {
  border-color: #b7d7d4;
  background: #f0faf8;
}

.balance-card.expiry {
  border-color: #f0cc86;
  background: #fff8eb;
}

.balance-card.low {
  border-color: #e5a2a8;
  background: #fff2f3;
}

.balance-number {
  font-size: 44px;
  line-height: 1;
  font-weight: 700;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
  min-width: 0;
}

.action-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 14px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  min-height: auto;
  min-width: 0;
}

.action-box-wide {
  grid-column: auto;
  min-height: auto;
}

.action-fields {
  display: grid;
  gap: 10px;
  align-content: start;
}

.sale-summary {
  border: 1px solid #b7d7d4;
  border-radius: 8px;
  background: linear-gradient(180deg, #f2fbfa, #e9f5f3);
  color: #075b55;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
}

.sale-summary strong {
  color: var(--ink);
  font-size: 22px;
}

.membership-sale-pill {
  border: 1px solid #c8d7d5;
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background: #f5fbfa;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
}

.membership-sale-pill span,
.membership-selection small,
.member-result small {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.membership-sale-pill strong {
  display: block;
  margin-top: 2px;
}

.membership-dialog-form {
  display: grid;
  gap: 14px;
}

#membershipDialog {
  width: min(560px, calc(100vw - 32px));
}

.member-search-results {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  max-height: 310px;
  overflow: auto;
  padding: 8px;
}

.member-result {
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  box-sizing: border-box;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 12px;
  text-align: left;
  white-space: normal;
  width: 100%;
}

.member-result > span:first-child {
  min-width: 0;
}

.member-result strong {
  display: block;
  line-height: 1.2;
}

.member-result small {
  line-height: 1.2;
  margin-top: 3px;
}

.member-result:hover {
  border-color: #b8c2c8;
  background: var(--surface-soft);
}

.member-result.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(20, 133, 127, 0.12);
}

.membership-selection {
  border: 1px solid #c8d7d5;
  border-radius: 8px;
  background: #f5fbfa;
  color: var(--muted);
  min-height: 46px;
  padding: 12px;
}

.membership-selection strong {
  color: var(--ink);
}

.clock-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  min-height: 96px;
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.clock-status strong {
  display: block;
  font-size: 26px;
}

.clock-status.in {
  background: #e7f5f3;
  border-color: #b7d7d4;
}

.clock-status.out {
  background: var(--surface-soft);
}

.break-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.break-status.active {
  border-color: #f0cc86;
  background: #fff8eb;
  color: #7a4a00;
}

.break-status strong {
  color: var(--ink);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.till-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
  align-items: start;
}

.till-register {
  border-top: 4px solid var(--brand);
}

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

.till-amount-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.till-history {
  min-width: 0;
}

.grid-form.compact-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 16px;
}

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

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 100%;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
  background: #fff;
}

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

th {
  background: #f8faf9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.list-panel {
  display: grid;
  gap: 10px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.report-grid.compact {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.report-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
  padding: 14px;
  min-height: 84px;
}

.report-tile span {
  color: var(--muted);
  font-size: 13px;
}

.report-tile strong {
  display: block;
  font-size: 24px;
  margin-top: 6px;
}

.report-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.segmented-control {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.segmented-control button {
  border: 0;
  border-radius: 0;
  min-height: 36px;
  background: transparent;
}

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

.report-range {
  color: var(--muted);
  margin-bottom: 14px;
}

.report-breakdowns {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 18px;
  padding-top: 18px;
}

.report-breakdowns h3 {
  margin-bottom: 8px;
}

.staff-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 18px;
  align-items: start;
}

.staff-timesheet-panel {
  grid-row: span 2;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.history-item.added {
  border-left-color: var(--teal);
}

.history-item.used {
  border-left-color: var(--brand);
}

.history-item summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
}

.history-item summary::-webkit-details-marker {
  display: none;
}

.history-item summary small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.history-amount {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  padding: 5px 9px;
  white-space: nowrap;
}

.history-item dl {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px 14px;
}

.history-item dl div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px;
}

.history-item dt {
  color: var(--muted);
  font-size: 12px;
}

.history-item dd {
  margin: 0;
}

.history-actions {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  padding: 10px 14px 12px;
}

.summary-box {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.summary-box span {
  color: var(--muted);
  font-size: 13px;
}

.import-box {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  width: min(620px, calc(100vw - 32px));
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(20, 27, 34, 0.42);
}

.dialog-form {
  padding: 20px;
}

.dialog-form header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--sidebar);
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 10;
}

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

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .two-column,
  .dashboard-grid,
  .till-layout,
  .staff-layout,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .staff-timesheet-panel {
    grid-row: auto;
  }

  .till-amount-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 820px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    grid-template-rows: auto auto;
    padding: 14px;
    height: auto;
    overflow: visible;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-list button {
    justify-content: center;
  }

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

  .workspace {
    height: auto;
    overflow: visible;
  }

  .view {
    padding: 16px;
    overflow: visible;
  }

  .split-view {
    grid-template-columns: 1fr;
  }

  .list-column {
    position: static;
    max-height: none;
  }

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

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

  .break-status,
  .insight-grid,
  .till-amount-grid {
    grid-template-columns: 1fr;
  }

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

  .action-box-wide {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .metric-grid,
  .grid-form.compact-form {
    grid-template-columns: 1fr;
  }

  .profile-header {
    flex-direction: column;
  }

  .balance-card {
    text-align: left;
    width: 100%;
  }

  .balance-number {
    font-size: 36px;
  }
}
