:root {
  --bg: #f7f8f5;
  --panel: #ffffff;
  --ink: #17201c;
  --muted: #66736d;
  --line: #dce3df;
  --brand: #0f766e;
  --brand-2: #2563eb;
  --accent: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --soft: #edf7f5;
  --shadow: 0 18px 45px rgba(24, 35, 30, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

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

.sidebar {
  background: #101916;
  color: #eff7f4;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(7, 43, 31, 0.18);
  flex: 0 0 auto;
}

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

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span,
.userbox span,
.muted {
  color: var(--muted);
}

.sidebar .brand span,
.sidebar .userbox span {
  color: #a6b8b1;
}

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

.nav button {
  min-height: 40px;
  text-align: left;
  border-radius: 8px;
  padding: 9px 10px;
  color: #dcebe6;
  background: transparent;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.userbox {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.content {
  padding: 24px clamp(16px, 3vw, 36px);
  min-width: 0;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
  margin-bottom: 6px;
}

h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.filters {
  margin-bottom: 12px;
}

.filters input,
.filters select {
  min-width: min(360px, 100%);
}

.btn {
  min-height: 38px;
  border-radius: 8px;
  padding: 9px 13px;
  background: var(--brand);
  color: white;
  font-weight: 700;
}

.btn.secondary {
  background: #e8efec;
  color: var(--ink);
}

.btn.warn {
  background: var(--accent);
}

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

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.link-button {
  padding: 0;
  min-height: 0;
  background: transparent;
  color: var(--brand);
  text-align: left;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.wide-modal {
  width: min(860px, calc(100vw - 28px));
}

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

.detail-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f9fbfa;
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

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

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 28px;
  line-height: 1;
}

.metric.compact {
  margin: 12px 0;
}

.metric.compact strong {
  font-size: 22px;
}

.stock-list {
  max-height: 420px;
  overflow: auto;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.catalog-tile {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f9fbfa;
}

.catalog-tile span {
  color: var(--muted);
}

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

.day-metrics .metric {
  box-shadow: none;
  padding: 12px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

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

th {
  color: #42504a;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f2f5f3;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2ff;
  color: #3730a3;
}

.status.accepted,
.status.ok {
  background: #dcfce7;
  color: var(--ok);
}

.status.queued,
.status.sent,
.status.sending,
.status.retry,
.status.draft,
.status.planned,
.status.trial {
  background: #fef3c7;
  color: #92400e;
}

.status.rejected,
.status.error {
  background: #fee2e2;
  color: var(--danger);
}

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

.file-pick {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

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

label {
  display: grid;
  gap: 5px;
  color: #35423d;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
  min-height: 76px;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(115deg, rgba(15, 118, 110, 0.16), transparent 45%),
    linear-gradient(240deg, rgba(180, 83, 9, 0.12), transparent 40%),
    var(--bg);
}

.site {
  min-height: 100vh;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 48px);
  background: rgba(247, 248, 245, 0.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 3;
}

.site-hero {
  min-height: 560px;
  display: grid;
  align-items: center;
  padding: 56px clamp(16px, 6vw, 72px);
  background:
    linear-gradient(90deg, rgba(247, 248, 245, 0.96), rgba(247, 248, 245, 0.68)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='700' viewBox='0 0 1200 700'%3E%3Crect width='1200' height='700' fill='%23dfe9e5'/%3E%3Cg fill='none' stroke='%230f766e' stroke-width='5' opacity='.35'%3E%3Cpath d='M120 470h230l80-160 120 230 90-140h420'/%3E%3Ccircle cx='240' cy='250' r='80'/%3E%3Crect x='740' y='150' width='260' height='360' rx='28'/%3E%3Cpath d='M790 235h160M790 305h130M790 375h180'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

.site-hero > div {
  max-width: 760px;
}

.site-hero h1 {
  font-size: clamp(36px, 5vw, 64px);
  line-height: 1.02;
  margin-bottom: 18px;
}

.site-hero p {
  max-width: 680px;
  font-size: 19px;
  color: #35423d;
}

.site-band {
  padding: 42px clamp(16px, 5vw, 64px);
}

.login .card {
  width: min(430px, 100%);
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.mode-switch button {
  min-height: 38px;
  padding: 8px 12px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

.mode-switch button.active {
  background: var(--brand-2);
  color: #fff;
}

.notice {
  border-left: 4px solid var(--brand);
  background: var(--soft);
  padding: 12px;
  border-radius: 8px;
  color: #24534e;
}

.agent-layout {
  max-width: 980px;
  margin: 0 auto;
}

.agent-bottom {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 18px -8px -8px;
  padding: 8px;
  background: rgba(247, 248, 245, 0.94);
  backdrop-filter: blur(8px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.agent-bottom button {
  min-height: 44px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 800;
}

.agent-bottom button.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #101916;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 10;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 25, 22, 0.48);
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 4;
  }

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

  .userbox {
    margin-top: 0;
  }

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8 {
    grid-column: span 12;
  }
}

@media (max-width: 620px) {
  .content {
    padding: 16px 12px 22px;
  }

  .topbar,
  .split,
  .form-row {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar,
  .mode-switch {
    width: 100%;
  }

  .toolbar .btn,
  .mode-switch button {
    flex: 1;
  }

  .grid {
    gap: 10px;
  }

  .card {
    padding: 13px;
  }
}
