:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
  color: #17212b;
  background: #f3f5f7;
  font-synthesis: none;
  --surface-ground: #f3f5f7;
  --surface-card: #ffffff;
  --surface-soft: #f8fafb;
  --border-soft: #dfe4ea;
  --border-strong: #cbd3dc;
  --text-main: #17212b;
  --text-muted: #66727f;
  --brand-dark: #18232d;
  --accent: #059669;
  --accent-dark: #047857;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  background: var(--surface-ground);
}

button,
input {
  font: inherit;
}

button:focus-visible,
input:focus-visible {
  outline-offset: 2px;
}

h1,
p {
  margin-top: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  border-radius: 6px;
  color: #ffffff;
  background: var(--brand-dark);
}

.brand-mark .pi {
  font-size: 0.95rem;
}

.brand-copy {
  display: grid;
  line-height: 1.1;
}

.brand-copy strong {
  color: var(--text-main);
  font-size: 0.98rem;
  font-weight: 750;
}

.brand-copy small {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
}

/* Auth */
.auth-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) 48px;
  overflow: auto;
  background:
    linear-gradient(90deg, rgb(5 150 105 / 4%) 1px, transparent 1px),
    linear-gradient(rgb(5 150 105 / 4%) 1px, transparent 1px),
    #f1f4f6;
  background-size: 28px 28px;
}

.auth-brandbar {
  display: flex;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--border-soft);
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(12px);
}

.auth-panel {
  align-self: center;
  justify-self: center;
  width: min(calc(100% - 32px), 440px);
  padding: 32px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 20px 50px rgb(24 35 45 / 10%);
}

.auth-heading {
  margin-bottom: 26px;
  text-align: center;
}

.auth-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  color: var(--accent-dark);
  background: #ecfdf5;
}

.auth-kicker,
.page-kicker {
  margin-bottom: 7px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-heading h1 {
  margin-bottom: 8px;
  color: var(--text-main);
  font-size: 1.55rem;
  font-weight: 760;
  letter-spacing: 0;
}

.auth-heading > p:last-child {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.auth-footer {
  align-self: center;
  justify-self: center;
  color: #788490;
  font-size: 0.76rem;
}

.form-grid,
.record-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: #35414d;
  font-size: 0.84rem;
  font-weight: 680;
}

.auth-panel .p-inputtext,
.auth-panel .p-password,
.auth-panel .p-password-input {
  width: 100%;
}

.auth-panel .p-inputtext {
  min-height: 42px;
}

.auth-panel .p-button {
  min-height: 42px;
  margin-top: 2px;
}

/* Application shell */
.app-shell {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-ground);
}

.app-header {
  z-index: 10;
  flex: 0 0 64px;
  display: grid;
  grid-template-columns: minmax(210px, auto) 1fr auto;
  align-items: center;
  gap: 26px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-soft);
  background: #ffffff;
  box-shadow: 0 1px 2px rgb(24 35 45 / 4%);
}

.primary-nav {
  align-self: stretch;
  display: flex;
  align-items: stretch;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 680;
}

.nav-item.active {
  color: var(--text-main);
}

.nav-item.active::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 0;
  left: 12px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}

.nav-item .pi {
  color: var(--accent-dark);
  font-size: 0.9rem;
}

.account-area {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  border-radius: 50%;
  color: #065f46;
  background: #d1fae5;
  font-size: 0.8rem;
  font-weight: 800;
}

.user-meta {
  display: grid;
  min-width: 0;
  line-height: 1.1;
}

.user-meta strong {
  max-width: 170px;
  overflow: hidden;
  color: var(--text-main);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta small {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.workspace {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 24px 22px;
}

.page-header {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.page-header h1 {
  margin-bottom: 3px;
  color: var(--text-main);
  font-size: 1.45rem;
  font-weight: 760;
  letter-spacing: 0;
}

.page-kicker {
  margin-bottom: 5px;
}

.page-meta {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.page-actions,
.row-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-actions .p-button {
  min-height: 38px;
}

.table-surface {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 4px 16px rgb(24 35 45 / 5%);
}

.records-table {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
}

.records-table .p-datatable-header {
  padding: 10px 12px;
  border-width: 0 0 1px;
  background: #ffffff;
}

.records-table .p-datatable-thead > tr > th {
  padding: 11px 9px;
  color: #34414e;
  border-color: #dbe2e9;
  background: #f8fafb;
  font-size: 0.78rem;
  font-weight: 760;
}

.records-table .p-datatable-tbody > tr > td {
  padding: 10px 9px;
  color: #253442;
  border-color: #dfe5eb;
  font-size: 0.8rem;
  transition: background-color 120ms ease;
}

.records-table.p-datatable-striped .p-datatable-tbody > tr.p-row-even > td {
  background: #ffffff;
}

.records-table.p-datatable-striped .p-datatable-tbody > tr.p-row-odd > td {
  background: #edf4fa;
}

.records-table .p-datatable-tbody > tr:hover > td {
  background: #dceaf5;
}

.records-table .p-datatable-tfoot {
  position: sticky;
  bottom: 0;
  z-index: 3;
}

.records-table .p-datatable-tfoot > tr > td {
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding: 10px 9px;
  color: #17212b;
  border-color: #c9d3dd;
  border-top: 2px solid #aab9c7;
  background: #e8eef4;
  box-shadow: 0 -2px 7px rgb(24 35 45 / 8%);
  font-size: 0.8rem;
  white-space: nowrap;
}

.table-toolbar {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.table-count {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #465360;
  font-size: 0.8rem;
  font-weight: 720;
}

.table-count .pi {
  color: var(--accent-dark);
  font-size: 0.78rem;
}

.column-filter {
  width: 100%;
  min-width: 0;
}

.row-actions {
  justify-content: center;
}

.row-actions .p-button {
  width: 30px;
  height: 30px;
}

.record-dialog {
  width: min(96vw, 860px);
}

.bulk-dialog {
  width: min(96vw, 420px);
}

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

.product-cell {
  display: grid;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  white-space: normal;
  overflow-wrap: anywhere;
}

.product-cell > span {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.product-pricing-head,
.product-pricing-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(90px, 1fr) minmax(120px, 1.2fr) minmax(100px, 1fr);
  gap: 12px;
  align-items: center;
}

.product-pricing-head {
  padding: 0 0 10px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.product-pricing-row {
  padding: 10px 0;
  border-top: 1px solid var(--border-soft);
}

.product-name {
  font-size: 0.85rem;
}

.product-pricing-row label,
.product-pricing-row .p-inputnumber,
.product-pricing-row .p-inputnumber-input {
  min-width: 0;
  width: 100%;
}

.mobile-field-label {
  display: none;
}

.line-amount,
.product-pricing-head > :last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.record-grand-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 0;
  border-block: 1px solid var(--border-strong);
  color: var(--text-main);
  font-weight: 750;
}

.record-grand-total output {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.wide {
  grid-column: 1 / -1;
}

.dialog-actions {
  justify-content: flex-end;
  width: 100%;
}

.p-dialog {
  border-radius: 8px;
}

.p-dialog .p-dialog-header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}

.p-dialog .p-dialog-content {
  padding-top: 20px;
}

.p-dialog .p-dialog-footer {
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

@media (max-width: 760px) {
  .app-header {
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 0 14px;
  }

  .app-header .brand-copy small,
  .user-meta {
    display: none;
  }

  .primary-nav {
    display: none;
  }

  .workspace {
    gap: 12px;
    padding: 14px 10px 10px;
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .page-actions {
    display: flex;
    width: 100%;
  }

  .page-actions .p-button {
    flex: 0 0 42px;
    width: 42px;
    min-width: 0;
  }

  .page-actions .p-button:first-child {
    padding-inline: 0;
  }

  .page-actions .p-button:not(:last-child) .p-button-label {
    display: none;
  }

  .page-actions .p-button:last-child {
    flex: 1 1 auto;
    width: auto;
  }

  .page-actions .p-button:last-child .p-button-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .records-table {
    font-size: 0.82rem;
  }

  .table-toolbar {
    min-width: 0;
  }

  .table-toolbar .p-button {
    min-width: 0;
  }

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

  .product-pricing-head {
    display: none;
  }

  .product-pricing-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-block: 14px;
  }

  .product-name,
  .line-amount {
    grid-column: 1 / -1;
  }

  .mobile-field-label {
    display: inline;
  }

  .auth-brandbar {
    padding: 0 18px;
  }

  .auth-panel {
    padding: 26px 22px;
  }
}

@media (max-width: 480px) {
  .brand-copy strong {
    font-size: 0.9rem;
  }

  .auth-heading h1 {
    font-size: 1.35rem;
  }
}

/* Native PHP views use the same visual tokens without a component runtime. */
[hidden] { display: none !important; }
button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
input, select { width: 100%; min-width: 0; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 5px; background: #fff; color: var(--text-main); }
input:focus, select:focus { outline: 2px solid #6ee7b7; outline-offset: 1px; }
.btn, .icon-btn, .sort-btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 1px solid var(--border-soft); border-radius: 5px; color: #475569; background: #fff; }
.btn { min-height: 38px; padding: 8px 12px; font-size: .84rem; font-weight: 600; white-space: nowrap; }
.btn:hover, .icon-btn:hover { background: #edf4fa; }
.btn.primary { color: #fff; border-color: var(--accent); background: var(--accent); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: #dc2626; border-color: #fecaca; }
.btn.danger-fill { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.text { border-color: transparent; background: transparent; color: var(--accent-dark); }
.icon-btn { width: 32px; height: 32px; flex: 0 0 32px; padding: 0; background: transparent; border-color: transparent; }
.icon-only { width: 40px; padding: 0; }
.password-field { position: relative; display: flex; align-items: center; }
.password-field input { padding-right: 40px; }
.password-field .icon-btn { position: absolute; right: 4px; }
.muted { color: var(--text-muted); font-weight: 400; line-height: 1.6; }
.form-error, .warning { margin: 0; padding: 10px 12px; font-size: .83rem; line-height: 1.5; border-radius: 4px; overflow-wrap: anywhere; }
.form-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.warning { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.table-surface { display: flex; flex-direction: column; position: relative; }
.table-toolbar { padding: 8px 12px; flex: 0 0 auto; border-bottom: 1px solid var(--border-soft); }
.table-scroll { flex: 1 1 0; height: 0; min-height: 0; overflow: auto; }
#sales-table { width: 100%; height: 100%; min-width: 1380px; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: .8rem; }
#sales-table tbody tr, #sales-table thead, #sales-table tfoot { height: 1px; }
#sales-table tbody::after { content: ''; display: table-row; height: 100%; }
.date-col { width: 150px; } .customer-col { width: 155px; } .product-col { width: 115px; } .total-col { width: 130px; } .owner-col { width: 135px; } .actions-col { width: 80px; }
#sales-table th, #sales-table td { padding: 10px 8px; border-right: 1px solid #dfe5eb; border-bottom: 1px solid #dfe5eb; text-align: left; overflow-wrap: anywhere; }
#sales-table thead th { position: sticky; top: 0; z-index: 2; background: #f8fafb; color: #34414e; font-size: .78rem; }
#sales-table tbody tr:nth-child(odd) td { background: #fff; }
#sales-table tbody tr:nth-child(even) td { background: #edf4fa; }
#sales-table tbody tr:hover td { background: #dceaf5; }
#sales-table tfoot th, #sales-table tfoot td { position: sticky; bottom: 0; z-index: 3; background: #e8eef4; border-top: 2px solid #aab9c7; box-shadow: 0 -2px 5px #18232d12; font-weight: 700; }
.column-heading { display: flex; gap: 4px; align-items: center; justify-content: space-between; min-height: 32px; }
.sort-btn { border: 0; padding: 0; background: transparent; font-weight: 700; font-size: inherit; text-align: left; }
.sort-btn i { font-size: .7rem; color: #789; }
.filter-btn.active { background: #d1fae5; color: #047857; }
.table-message { text-align: center !important; padding: 36px !important; color: var(--text-muted); }
.table-state { position: absolute; top: 52px; right: 12px; z-index: 4; padding: 8px 12px; background: #fff; color: #047857; border: 1px solid #a7f3d0; border-radius: 4px; font-size: .8rem; }
.row-actions { gap: 2px; }
.row-actions button:first-child { color: #059669; } .row-actions button:last-child { color: #dc2626; }
dialog { padding: 0; max-width: calc(100vw - 24px); max-height: calc(100dvh - 32px); border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text-main); background: white; box-shadow: 0 20px 80px #18232d30; }
dialog::backdrop { background: #17212b66; }
dialog > form { display: flex; flex-direction: column; max-height: calc(100dvh - 34px); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0; }
.dialog-header h2 { margin: 0; font-size: 1.05rem; }
.dialog-body { padding: 20px; overflow: auto; min-height: 0; }
.dialog-actions { padding: 14px 20px; border-top: 1px solid var(--border-soft); flex-shrink: 0; }
.filter-dialog { width: 330px; margin: 0; position: fixed; }
.filter-rule { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--border-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
#toasts { position: fixed; top: 14px; right: 14px; z-index: 30; display: grid; gap: 8px; width: min(360px, calc(100vw - 28px)); pointer-events: none; }
.toast { background: #fff; border: 1px solid #a7f3d0; border-left: 4px solid #059669; padding: 14px; box-shadow: 0 4px 24px #17212b20; border-radius: 5px; font-size: .85rem; overflow-wrap: anywhere; }
.toast.error { border-color: #fecaca; border-left-color: #dc2626; }
@media (max-width: 760px) {
  .page-actions .btn { flex: 0 0 40px; width: 40px; padding: 0; }
  .page-actions .btn span { display: none; }
  .page-actions .btn:last-child { flex: 1; width: auto; padding: 8px; }
  .page-actions .btn:last-child span { display: inline; }
  .table-toolbar { gap: 4px; padding: 6px 8px; }
  .table-toolbar .btn { font-size: .72rem; padding: 6px; gap: 4px; }
  .table-count { font-size: .74rem; gap: 5px; }
  .dialog-body, .dialog-header, .dialog-actions { padding: 14px; }
}
