
:root {
  color-scheme: dark;
  --bg: #0d0d0c;
  --surface: #11100f;
  --toolbar: #161412;
  --panel: #1b1916;
  --panel-2: #24201c;
  --line: #39332d;
  --text: #fff7eb;
  --muted: #c9beb1;
  --soft: #8c8278;
  --accent: #d7b46a;
  --accent-text: #17120a;
  --green: #71c59a;
  --red: #df6663;
  --danger-bg: #3b2020;
  --danger-text: #ffd9d7;
  --secondary: #2d2924;
  --pill-bg: #171512;
  --price-bg: #292113;
  --status-bg: #171512;
  --status-error-bg: #251719;
  --input: #0f0e0d;
  --radius: 8px;
  --font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  font-size: 16px;
  letter-spacing: 0;
}

body * {
  min-width: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

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

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px;
}

.login-panel h1,
.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.login-panel p,
.empty,
.status-line {
  color: var(--muted);
}

.login-panel label,
.field label,
.add-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.login-panel input,
.field input,
.field textarea,
.add-form input,
.add-form textarea,
.add-form select,
.toolbar input,
.toolbar select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

.login-panel input:focus,
.field input:focus,
.field textarea:focus,
.add-form input:focus,
.add-form textarea:focus,
.add-form select:focus,
.toolbar input:focus,
.toolbar select:focus {
  border-color: var(--accent);
}

.primary-btn,
.secondary-btn,
.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  max-width: 100%;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: normal;
}

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

.secondary-btn {
  background: var(--secondary);
  color: var(--text);
}

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

.admin-shell {
  width: min(1360px, calc(100% - 32px));
  max-width: none;
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow-x: hidden;
}

.topbar {
  display: grid;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.topbar-main > div {
  min-width: 0;
}

.top-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.top-actions .primary-btn,
.top-actions .secondary-btn {
  min-width: 0;
  padding-left: 10px;
  padding-right: 10px;
  text-align: center;
  line-height: 1.15;
}

.top-actions button.active {
  color: var(--accent-text);
  background: var(--accent);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--accent);
  background: var(--pill-bg);
  font-size: 13px;
}

.pill.online {
  color: #bdf4cf;
  border-color: rgba(72, 199, 116, 0.46);
  background: rgba(72, 199, 116, 0.12);
}

.pill.online::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(72, 199, 116, 0.13);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(220px, 0.62fr) minmax(320px, auto);
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--toolbar);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.main-status {
  margin: 0;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--status-bg);
  color: var(--muted);
  font-size: 13px;
}

.main-status.error {
  color: var(--danger-text);
  background: var(--status-error-bg);
}

.segment {
  display: grid;
  grid-template-columns: repeat(3, minmax(70px, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 100%;
}

.segment button {
  min-height: 42px;
  background: var(--input);
  color: var(--muted);
  border-right: 1px solid var(--line);
  padding: 6px 10px;
}

.segment button:last-child {
  border-right: 0;
}

.segment button.active {
  color: var(--accent-text);
  background: var(--accent);
}

.workspace {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 16px 20px 24px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.workspace.with-side-panel {
  grid-template-columns: minmax(0, 1fr) 380px;
}

.topbar,
.toolbar,
.main-status,
.workspace-content,
.side-panel,
.archive-panel {
  transition: filter 160ms ease, opacity 160ms ease;
}

.admin-shell.is-loading .topbar,
.admin-shell.is-loading .toolbar,
.admin-shell.is-loading .main-status,
.admin-shell.is-loading .workspace-content,
.admin-shell.is-loading .side-panel,
.admin-shell.is-loading .archive-panel {
  filter: blur(3px);
  opacity: 0.42;
  pointer-events: none;
  user-select: none;
}

.loading-overlay {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(360px, calc(100vw - 32px));
  border: 1px solid rgba(215, 180, 106, 0.35);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 14px 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.42);
  transform: translate(-50%, -50%);
}

.loading-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(215, 180, 106, 0.52);
  animation: pulse 1.35s ease-in-out infinite;
  flex: 0 0 auto;
}

.loading-overlay strong {
  display: block;
  font-size: 14px;
}

.loading-overlay span:not(.loading-dot) {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(215, 180, 106, 0.48); }
  70% { box-shadow: 0 0 0 9px rgba(215, 180, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(215, 180, 106, 0); }
}

.items-header,
.side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.items-header h2,
.side-header h2 {
  margin: 0;
  font-size: 18px;
}

.items-grid {
  display: grid;
  gap: 10px;
}

.item-card,
.side-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
}

.item-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 12px;
}

.item-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 10px;
  align-items: start;
}

.item-title {
  min-width: 0;
}

.item-title strong {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.quantity-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  background: var(--pill-bg);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.item-title span,
.meta-line,
.change-row {
  color: var(--muted);
  font-size: 12px;
}

.anchor-line {
  margin-top: 5px;
  text-align: right;
}

.anchor-line strong {
  color: var(--text);
}

.price-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  min-height: 30px;
  border-radius: var(--radius);
  background: var(--price-bg);
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.edit-grid {
  display: grid;
  grid-template-columns: minmax(94px, 112px) minmax(150px, 1fr);
  gap: 10px;
  align-items: end;
}

.edit-grid .price-field input {
  text-align: right;
  max-width: 112px;
}

.field textarea,
.add-form textarea {
  min-height: 42px;
  resize: vertical;
}

.switch,
.visibility-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  color: var(--muted);
  background: var(--input);
}

.switch input,
.visibility-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.inline-toggle-row {
  display: flex;
  justify-content: flex-start;
}

.visibility-toggle {
  min-height: 34px;
  padding-right: 10px;
  max-width: 100%;
}

.visibility-toggle span {
  display: grid;
  gap: 1px;
}

.visibility-toggle strong {
  color: var(--text);
  font-size: 12px;
}

.visibility-toggle small {
  color: var(--muted);
  font-size: 10px;
}

.save-state {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.side-panel {
  padding: 14px;
  align-self: start;
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow: auto;
}

.side-actions {
  display: grid;
  gap: 10px;
}

.side-actions .primary-btn {
  width: 100%;
}

.add-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.add-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.add-panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.add-form {
  display: grid;
  gap: 10px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.changes {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.archive-panel {
  display: grid;
  gap: 12px;
  width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px;
}

.archive-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.archive-head h2 {
  margin: 0;
  font-size: 18px;
}

.change-row {
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.changes .secondary-btn {
  width: 100%;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
  z-index: 5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.62);
}

.modal-panel {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 16px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.48);
}

.modal-panel h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal-panel p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.modal-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.modal-panel input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

@media (min-width: 1121px) {
  .topbar {
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 var(--radius) var(--radius);
  }

  .toolbar {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }

  .main-status {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }

  .workspace {
    padding-left: 0;
    padding-right: 0;
  }

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

  .workspace.with-side-panel .items-grid {
    grid-template-columns: 1fr;
  }

  .item-card {
    min-height: 214px;
  }

  .item-head {
    align-items: start;
  }

  .card-actions {
    align-self: end;
  }
}

@media (max-width: 1120px) {
  .toolbar,
  .workspace,
  .workspace.with-side-panel,
  .edit-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .workspace.with-side-panel .side-panel {
    order: -1;
  }
}

@media (max-width: 640px) {
  .admin-shell {
    width: 100%;
    margin: 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .login-shell,
  .admin-shell,
  .topbar,
  .toolbar,
  .workspace,
  .main-status {
    width: 100%;
    max-width: 100dvw;
  }

  .login-panel h1,
  .topbar h1 {
    font-size: 22px;
  }

  .login-panel p,
  .empty,
  .status-line,
  .item-title span,
  .meta-line,
  .change-row {
    font-size: 13px;
  }

  .top-actions {
    width: 100%;
  }

  .topbar-main {
    width: 100%;
  }

  .toolbar,
  .workspace,
  .main-status {
    padding-left: 14px;
    padding-right: 14px;
  }

  .top-actions {
    gap: 6px;
  }

  .top-actions .primary-btn,
  .top-actions .secondary-btn {
    min-height: 38px;
    padding-left: 6px;
    padding-right: 6px;
    font-size: 12px;
  }

  .segment {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .segment button {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .segment button:last-child {
    border-bottom: 0;
  }

  .item-head {
    grid-template-columns: minmax(0, 1fr) max-content;
  }

  .item-card,
  .side-panel,
  .login-panel {
    width: 100%;
    max-width: 100%;
  }

  .price-badge {
    justify-self: start;
  }

  .anchor-line {
    text-align: left;
  }
}
