:root {
  color-scheme: dark;
  --bg-dark: #040404;
  --bg-darker: #000000;
  --card-bg: rgba(8, 8, 8, 0.82);
  --card-bg-2: rgba(18, 18, 18, 0.75);
  --text: #fafafa;
  --text-soft: #cfcfcf;
  --orange-1: #ff8a00;
  --orange-2: #ff6400;
  --orange-3: #ffbb6a;
  --orange-4: #ff9f1a;
  --danger: #ff6d6d;
  --ok: #79dfa1;
  --warning: #ffd27a;
  --border: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 187, 106, 0.28);
  --focus: rgba(255, 138, 0, 0.65);
  --shadow: 0 26px 60px rgba(0, 0, 0, 0.55);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(1200px 700px at -10% -15%, rgba(255, 122, 0, 0.3) 0%, rgba(255, 122, 0, 0) 62%),
    radial-gradient(900px 460px at 104% 115%, rgba(255, 98, 0, 0.24) 0%, rgba(255, 98, 0, 0) 62%),
    radial-gradient(560px 320px at 50% 98%, rgba(255, 166, 47, 0.1) 0%, rgba(255, 166, 47, 0) 65%),
    linear-gradient(145deg, var(--bg-darker) 0%, #080808 52%, var(--bg-dark) 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 42px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 42px);
  mask-image: radial-gradient(circle at center, black 52%, transparent 95%);
  opacity: 0.36;
}

body::after {
  background: conic-gradient(from 0deg at 50% 50%, rgba(255, 112, 0, 0.2), rgba(255, 140, 40, 0), rgba(255, 112, 0, 0.2));
  filter: blur(110px);
  opacity: 0.3;
  animation: aura 12s linear infinite;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
  box-shadow: none;
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1350px, calc(100% - 28px));
  min-height: calc(100vh - 28px);
  margin: 14px auto;
  padding: clamp(18px, 3vw, 40px);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  background:
    linear-gradient(170deg, rgba(120, 78, 36, 0.72) 0%, rgba(58, 27, 8, 0.78) 45%, rgba(18, 8, 2, 0.88) 100%);
  box-shadow: var(--shadow);
  isolation: isolate;
}

.app-shell::before,
.auth-card::before,
.filters-panel::before,
.table-panel::before,
.metrics-grid article::before,
dialog::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(125deg, rgba(255, 187, 106, 0.42) 0%, rgba(255, 128, 0, 0.12) 38%, rgba(255, 96, 0, 0.42) 100%);
}

.auth-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(14px, 3.5vw, 48px);
}

.auth-card {
  position: relative;
  isolation: isolate;
  width: min(100%, 560px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    linear-gradient(170deg, var(--card-bg-2) 0%, var(--card-bg) 48%, rgba(8, 8, 8, 0.88) 100%);
  backdrop-filter: blur(9px);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3.2vw, 34px);
}

.auth-card::after,
.app-shell::after {
  content: "";
  position: absolute;
  inset: 1px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 22px;
  pointer-events: none;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-card .card-header {
  margin-bottom: 12px;
}

.logo {
  width: clamp(48px, 7vw, 68px);
  height: clamp(48px, 7vw, 68px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  object-fit: cover;
  background: #fff;
  box-shadow: 0 8px 24px rgba(255, 128, 0, 0.28);
}

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

.topbar h1,
.auth-card h1,
.table-head h2,
.dialog-head h2,
.status-panel h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.06;
}

.topbar h1,
.auth-card h1 {
  font-size: clamp(1.45rem, 2.8vw, 2.1rem);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--orange-3);
  font-size: 0.79rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-copy {
  margin: 0 0 8px;
  color: var(--text-soft);
  font-size: 0.94rem;
  line-height: 1.45;
}

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

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  max-width: 260px;
  border: 1px solid rgba(255, 140, 26, 0.25);
  border-radius: 999px;
  background: rgba(255, 140, 26, 0.1);
  color: var(--text-soft);
  padding: 0 13px;
  font-size: 0.86rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary,
.secondary,
.ghost {
  min-height: 42px;
  border-radius: 13px;
  padding: 0 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.primary,
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.primary {
  color: #161616;
  background:
    linear-gradient(130deg, var(--orange-3) 0%, var(--orange-4) 36%, var(--orange-1) 64%, var(--orange-2) 100%);
  background-size: 160% 160%;
  box-shadow: 0 14px 28px rgba(255, 119, 0, 0.35);
}

.secondary,
.ghost {
  border: 1px solid rgba(255, 140, 26, 0.25);
  color: var(--orange-3);
  background: rgba(255, 140, 26, 0.1);
  box-shadow: none;
}

.primary:hover,
.secondary:hover,
.ghost:hover,
.row-actions button:hover,
.segmented button:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.primary:hover {
  background-position: right center;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.square {
  width: 42px;
  padding: 0;
}

.full-width {
  width: 100%;
}

.icon-button svg,
.input-with-icon svg,
.empty-state svg,
.row-actions svg {
  width: 18px;
  height: 18px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.auth-message {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid rgba(255, 109, 109, 0.36);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 109, 109, 0.1) 0%, rgba(255, 109, 109, 0.04) 100%);
}

.status-panel p {
  margin: 6px 0 0;
  color: var(--text-soft);
}

.status-panel code {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 109, 109, 0.12);
  color: var(--danger);
  white-space: nowrap;
}

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

.metrics-grid article,
.filters-panel,
.table-panel {
  position: relative;
  isolation: isolate;
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    linear-gradient(170deg, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0.015) 100%);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.26);
}

.metrics-grid article {
  min-height: 96px;
  padding: 18px;
  overflow: hidden;
}

.metrics-grid article::before,
.filters-panel::before,
.table-panel::before {
  opacity: 0.18;
}

.metrics-grid span {
  display: block;
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 700;
}

.metrics-grid strong {
  display: block;
  margin-top: 8px;
  color: #fff;
  font-size: 1.95rem;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.filters-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 16px;
  padding: 16px;
}

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

.field label {
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.075) 0%, rgba(255, 255, 255, 0.02) 100%);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, background-color 140ms ease;
}

.field textarea {
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.field select option {
  color: #131313;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: rgba(255, 177, 92, 0.45);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--orange-1);
  box-shadow: 0 0 0 3px var(--focus), 0 0 28px rgba(255, 128, 0, 0.16);
  transform: translateY(-1px);
}

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

.input-with-icon svg {
  position: absolute;
  left: 13px;
  top: 13px;
  color: rgba(255, 255, 255, 0.56);
}

.input-with-icon input {
  padding-left: 42px;
}

.table-panel {
  overflow: hidden;
}

.table-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
}

.table-head p {
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  align-self: center;
  border: 1px solid rgba(255, 140, 26, 0.25);
  border-radius: 13px;
  overflow: hidden;
}

.segmented button {
  min-height: 38px;
  border-right: 1px solid rgba(255, 140, 26, 0.2);
  background: rgba(255, 140, 26, 0.08);
  color: var(--text-soft);
  font-weight: 800;
  transition: transform 140ms ease, filter 160ms ease, background-color 160ms ease;
}

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

.segmented button.active {
  color: #17110a;
  background: linear-gradient(120deg, var(--orange-3), var(--orange-1));
}

.table-wrap {
  max-height: calc(100vh - 365px);
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 13px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(35, 17, 5, 0.98);
  color: var(--orange-3);
  font-size: 0.76rem;
  text-transform: uppercase;
}

td {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
}

tbody tr:hover {
  background: rgba(255, 140, 26, 0.06);
}

.item-name {
  min-width: 240px;
  color: #fff;
  font-weight: 800;
}

.muted {
  color: var(--text-soft);
  font-weight: 500;
}

.qty {
  color: #fff;
  font-weight: 900;
  text-align: right;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 160px;
  border: 1px solid rgba(255, 184, 112, 0.45);
  border-radius: 999px;
  padding: 0 10px;
  background: linear-gradient(120deg, var(--orange-3), var(--orange-1));
  color: #19120a;
  font-size: 0.75rem;
  font-weight: 900;
  white-space: nowrap;
}

.pill.warn {
  border-color: rgba(255, 109, 109, 0.58);
  background: linear-gradient(125deg, #ff6d6d 0%, #ff4848 60%, #d82525 100%);
  color: #fff5f5;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.row-actions button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 140, 26, 0.25);
  border-radius: 12px;
  background: rgba(255, 140, 26, 0.1);
  color: var(--orange-3);
  transition: transform 140ms ease, filter 160ms ease, background-color 160ms ease;
}

.actions-col {
  width: 98px;
  text-align: right;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 16px;
  padding: 28px 18px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-soft);
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

dialog {
  position: relative;
  isolation: isolate;
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0;
  color: var(--text);
  background:
    linear-gradient(170deg, rgba(44, 26, 12, 0.98) 0%, rgba(18, 10, 5, 0.98) 100%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.62);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(3px);
}

.record-form {
  padding: 20px;
}

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

.dialog-head {
  margin-bottom: 16px;
}

.dialog-actions {
  margin-top: 18px;
}

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

.wide {
  grid-column: 1 / -1;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  width: min(92vw, 360px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(16, 16, 16, 0.97) 0%, rgba(10, 10, 10, 0.97) 100%);
  color: var(--text);
  padding: 12px 14px;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.45);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.3;
}

@keyframes aura {
  0% {
    transform: rotate(0deg) scale(1);
  }

  50% {
    transform: rotate(180deg) scale(1.05);
  }

  100% {
    transform: rotate(360deg) scale(1);
  }
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 20px, 1350px);
    padding: 18px;
  }

  .topbar,
  .table-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions button {
    flex: 1 1 150px;
  }

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

  .workspace {
    grid-template-columns: 1fr;
  }

  .filters-panel {
    position: static;
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .app-shell,
  .auth-card {
    border-radius: 20px;
  }

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

  .segmented {
    grid-template-columns: 1fr;
  }

  .segmented button {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 140, 26, 0.2);
  }

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

  .dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }
}

@media (max-width: 390px) {
  .auth-shell {
    padding: 10px;
  }

  .app-shell,
  .auth-card {
    padding: 16px;
  }

  .field input,
  .field select,
  .field textarea,
  button {
    font-size: 0.93rem;
  }
}
