:root {
  --bg: #000000;
  --bg-elev: #191C21;
  --bg-elev-2: #22262e;
  --panel: rgba(25, 28, 33, 0.94);
  --line: rgba(109, 144, 193, 0.2);
  --line-bright: rgba(116, 170, 223, 0.3);
  --ink: #EDEFF2;
  --ink-soft: #8a95a8;
  --accent: #74AADF;
  --accent-2: #6D90C1;
  --danger: #d85050;
  --radius: 16px;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% -10%, #1a2a42 0%, transparent 45%),
    radial-gradient(circle at 95% 12%, #15202e 0%, transparent 42%),
    linear-gradient(160deg, #000000, #0a0d12 60%, #000000);
  padding: 1rem;
  position: relative;
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.15) 1px, transparent 0);
  background-size: 16px 16px;
  mix-blend-mode: soft-light;
  z-index: -3;
}

.bg-glow {
  position: fixed;
  border-radius: 999px;
  filter: blur(52px);
  z-index: -2;
  opacity: 0.36;
}

.glow-a {
  width: 360px;
  height: 360px;
  background: #6D90C1;
  top: -120px;
  left: -90px;
}

.glow-b {
  width: 340px;
  height: 340px;
  background: #3a5a8a;
  bottom: -120px;
  right: -95px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 0.95rem;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.brand-block {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.logo-slot {
  width: 180px;
  min-height: 38px;
  border: 1px solid var(--line-bright);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.32);
  display: grid;
  place-items: center;
  padding: 0.35rem;
}

.logo-slot img {
  max-width: 100%;
  max-height: 50px;
  display: block;
}

.logo-slot img.hidden {
  display: none;
}

.logo-fallback {
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.12em;
  color: var(--ink);
  font-size: 1.3rem;
}

.logo-fallback.hidden {
  display: none;
}

.eyebrow {
  margin: 0;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.03em;
  line-height: 1;
}

h1 {
  font-size: clamp(2rem, 5vw, 2.95rem);
  margin-top: 0.2rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.18rem;
}

.subtle {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.topbar-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.kpi-card {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  padding: 0.72rem;
}

.kpi-label {
  margin: 0;
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.kpi-value {
  margin: 0.36rem 0 0;
  font-size: 1.68rem;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.02em;
}

.tab-bar {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 1rem;
  padding: 0.3rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-x: auto;
}

.tab-btn {
  font: inherit;
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  padding: 0.5rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: var(--accent);
  color: #000000;
  font-weight: 500;
  border-color: transparent;
}

.tab-panel {
  display: none;
}

.tab-panel.visible {
  display: block;
}

/* --- Add-Order inline row --- */
.add-order-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: end;
  padding: 0.65rem;
  margin-bottom: 0.85rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.add-order-row input,
.add-order-row select {
  flex: 1;
  min-width: 90px;
}

.add-order-row input[name="customer"],
.add-order-row select[name="design"] {
  min-width: 120px;
}

.add-order-row input[name="qty"] {
  max-width: 64px;
  min-width: 50px;
}

/* --- Customer Accordion --- */
.customers-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.customer-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.23);
  overflow: hidden;
}

.customer-header {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.6fr 0.6fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
}

.customer-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.customer-header .col-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  display: block;
}

.customer-header .col-value {
  font-size: 0.88rem;
}

.customer-header .expand-arrow {
  font-size: 0.8rem;
  color: var(--ink-soft);
  transition: transform 0.2s;
  user-select: none;
}

.customer-card.open .expand-arrow {
  transform: rotate(90deg);
}

.customer-header .header-actions {
  display: flex;
  gap: 0.3rem;
}

.customer-detail {
  display: none;
  border-top: 1px solid var(--line);
  padding: 0.55rem 0.75rem;
  background: rgba(0, 0, 0, 0.12);
}

.customer-card.open .customer-detail {
  display: block;
}

.detail-line {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.5fr 0.5fr 0.7fr 0.8fr 1fr auto;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(133, 147, 180, 0.1);
}

.detail-line:last-of-type {
  border-bottom: none;
}

.detail-line input,
.detail-line select {
  padding: 0.3rem 0.4rem;
  font-size: 0.8rem;
}

.detail-line .line-actions {
  display: flex;
  gap: 0.25rem;
}

.detail-line .line-actions button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.2rem 0.44rem;
  font-size: 0.73rem;
  cursor: pointer;
}

.detail-labels {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.5fr 0.5fr 0.7fr 0.8fr 1fr auto;
  gap: 0.35rem;
  padding: 0 0 0.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.2rem;
}

.detail-labels span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.detail-footer {
  display: flex;
  gap: 0.4rem;
  padding-top: 0.45rem;
  margin-top: 0.2rem;
}

.detail-footer button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.25rem 0.55rem;
  font-size: 0.76rem;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 0.95rem;
  align-items: start;
}

#customersPanel,
#expensePanel,
#jobsPanel,
#inventoryPanel,
#pricingPanel {
  grid-column: span 2;
}

#designPanel,
#importPanel {
  grid-column: span 1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.inline-controls {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* editor-toolbar removed — accordion replaces it */

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--ink);
  padding: 0.52rem 0.55rem;
}

input::placeholder {
  color: #7884a3;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(116, 170, 223, 0.45);
  outline-offset: 1px;
}

.btn {
  background: var(--accent);
  color: #000000;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(1.06);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-color: var(--line);
}

.btn.danger {
  background: var(--danger);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 0.85rem;
  background: rgba(0, 0, 0, 0.23);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

thead {
  background: #0a0d12;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 0.52rem;
  font-size: 0.83rem;
  vertical-align: top;
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-block;
  padding: 0.18rem 0.38rem;
  border-radius: 999px;
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid transparent;
}

.badge.new,
.badge.queued {
  background: rgba(109, 144, 193, 0.2);
  border-color: rgba(109, 144, 193, 0.55);
}

.badge.printing,
.badge.quality-check {
  background: rgba(116, 170, 223, 0.22);
  border-color: rgba(116, 170, 223, 0.6);
}

.badge.ready,
.badge.completed,
.badge.delivered,
.badge.paid {
  background: rgba(128, 200, 138, 0.2);
  border-color: rgba(128, 200, 138, 0.56);
}

.badge.pending {
  background: rgba(216, 80, 80, 0.22);
  border-color: rgba(216, 80, 80, 0.56);
}

.item-list {
  margin: 0;
  padding-left: 1rem;
}

.item-list li {
  margin: 0.15rem 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 0.5rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.7rem;
}

.form-grid h3 {
  grid-column: 1 / -1;
}

.form-grid label {
  display: grid;
  gap: 0.22rem;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

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

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, 1fr));
  gap: 0.48rem;
  margin-bottom: 0.7rem;
}

.inventory-cell {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0.45rem;
  background: rgba(0, 0, 0, 0.24);
}

.inventory-cell label {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.calc-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.75rem;
  align-items: end;
}

.calc-row label {
  display: grid;
  gap: 0.22rem;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.calc-result,
.summary-row {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  padding: 0.66rem;
  font-size: 0.84rem;
}

.inline-form {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.62rem;
}

.chip-list {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.4rem 0.28rem 0.56rem;
  background: rgba(255, 255, 255, 0.04);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
}

.chip button {
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.4);
  color: var(--ink);
}

/* --- Design Library Grid --- */
.design-grid {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.design-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  transition: background 0.15s;
}

.design-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.design-item.unused {
  opacity: 0.55;
}

.design-item .design-name {
  flex: 1;
  font-size: 0.84rem;
}

.design-item .design-usage {
  font-size: 0.7rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.design-item.used .design-usage {
  color: var(--accent-2);
}

.design-item button {
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 22px;
  height: 22px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.4);
  color: var(--ink-soft);
  font-size: 0.8rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.design-item button:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.actions-cell button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.2rem 0.44rem;
  font-size: 0.73rem;
  cursor: pointer;
}

.muted {
  color: var(--ink-soft);
}

.attachment-note {
  color: #8ab4d8;
  font-size: 0.72rem;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  #customersPanel,
  #expensePanel,
  #jobsPanel,
  #inventoryPanel,
  #pricingPanel,
  #designPanel,
  #importPanel {
    grid-column: span 1;
  }
}

@media (max-width: 760px) {
  body {
    padding: 0.65rem;
  }

  .topbar {
    padding: 0.8rem;
  }

  .tab-bar {
    gap: 0.2rem;
    padding: 0.25rem;
  }

  .tab-btn {
    font-size: 0.88rem;
    padding: 0.4rem 0.7rem;
  }

  .brand-block {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    flex: 1;
    min-width: 120px;
  }

  .inventory-grid,
  .calc-row,
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .calc-row button,
  .form-grid .wide,
  .form-grid button {
    grid-column: 1 / -1;
  }

  .customer-header {
    grid-template-columns: 1fr 1fr auto;
    gap: 0.3rem;
  }

  .customer-header > div:nth-child(n+3):nth-child(-n+4) {
    display: none;
  }

  .detail-line,
  .detail-labels {
    grid-template-columns: 1fr 0.6fr 0.5fr 0.5fr auto;
  }

  .detail-line > :nth-child(5),
  .detail-line > :nth-child(6),
  .detail-labels > :nth-child(5),
  .detail-labels > :nth-child(6) {
    display: none;
  }
}
