:root {
  color-scheme: light;
  --ink: #1c1915;
  --muted: #6b6258;
  --paper: #f6f1e8;
  --card: #fffdf8;
  --line: #e3d6c4;
  --green: #0f6e56;
  --green-soft: #e5f4ef;
  --clay: #9a3412;
  --clay-soft: #fde8df;
  --shadow: 0 16px 40px rgba(58, 42, 22, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 32px 20px 64px;
  background:
    radial-gradient(circle at top right, #efe2cf 0, transparent 28rem),
    var(--paper);
  color: var(--ink);
  font-family: Vazirmatn, Tahoma, sans-serif;
  line-height: 1.6;
}

body.app-shell {
  display: flex;
  min-height: 100vh;
  padding: 0;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px 16px;
  background: #1c1915;
  color: #f6f1e8;
}

.sidebar .brand {
  margin: 0;
  font-weight: 700;
  font-size: 1.15rem;
}

.sidebar .who {
  margin: 0 0 12px;
  color: #c8bbaa;
  font-size: 0.85rem;
}

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

.sidebar a {
  color: #f6f1e8;
  font-weight: 600;
  text-decoration: none;
  border-radius: 12px;
  padding: 10px 12px;
}

.sidebar a.active,
.sidebar a:hover {
  background: #0f6e56;
}

.sidebar form {
  margin-top: auto;
}

.sidebar button {
  width: 100%;
  background: transparent;
  color: #f6f1e8;
  border: 1px solid #4a433b;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 32px 20px 64px;
}

@media (max-width: 800px) {
  body.app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar form { margin-top: 12px; }
}

.top, .filters, .notice, .factory, .table-wrap, .empty, .search-results, .order-create {
  max-width: 1180px;
  margin-inline: auto;
}

.top { position: relative; }

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f6f1e8;
  padding: 8px 0 12px;
}

.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

a.excel-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  background: var(--green);
  color: white;
  border-radius: 12px;
  padding: 11px 18px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

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

@media (max-width: 800px) {
  .title-row { align-items: stretch; flex-direction: column; }
  a.excel-btn { justify-content: center; }
}

.logout {
  position: absolute;
  top: 0;
  left: 0;
}

.logout button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.login-card {
  max-width: 420px;
  margin: 8vh auto;
  padding: 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

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

.login-card .notice { margin: 0 0 16px; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.3;
}

.lede {
  max-width: 42rem;
  color: var(--muted);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin: 24px auto;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.grow { flex: 1 1 220px; }

input[type="number"], input[type="text"], input[type="password"], input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
}

button {
  border: 0;
  background: var(--green);
  color: white;
  border-radius: 12px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button.danger { background: var(--clay); }

.suppliers {
  max-width: 1180px;
  margin: 0 auto 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suppliers a {
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
}

.suppliers a span {
  color: var(--muted, #6b6358);
  font-weight: 400;
  margin-right: 4px;
}

.suppliers a.active {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.suppliers a.active span { color: white; }

.search-results {
  margin: 0 auto 14px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.search-results p { margin: 0; }

.search-results ul {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.search-results a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  background: var(--green-soft);
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 600;
}

.search-results a span {
  color: var(--muted);
  font-weight: 400;
}

.remove { margin-top: 8px; }

.remove button {
  background: transparent;
  color: var(--clay);
  border: 1px solid #f0c8b8;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.ok-notice {
  background: var(--green-soft);
  border-color: #b7e0d4;
}

.notice, .empty {
  background: var(--clay-soft);
  border: 1px solid #f0c8b8;
  border-radius: 16px;
  padding: 16px 18px;
}

.factory { margin-bottom: 12px; }

.summary {
  max-width: 1180px;
  margin: 0 auto 20px;
}

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

.summary h2 {
  margin: 0;
  font-size: 1.25rem;
}

.order-create {
  margin: 24px auto;
}

.order-create input[type="number"] {
  max-width: 8rem;
}

.hint { color: var(--muted); font-weight: 400; }

.copy-btn {
  background: var(--ink);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.copy-table {
  user-select: text;
  background: white;
}

.copy-table th,
.copy-table td {
  border: 1px solid #cfc3b2;
}

.copy-table .row-num {
  width: 3rem;
  text-align: center;
  color: var(--muted, #6b6358);
}

.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; }

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

th {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
  background: #fbf7f1;
}

.products > tbody > tr:not(.sizes) td { background: #fffdf8; }

.sizes td { background: #f8f4ee; padding-top: 0; }

.sizes table { background: transparent; }

.sizes th { background: transparent; }

a { color: var(--green); font-weight: 700; text-decoration: none; }

th a.sort-link { color: inherit; white-space: nowrap; }

.code {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85rem;
}

.plan span, .plan strong { display: block; }

.ok { color: var(--green); font-weight: 700; }
.bad { color: var(--clay); font-weight: 700; }
.muted { color: var(--muted); }

.ok, .bad {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
}

.ok { background: var(--green-soft); }
.bad { background: var(--clay-soft); }
