html {
  font-size: 15px;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #f4f6f3;
  color: #17211c;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

.app-shell {
  display: flex;
}

.app-sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: 280px;
  padding: 18px;
  background: #17211c;
  color: #fff;
  overflow-y: auto;
}

.sidebar-toggle,
.sidebar-close,
.sidebar-backdrop {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  padding: 10px 8px 20px;
}

.brand small {
  display: block;
  color: #a9b8af;
  margin-top: 4px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f5a524;
  color: #1d1d1b;
  font-weight: 800;
}

.side-nav {
  display: grid;
  gap: 4px;
}

.side-nav__home {
  color: #dfe8e2;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 800;
}

/* Groups collapse with <details>, so the markers below replace the browser's default triangle. */
.side-nav__group {
  border-radius: 10px;
}

.side-nav__group[open] {
  background: rgba(255, 255, 255, 0.03);
  padding-bottom: 6px;
}

.side-nav__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  padding: 10px 12px;
  border-radius: 8px;
  color: #a9bcb1;
  font-size: 0.82rem;
  font-weight: 800;
  user-select: none;
}

.side-nav__summary::-webkit-details-marker {
  display: none;
}

.side-nav__summary:hover,
.side-nav__summary:focus-visible {
  background: #26352e;
  color: #fff;
}

.side-nav__chevron {
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  padding: 3px;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  opacity: 0.7;
}

.side-nav__group[open] .side-nav__chevron {
  transform: rotate(-135deg);
}

/* The daily action, sitting directly under its group heading. */
.side-nav__quick {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 8px 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(31, 185, 120, 0.14);
  border: 1px solid rgba(31, 185, 120, 0.32);
  color: #7ce0b0;
  font-weight: 800;
  font-size: 0.85rem;
  text-decoration: none;
}

.side-nav__quick:hover,
.side-nav__quick:focus {
  background: rgba(31, 185, 120, 0.24);
  color: #fff;
}

.side-nav__quick-plus {
  font-size: 1.05rem;
  line-height: 1;
}

.side-nav__links {
  display: grid;
  gap: 3px;
  padding: 0 6px;
}

.side-nav a {
  color: #dfe8e2;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.9rem;
}

.side-nav__links a {
  padding-inline-start: 20px;
}

.side-nav a:hover,
.side-nav a:focus,
.side-nav a.active {
  background: #26352e;
  color: #fff;
}

.side-nav a.active {
  border-color: rgba(95, 191, 147, 0.32);
  box-shadow: inset 4px 0 0 #1fb978;
}

/* A group containing the current page stays visibly marked even while collapsed. */
.side-nav__group:has(a.active) > .side-nav__summary {
  color: #fff;
}

.side-nav-plan {
  margin: 14px 10px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 2px;
}

.side-nav-plan__label {
  color: #8da094;
  font-size: 0.72rem;
  font-weight: 700;
}

.side-nav-plan__name {
  color: #fff;
  font-size: 0.95rem;
}

.side-nav-plan__link {
  color: #7ce0b0;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

.app-main {
  min-height: 100vh;
  width: 100%;
  margin-inline-start: 280px;
}

.auth-main {
  margin-inline-start: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid #dde5df;
  backdrop-filter: blur(10px);
}

.topbar span {
  display: block;
  color: #66746c;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.content {
  padding: 26px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 20px;
}

.page-header h1,
.panel h1 {
  margin: 0 0 6px;
  font-size: 1.8rem;
  font-weight: 800;
}

.page-header p,
.login-brand p,
.panel p {
  margin: 0;
  color: #67756d;
}

.filters {
  display: flex;
  gap: 10px;
  align-items: center;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel,
.login-panel {
  background: #fff;
  border: 1px solid #dde5df;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(23, 33, 28, 0.06);
}

.metric-card {
  padding: 16px;
  border-inline-start-width: 5px;
}

.metric-card span,
.metric-card small {
  display: block;
  color: #64736b;
}

.metric-card strong {
  display: block;
  margin: 8px 0;
  font-size: 1.7rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-grid > div {
  min-height: 72px;
  padding: 14px;
  border: 1px solid #dbe5df;
  border-radius: 8px;
  background: #f8faf8;
}

.summary-grid span {
  display: block;
  color: #64736b;
  font-size: 0.86rem;
}

.summary-grid strong {
  display: block;
  margin-top: 6px;
  color: #17211c;
  font-size: 1.15rem;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.table {
  margin-bottom: 0;
}

.table tbody tr:hover {
  background: #fbfcfb;
}

.table thead th {
  color: #55625b;
  background: #f6f8f6;
  font-weight: 700;
}

.empty-cell {
  color: #79877f;
  text-align: center;
  padding: 24px !important;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #e9f6ef;
  color: #17683b !important;
  font-weight: 700;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 430px);
  padding: 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
}

.login-form {
  display: grid;
  gap: 10px;
}

.narrow-panel {
  max-width: 620px;
}

.pos-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  min-height: calc(100vh - 120px);
}

.pos-sale,
.pos-summary {
  background: #fff;
  border: 1px solid #dde5df;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(23, 33, 28, 0.06);
}

.pos-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(180px, 1fr) minmax(150px, .7fr);
  gap: 10px;
  margin-bottom: 12px;
}

.search-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.pos-status {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f6f8f6;
  color: #56625c;
  font-weight: 700;
}

.pos-status.success {
  background: #e9f6ef;
  color: #17683b;
}

.pos-status.warning {
  background: #fff5df;
  color: #8a5b00;
}

.pos-status.danger {
  background: #fdeaea;
  color: #9d1c1c;
}

.search-item {
  min-height: 88px;
  padding: 12px;
  text-align: start;
  border: 1px solid #dbe5df;
  border-radius: 8px;
  background: #f9fbf9;
}

.search-item span,
.search-item small {
  display: block;
}

.search-item strong {
  display: block;
  margin: 4px 0;
  color: #17683b;
}

.search-empty {
  padding: 12px;
  color: #7b877f;
  background: #f7f8f7;
  border-radius: 8px;
}

.pos-cart-table td strong,
.pos-cart-table td small {
  display: block;
}

.qty-input {
  width: 110px;
}

.pos-summary {
  display: grid;
  align-content: start;
  gap: 12px;
}

.summary-line,
.summary-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  background: #f6f8f6;
}

.summary-total {
  background: #17211c;
  color: #fff;
}

.summary-total strong {
  font-size: 2rem;
}

.payment-actions {
  display: grid;
  gap: 10px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.module-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 86px;
  padding: 14px;
  border: 1px solid #dbe5df;
  border-radius: 8px;
  background: #f9fbf9;
  color: #17211c;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
}

.module-tile:hover {
  border-color: #17683b;
  color: #17683b;
}

.module-tile.muted {
  color: #68756e;
}

.list-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.wide-toolbar {
  grid-template-columns: minmax(220px, 1fr) 180px 160px 160px auto;
}

.editor-form {
  display: grid;
  gap: 18px;
}

.procurement-section {
  margin-bottom: 18px;
}

.procurement-actions,
.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.reject-form {
  display: grid;
  grid-template-columns: minmax(130px, 190px) auto;
  gap: 6px;
}

.procurement-lines {
  display: grid;
  gap: 10px;
}

.procurement-line {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(120px, 0.7fr) minmax(180px, 1.2fr) auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid #dbe5df;
  border-radius: 8px;
  background: #f8faf8;
}

.compact-number {
  min-width: 120px;
  max-width: 180px;
}

.count-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, .5fr) minmax(220px, 1fr);
  gap: 10px;
}

.count-table-wrap {
  max-height: 65vh;
  border: 1px solid #dde5df;
}

.count-table-wrap thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.batch-grid {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 145px 145px;
  gap: 6px;
  min-width: 430px;
}

.simple-line {
  grid-template-columns: minmax(260px, 2fr) minmax(140px, .7fr) auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.span-2 {
  grid-column: span 2;
}

.checks-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 12px;
  border: 1px solid #dde5df;
  border-radius: 8px;
  background: #f9fbf9;
}

.readonly-box,
.json-box {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #dbe5df;
  border-radius: 8px;
  background: #f8faf8;
  color: #26352e;
}

.json-box {
  max-height: 320px;
  overflow: auto;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
}

.form-actions,
.pager-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.actions-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.actions-row form {
  margin: 0;
}

.color-swatch {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-inline-end: .35rem;
  vertical-align: middle;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.permission-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.permission-group h2 {
  font-size: 1rem;
  margin: 0 0 12px;
}

.permission-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.permission-check small,
.permission-check code {
  display: block;
  color: var(--muted);
}

.danger-panel {
  border-color: #f1b9b9;
}

.table td small {
  display: block;
  color: #68756e;
}

.btn-primary {
  --bs-btn-bg: #17683b;
  --bs-btn-border-color: #17683b;
  --bs-btn-hover-bg: #125731;
  --bs-btn-hover-border-color: #125731;
}

.form-control:focus,
.form-check-input:focus,
.btn:focus {
  box-shadow: 0 0 0 0.2rem rgba(23, 104, 59, 0.2);
}

.notification-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
}

.notification-list {
  display: grid;
  gap: 10px;
}

.notification-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-inline-start: 4px solid #9aa8a0;
  border-radius: 8px;
  background: #fff;
}

.notification-item.is-unread {
  border-inline-start-color: #17683b;
  background: #f6fbf8;
}

.notification-item-head,
.notification-item-actions,
.device-status-panel,
.device-status-list,
.device-token-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.api-scope-fieldset {
  border: 1px solid var(--border);
  padding: 1rem;
}

.api-scope-fieldset legend {
  float: none;
  width: auto;
  margin: 0;
  padding: 0 .35rem;
  font-size: .9rem;
  font-weight: 700;
}

.api-scope-fieldset .form-check {
  min-width: min(100%, 18rem);
}

.notification-item-head,
.device-status-panel {
  justify-content: space-between;
}

.notification-item-head > div,
.notification-item-actions,
.device-token-actions {
  flex-wrap: wrap;
}

.notification-item p {
  margin: 10px 0;
}

.notification-item time,
.notification-item-actions .text-muted {
  color: var(--muted);
  font-size: .875rem;
}

.bridge-token {
  margin-top: 8px;
  padding: 10px;
  overflow-wrap: anywhere;
  border: 1px solid #e0b85f;
  border-radius: 6px;
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  user-select: all;
}

.device-status-panel h2 {
  font-size: 1rem;
  margin: 0 0 8px;
}

@media (max-width: 1100px) {
  .metrics-grid,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .app-shell {
    display: block;
  }

  .app-sidebar {
    position: fixed;
    z-index: 50;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(320px, 88vw);
    max-height: 100vh;
    transform: translateX(105%);
    transition: transform 180ms ease;
    box-shadow: -18px 0 42px rgba(11, 21, 16, 0.24);
  }

  .sidebar-open {
    overflow: hidden;
  }

  .sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .sidebar-toggle,
  .sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    padding: 0;
    border: 1px solid #cdd8d1;
    border-radius: 6px;
    background: #fff;
    color: #17211c;
    font-size: 1.4rem;
    line-height: 1;
  }

  .sidebar-close {
    position: absolute;
    z-index: 1;
    inset-block-start: 14px;
    inset-inline-end: 14px;
    border-color: rgba(255, 255, 255, 0.28);
    background: #26352e;
    color: #fff;
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 45;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(9, 17, 13, 0.48);
  }

  .sidebar-backdrop:not([hidden]) {
    display: block;
  }

  .brand {
    padding-inline-end: 54px;
  }

  .app-main {
    margin-inline-start: 0;
  }

  .topbar,
  .page-header,
  .filters,
  .list-toolbar,
  .form-grid,
  .notification-item-head,
  .device-status-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding: 12px 16px;
  }

  .topbar-heading {
    align-items: center;
  }

  .topbar-actions {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .content {
    padding: 18px 16px;
  }

  .list-toolbar,
  .wide-toolbar,
  .form-grid,
  .procurement-line,
  .pos-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .pos-screen,
  .pos-sale,
  .pos-summary,
  .pos-toolbar > * {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .pos-sale .table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
  }

  .reject-form {
    grid-template-columns: 1fr auto;
    width: 100%;
  }

  .count-toolbar,
  .batch-grid,
  .simple-line {
    grid-template-columns: 1fr;
  }

  .batch-grid {
    min-width: 260px;
  }

  .span-2 {
    grid-column: auto;
  }

  .metrics-grid,
  .dashboard-grid,
  .summary-grid,
  .module-grid,
  .pos-screen {
    grid-template-columns: 1fr;
  }

  .search-results {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar {
    transition: none;
  }
}
