:root {
  --ink: #102033;
  --muted: #64748b;
  --paper: #eef3f7;
  --panel: #ffffff;
  --line: #d9e2ea;
  --accent: #0f766e;
  --accent-dark: #0b4f4a;
  --accent-soft: #d9f2ee;
  --accent-2: #b45309;
  --danger-soft: #fee2e2;
}

body {
  background:
    linear-gradient(90deg, rgba(16, 32, 51, .035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(16, 32, 51, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  color: #1f2937;
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

.app-frame {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0c1f2d 0%, #07131d 100%);
  color: white;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand-mark small,
td small {
  display: block;
  color: #8d99ae;
}

.brand-dot {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 8px;
  box-shadow: inset -8px -8px 0 rgba(0,0,0,.18);
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar a {
  color: #dbe4ea;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.sidebar a:hover,
.sidebar a.active {
  background: rgba(15, 118, 110, .22);
  border-color: rgba(94, 234, 212, .24);
  color: white;
}

.content {
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.topbar h1 {
  color: var(--ink);
  font-size: 28px;
  font-weight: 800;
  margin: 0;
}

.date-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
}

.panel,
.metric,
.login-card,
.ticket {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .08);
}

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

.panel-head,
.action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.panel h2 {
  font-size: 18px;
  margin: 0 0 12px;
  color: var(--ink);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric {
  padding: 18px;
  border-left: 5px solid var(--accent);
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 90px;
  height: 90px;
  border: 14px solid rgba(15, 118, 110, .08);
  border-radius: 50%;
}

.metric.warning {
  border-left-color: var(--accent-2);
}

.metric span {
  color: var(--muted);
  display: block;
}

.metric strong {
  color: var(--ink);
  font-size: 30px;
}

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

.filter-row .form-control,
.filter-row .form-select {
  width: 190px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.table tbody tr {
  border-color: var(--line);
}

.table tbody tr:hover {
  background: #f8fbfd;
}

.btn {
  border-radius: 7px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}

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

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .16);
}

.detail-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.detail-head,
.detail-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 48px;
  gap: 8px;
  padding: 10px;
  align-items: center;
}

.detail-head {
  background: #e7eef4;
  color: #5f6368;
  font-size: 12px;
  text-transform: uppercase;
}

.detail-row + .detail-row {
  border-top: 1px solid var(--line);
}

.login-shell {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,.04) 1px, transparent 1px),
    #0e171d;
  background-size: 46px 46px;
}

.login-panel {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 440px;
  align-items: center;
  gap: 54px;
  padding: clamp(24px, 5vw, 70px);
  position: relative;
  overflow: hidden;
}

.pam-login::before {
  content: "";
  position: absolute;
  inset: 28px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 8px;
  pointer-events: none;
}

.login-copy {
  color: white;
  max-width: 760px;
  position: relative;
  z-index: 1;
}

.login-copy h1 {
  font-size: clamp(52px, 8vw, 112px);
  line-height: .86;
  font-weight: 900;
  margin: 18px 0 22px;
  letter-spacing: 0;
}

.eyebrow {
  color: #f59e0b;
  text-transform: uppercase;
  letter-spacing: 2px;
}


.login-card-wrap {
  position: relative;
  z-index: 1;
}

.login-card {
  padding: 30px;
  background: #fffdf8;
  border-color: rgba(255,255,255,.24);
  box-shadow: 0 28px 70px rgba(0,0,0,.32);
}

.login-card-head {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.login-card-head h2 {
  margin: 0;
  color: var(--ink);
  font-weight: 900;
}

.login-card-head p {
  margin: 0;
  color: #69727d;
}

.login-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #101820;
  color: #5eead4;
  font-size: 24px;
}

.input-with-icon {
  position: relative;
}

.input-with-icon i {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #69727d;
}

.input-with-icon .form-control {
  padding-left: 40px;
  min-height: 48px;
}

.ticket-wrap {
  max-width: 820px;
  margin: auto;
}

.ticket {
  padding: 28px;
}

.ticket header {
  text-align: center;
  border-bottom: 1px dashed #999;
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.ticket img {
  max-height: 70px;
  object-fit: contain;
}

.ticket-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.ticket footer {
  display: flex;
  justify-content: space-between;
  font-size: 24px;
  border-top: 2px solid #222;
  padding-top: 12px;
}

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

.report-number {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
}

.detail-hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  background: #14213d;
  color: white;
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: 0 16px 30px rgba(20, 33, 61, .16);
}

.sale-hero {
  background: #12302f;
}

.detail-hero h2 {
  margin: 4px 0;
  font-size: 28px;
  font-weight: 900;
}

.detail-hero p {
  margin: 0;
  color: #dbe4ea;
}

.eyebrow-dark {
  color: #f59e0b;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1px;
  font-weight: 800;
}

.detail-total {
  min-width: 220px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  align-content: center;
  text-align: right;
}

.detail-total span {
  color: #dbe4ea;
}

.detail-total strong {
  font-size: 30px;
}

.audit-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.audit-strip span {
  background: #ebe6dc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
}

.product-finder {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6fafc;
  margin-bottom: 16px;
  overflow: hidden;
}

.finder-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.finder-head h2 {
  font-size: 18px;
  margin: 0;
  color: var(--ink);
}

.finder-head p {
  margin: 2px 0 0;
  color: #69727d;
}

.finder-search {
  position: relative;
  min-width: 300px;
}

.finder-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #69727d;
}

.finder-search .form-control {
  padding-left: 38px;
}

.finder-list {
  display: grid;
  grid-template-columns: 1fr;
  max-height: 280px;
  overflow: auto;
}

.finder-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 160px 160px;
  gap: 12px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  padding: 12px 14px;
  color: #111827;
  cursor: pointer;
  font-family: inherit;
}

.finder-item:hover {
  background: #ffffff;
}

.finder-item:focus {
  outline: 3px solid rgba(15, 118, 110, .2);
  outline-offset: -3px;
}

.finder-item strong,
.finder-item small {
  display: block;
}

.finder-price {
  text-align: right;
}

.finder-price b {
  color: var(--accent);
  font-size: 18px;
}

.badge.text-bg-danger {
  background: #b42318 !important;
}

.auto-refresh-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #f8fbfd;
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
}

.auto-refresh-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, .12);
}

.finder-price.muted b {
  color: #69727d;
}

.purchase-shell {
  display: grid;
  gap: 16px;
}

.purchase-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: stretch;
  background: #12302f;
  color: white;
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 16px 30px rgba(15, 23, 42, .14);
}

.purchase-hero h2 {
  margin: 4px 0;
  font-size: 30px;
  font-weight: 900;
}

.purchase-hero p {
  margin: 0;
  color: #dbe4ea;
}

.purchase-hero-total {
  min-width: 220px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  align-content: center;
  text-align: right;
}

.purchase-hero-total span {
  color: #dbe4ea;
}

.purchase-hero-total strong {
  font-size: 30px;
}

.purchase-context {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 240px;
  gap: 16px;
  margin-bottom: 0;
}

.purchase-field {
  min-width: 0;
}

.purchase-finder {
  margin-bottom: 0;
}

.purchase-lines {
  margin-bottom: 0;
}

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

.purchase-section-head h2 {
  margin: 0;
}

.purchase-section-head p {
  margin: 2px 0 0;
  color: #69727d;
}

.row-highlight {
  animation: rowPulse .8s ease;
}

.sale-summary {
  margin-top: 16px;
  border: 1px solid #111827;
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #101820;
  color: white;
}

.summary-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.summary-head span {
  color: #dbe4ea;
}

.summary-table {
  margin: 0;
}

.summary-table thead th {
  background: #050505;
  color: white;
  font-size: 14px;
  letter-spacing: 1px;
  text-align: center;
  white-space: nowrap;
}

.summary-table td,
.summary-table th {
  border: 2px solid #1f2937;
}

.summary-table tfoot td {
  font-size: 20px;
  font-weight: 900;
}

.summary-table td:nth-child(1),
.summary-table td:nth-child(3),
.summary-table td:nth-child(4),
.summary-table td:nth-child(5),
.summary-table tfoot td {
  text-align: right;
}

.permissions-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
}

.permission-users {
  position: sticky;
  top: 18px;
}

.permission-note {
  color: #69727d;
  margin: 14px 0 0;
}

.permission-form .panel-head {
  margin-bottom: 16px;
}

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

.permission-card {
  display: grid;
  grid-template-columns: 22px 42px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: #f8f5ef;
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
}

.permission-card:hover {
  background: #fffdf8;
}

.permission-card input {
  width: 18px;
  height: 18px;
}

.permission-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #101820;
  color: white;
}

.permission-card strong,
.permission-card small {
  display: block;
}

.permission-card small {
  color: #69727d;
}

.product-editor {
  margin-bottom: 18px;
}

.product-form-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.product-photo-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .08);
  display: grid;
  gap: 12px;
  position: sticky;
  top: 18px;
}

.product-photo-preview {
  aspect-ratio: 1;
  border: 1px dashed #9fb2c3;
  background: #f7fafc;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  text-align: center;
}

.product-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-photo-preview i {
  font-size: 46px;
  color: var(--accent);
}

.product-photo-preview span {
  display: block;
  font-weight: 700;
}

.product-photo-action {
  display: inline-flex;
  justify-content: center;
  gap: 8px;
}

.product-form-panel {
  margin-bottom: 0;
}

.product-form-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.product-form-head h2 {
  margin: 4px 0;
  font-size: 24px;
}

.product-form-head p {
  margin: 0;
  color: var(--muted);
}

.product-status-chip,
.barcode-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #f8fbfd;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

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

.field-span-3 { grid-column: span 3; }
.field-span-4 { grid-column: span 4; }
.field-span-6 { grid-column: span 6; }
.field-span-8 { grid-column: span 8; }

.input-with-action {
  position: relative;
}

.input-with-action i {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  z-index: 2;
}

.input-with-action .form-control {
  padding-left: 40px;
}

.category-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.category-chip {
  border: 1px solid var(--line);
  background: #f8fbfd;
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.category-chip:hover,
.category-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.product-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}

.product-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f7fafc;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--accent);
  flex: 0 0 auto;
}

.product-thumb-upload {
  cursor: pointer;
  margin: 0;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.product-thumb-upload:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(15, 118, 110, .14);
  transform: translateY(-1px);
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-thumb i {
  font-size: 24px;
}

.product-thumb.image-ready {
  border-color: var(--accent);
}

.product-table td small {
  margin-top: 2px;
}

@keyframes rowPulse {
  0% { background: #d1fae5; }
  100% { background: transparent; }
}

@media (max-width: 900px) {
  .app-frame,
  .login-panel,
  .report-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .detail-head {
    display: none;
  }
  .detail-row {
    grid-template-columns: 1fr;
  }
  .detail-hero {
    flex-direction: column;
  }
  .purchase-hero {
    flex-direction: column;
  }
  .purchase-context {
    grid-template-columns: 1fr;
  }
  .detail-total {
    text-align: left;
  }
  .finder-head,
  .finder-item {
    grid-template-columns: 1fr;
    display: grid;
  }
  .finder-search {
    min-width: 100%;
  }
  .finder-price {
    text-align: left;
  }
  .permissions-shell,
  .permission-grid {
    grid-template-columns: 1fr;
  }
  .product-form-shell,
  .product-form-grid {
    grid-template-columns: 1fr;
  }
  .field-span-3,
  .field-span-4,
  .field-span-6,
  .field-span-8 {
    grid-column: span 1;
  }
  .product-photo-panel {
    position: static;
  }
  .permission-users {
    position: static;
  }
}

@media print {
  .sidebar,
  .topbar,
  .no-print,
  .alert {
    display: none !important;
  }
  .app-frame {
    display: block;
  }
  .content {
    padding: 0;
  }
  .ticket {
    box-shadow: none;
    border: none;
  }
}
