:root {
  --bg: #f4f7f6;
  --ink: #15201e;
  --muted: #64706e;
  --line: #dbe5e2;
  --panel: #ffffff;
  --soft: #eef6f3;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --blue: #2563eb;
  --amber: #b45309;
  --rose: #b91c1c;
  --shadow: 0 16px 40px rgba(21, 32, 30, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.10), transparent 34rem),
    radial-gradient(circle at 100% 0%, rgba(180, 83, 9, 0.10), transparent 24rem),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

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

.auth-card {
  width: min(920px, 100%);
  display: grid;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.auth-brand {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.auth-copy h1 {
  margin-bottom: 10px;
}

.auth-copy p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.auth-error {
  padding: 12px 14px;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  background: #fff1f2;
  color: #9f1239;
}

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

.auth-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.auth-demo {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.auth-demo h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

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

.auth-demo-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #e6efec;
  border-radius: 8px;
  background: #fff;
}

.auth-demo-item span,
.auth-hint {
  color: var(--muted);
}

.auth-hint {
  margin: 14px 0 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: #10201d;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #21a196;
  font-weight: 800;
}

.brand small,
.sidebar-foot small {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.62);
}

.role-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.66);
  text-transform: uppercase;
}

.role-select {
  width: 100%;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 0 12px;
}

.role-select option {
  color: var(--ink);
}

.nav {
  display: grid;
  gap: 6px;
  overflow: auto;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  text-align: left;
  font-weight: 650;
}

.nav button.is-active,
.nav button:hover {
  background: #21a196;
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.session-card {
  display: grid;
  gap: 6px;
  padding: 14px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.session-card strong,
.session-card span {
  color: #fff;
}

.session-card small {
  color: rgba(255, 255, 255, 0.66);
}

.session-label {
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 11px;
}

.session-actions {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.session-button,
.session-actions .ghost-action {
  width: 100%;
  justify-content: center;
}

.session-button {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.96);
}

.session-actions .ghost-action {
  background: rgba(255, 255, 255, 0.96);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #31d07d;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.topbar h1 {
  margin: 3px 0 0;
  font-size: 20px;
}

.search {
  margin-left: auto;
  position: relative;
  width: min(420px, 40vw);
}

.search span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 12px;
}

.search input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px 0 62px;
  outline: 0;
  background: #f8fbfa;
}

.content {
  padding: 24px;
}

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

.section-head h2 {
  margin-bottom: 4px;
}

.section-head p,
.sales-head p,
.preview-head p {
  color: var(--muted);
  margin-bottom: 0;
}

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

.mini-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.mini-action.danger {
  border-color: #fecdd3;
  background: #fff1f2;
  color: var(--rose);
}

.primary-action,
.secondary-action,
.ghost-action,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 12px;
  text-decoration: none;
  font-weight: 750;
}

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

.secondary-action,
.ghost-action,
.icon-button {
  background: #fff;
  color: var(--ink);
}

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

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

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

.metric,
.panel,
.product-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--primary);
  font-weight: 900;
}

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

.metric p {
  margin-bottom: 0;
  color: var(--muted);
}

.panel {
  padding: 16px;
}

.chart {
  display: flex;
  align-items: end;
  gap: 10px;
  height: 260px;
  padding-top: 18px;
}

.bar {
  flex: 1;
  min-width: 34px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #21a196, #0f766e);
  position: relative;
}

.bar label {
  position: absolute;
  left: 50%;
  bottom: -26px;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
  gap: 14px;
}

.low-stock,
.stack {
  display: grid;
  gap: 10px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #edf2ef;
  border-radius: 8px;
  background: #f9fbfa;
}

.list-item img,
.product-card img,
.table-product img {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
}

.list-item strong {
  display: block;
}

.muted-copy {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef2f7;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.pill.ok {
  background: #ecfdf5;
  color: #047857;
}

.pill.warn {
  background: #fffbeb;
  color: #b45309;
}

.pill.bad {
  background: #fff1f2;
  color: #be123c;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid #eef2f1;
  text-align: left;
  white-space: nowrap;
}

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

.table-product {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.row-actions form {
  margin: 0;
}

.pos-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 420px;
  gap: 14px;
}

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

.product-card {
  padding: 12px;
  text-align: left;
}

.product-card img {
  width: 100%;
  height: 92px;
}

.product-card strong {
  display: block;
  min-height: 40px;
  margin-top: 10px;
}

.product-card p,
.product-card small {
  margin-bottom: 0;
}

.cart-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px 110px;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid #edf2ef;
  border-radius: 8px;
  background: #f9fbfa;
}

.cart-line input,
.field,
.cart-select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.field:focus,
.cart-select:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.field-label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.sales-head,
.preview-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.customer-form {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfefd, #f5faf8);
}

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

.full-width {
  grid-column: 1 / -1;
}

.totals {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f7faf9;
}

.totals div {
  display: flex;
  justify-content: space-between;
}

.totals .totals-field {
  width: 180px;
  height: 38px;
}

.totals-final {
  padding-top: 6px;
  border-top: 1px solid var(--line);
  align-items: center;
}

.totals strong {
  font-size: 18px;
  color: var(--primary);
}

.preview-panel {
  margin-top: 14px;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.04), transparent 120px),
    #ffffff;
}

.viewer-panel {
  margin-top: 0;
}

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

.modal-card,
.viewer-card {
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.viewer-card {
  width: min(1040px, 100%);
  padding: 18px;
}

.modal-head,
.modal-foot,
.modal-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.modal-body {
  padding: 18px 20px;
}

.modal-foot {
  position: sticky;
  bottom: 0;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.modal-line-break {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}

.modal-subhead {
  margin-bottom: 12px;
}

.modal-subhead h4 {
  margin-bottom: 0;
}

.order-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 100px;
  gap: 10px;
  align-items: center;
}

.invoice-card {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

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

.invoice-top small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.invoice-meta {
  display: grid;
  gap: 6px;
  text-align: right;
  color: var(--muted);
  font-size: 13px;
}

.invoice-meta b {
  color: var(--ink);
}

.invoice-customer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #f7faf9;
}

.invoice-customer span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.invoice-customer strong {
  display: block;
}

.invoice-table {
  margin-top: 14px;
}

.invoice-table table {
  min-width: 100%;
}

.invoice-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.invoice-summary {
  width: min(320px, 100%);
  margin-left: auto;
  margin-top: 14px;
}

.invoice-summary div {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
}

.invoice-summary .grand {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 2px solid var(--ink);
}

.invoice-summary .grand strong {
  font-size: 20px;
}

.alert {
  margin: 16px 24px 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.alert.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.hidden {
  display: none !important;
}

.install-page {
  min-height: 100vh;
}

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

.install-panel {
  width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 28px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  padding: 12px;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
}

.status-line span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #f59e0b;
}

.status-line.is-ok {
  background: #f0fdf4;
  color: #166534;
}

.status-line.is-ok span {
  background: #22c55e;
}

.notice {
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 8px;
}

.notice.success {
  background: #f0fdf4;
  color: #166534;
}

.notice.danger {
  background: #fff1f2;
  color: #be123c;
}

code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95em;
}

.mobile-only {
  display: none;
}

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

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

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

@media (max-width: 760px) {
  .auth-card {
    padding: 20px;
  }

  .auth-demo-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    z-index: 10;
  }

  .sidebar.is-open {
    display: flex;
  }

  .mobile-only {
    display: inline-flex;
  }

  .topbar {
    gap: 10px;
    padding: 12px;
  }

  .search {
    display: none;
  }

  .content {
    padding: 14px;
  }

  .grid-4,
  .grid-3,
  .grid-2,
  .product-grid,
  .customer-grid,
  .invoice-customer {
    grid-template-columns: 1fr;
  }

  .invoice-top,
  .preview-head,
  .sales-head,
  .modal-head,
  .modal-foot,
  .modal-subhead {
    flex-direction: column;
  }

  .invoice-meta {
    text-align: left;
  }

  .order-item-row {
    grid-template-columns: 1fr;
  }

  .modal-card,
  .viewer-card {
    width: 100%;
  }
}
