:root {
  --bg: #0b0b0b;
  --panel: #121212;
  --panel-2: #181818;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f2f1ed;
  --muted: #8a8a84;
  --silver: #c8c8c8;
  --accent: #e8e6df;
  --good: #3d9a6a;
  --warn: #c4a035;
  --bad: #c44b4b;
  --info: #5a7fb5;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --sidebar: 240px;
  --radius: 10px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #1c1c1c, var(--bg));
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* —— Login —— */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, #161616, #101010);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.login-card .mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #111;
  font-weight: 800;
  margin-bottom: 18px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.95rem;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  background: #0d0d0d;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s var(--ease);
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(232, 230, 223, 0.45);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  font-weight: 650;
  transition: transform 0.15s var(--ease), opacity 0.15s var(--ease),
    background 0.15s var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  color: #111;
  width: 100%;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.btn-danger {
  background: rgba(196, 75, 75, 0.15);
  color: #f0a0a0;
  border: 1px solid rgba(196, 75, 75, 0.35);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.login-hint {
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--muted);
}

.login-error {
  color: #f0a0a0;
  font-size: 0.85rem;
  margin: 0 0 12px;
  min-height: 1.2em;
}

.image-upload {
  display: flex;
  align-items: stretch;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, #141414 0%, #0c0c0c 100%);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.image-upload.is-drag {
  border-color: rgba(232, 230, 223, 0.45);
  background: #161616;
}

.image-preview {
  width: 120px;
  height: 120px;
  flex: 0 0 120px;
  border-radius: 12px;
  overflow: hidden;
  background: #1a1a1a;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-upload-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.photo-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.photo-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.image-upload-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.image-upload-btns .btn {
  width: auto;
  min-width: 120px;
  padding: 10px 16px;
  font-size: 0.9rem;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.image-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.image-meta.is-ok {
  color: #8fd4ae;
}

.image-meta.is-err {
  color: #f0a0a0;
}

.photo-status {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--muted);
}

.photo-status.is-ready {
  color: #8fd4ae;
}

@media (max-width: 560px) {
  .image-upload {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .image-upload-actions {
    align-items: center;
    width: 100%;
  }

  .image-upload-btns {
    justify-content: center;
    width: 100%;
  }

  .image-upload-btns .btn {
    flex: 1;
  }
}

/* —— Shell —— */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
}

.brand-row .mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #111;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand-row strong {
  display: block;
  font-size: 0.95rem;
}

.brand-row span {
  color: var(--muted);
  font-size: 0.75rem;
}

.nav-btn {
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--muted);
  border-radius: 8px;
  padding: 11px 12px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.nav-btn:hover,
.nav-btn.active {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 12px;
}

.main {
  padding: 28px 32px 48px;
  min-width: 0;
}

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

.topbar h2 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.view {
  display: none;
  animation: fadeIn 0.28s var(--ease);
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* —— Cards / stats —— */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat {
  background: linear-gradient(180deg, #161616, #111);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat strong {
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.panel-head h3 {
  margin: 0;
  font-size: 1rem;
}

.panel-body {
  padding: 16px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar input,
.toolbar select {
  background: #0d0d0d;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 180px;
}

/* —— Tables —— */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

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

.product-cell img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  background: #222;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.badge-placed {
  background: rgba(90, 127, 181, 0.15);
  color: #9db7db;
  border-color: rgba(90, 127, 181, 0.35);
}
.badge-paid {
  background: rgba(61, 154, 106, 0.15);
  color: #8fd4ae;
  border-color: rgba(61, 154, 106, 0.35);
}
.badge-packed {
  background: rgba(196, 160, 53, 0.15);
  color: #e4c86a;
  border-color: rgba(196, 160, 53, 0.35);
}
.badge-shipped {
  background: rgba(90, 127, 181, 0.2);
  color: #b7cceb;
  border-color: rgba(90, 127, 181, 0.4);
}
.badge-delivered {
  background: rgba(61, 154, 106, 0.22);
  color: #a8e0c0;
  border-color: rgba(61, 154, 106, 0.45);
}
.badge-cancelled {
  background: rgba(196, 75, 75, 0.15);
  color: #f0a0a0;
  border-color: rgba(196, 75, 75, 0.35);
}
.badge-active {
  background: rgba(61, 154, 106, 0.15);
  color: #8fd4ae;
}
.badge-draft {
  background: rgba(138, 138, 132, 0.15);
  color: #bdbdb7;
}

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

.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
}

/* —— Forms / grid —— */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.split {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.timeline li {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 12px;
}

.timeline i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--silver);
  margin-top: 4px;
  box-shadow: 0 0 0 4px rgba(200, 200, 200, 0.12);
}

.timeline strong {
  display: block;
  text-transform: capitalize;
}

.timeline span {
  color: var(--muted);
  font-size: 0.82rem;
}

.kv {
  display: grid;
  gap: 8px;
}

.kv div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.kv em {
  color: var(--muted);
  font-style: normal;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.notice {
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(232, 230, 223, 0.06);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  right: auto;
  max-width: min(440px, calc(100vw - 32px));
  background: #1a1a1a;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 14px 18px;
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: 0.25s var(--ease);
  z-index: 400;
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: center;
  font-weight: 600;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-ok {
  border-color: rgba(61, 154, 106, 0.55);
  background: linear-gradient(180deg, #152019, #121212);
}

.toast.is-err {
  border-color: rgba(196, 75, 75, 0.55);
  background: linear-gradient(180deg, #241414, #121212);
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(232, 230, 223, 0.12);
  color: var(--silver);
}

.mode-pill.is-edit {
  background: rgba(90, 127, 181, 0.2);
  color: #b7cceb;
}

.mode-banner {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.88rem;
}

.mode-banner.is-edit {
  border-color: rgba(90, 127, 181, 0.35);
  background: rgba(90, 127, 181, 0.1);
  color: #c5d6ee;
}

.success-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
}

/* Beat .hidden { display:none !important } — both classes can briefly coexist */
.success-overlay.is-open,
.success-overlay.is-open.hidden {
  display: grid !important;
}

.success-card {
  width: min(440px, 100%);
  padding: 32px 28px 24px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, #1a1a1a, #101010);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  animation: successIn 0.35s var(--ease);
}

@keyframes successIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.success-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(61, 154, 106, 0.2);
  color: #8fd4ae;
  font-size: 1.6rem;
  font-weight: 700;
}

.confirm-icon {
  background: rgba(196, 75, 75, 0.2);
  color: #f0a0a0;
}

.confirm-card .success-eyebrow {
  color: #f0a0a0;
}

.success-eyebrow {
  margin: 0 0 6px;
  color: #8fd4ae;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
}

.success-card h2 {
  margin: 0 0 10px;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}

.success-card > p:not(.success-eyebrow) {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.success-actions {
  display: grid;
  gap: 8px;
}

.success-actions .btn {
  width: 100%;
}

.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 40;
  background: #1a1a1a;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
}

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

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

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    z-index: 30;
    transform: translateX(-105%);
    transition: transform 0.25s var(--ease);
  }

  .sidebar.open {
    transform: none;
  }

  .mobile-nav-toggle {
    display: inline-flex;
  }

  .main {
    padding: 64px 16px 40px;
  }
}

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