:root {
  --green: #1d4a38;
  --leaf: #1f7a45;
  --bg: #eef4ec;
  --card: #ffffff;
  --ink: #1c241f;
  --muted: #6b746c;
  --line: #e4ece3;
  --soft: #e7f4e1;
  --amber: #f8efd0;
  --amber-ink: #85640f;
  --blue: #e3eefb;
  --blue-ink: #1f4f86;
  --red: #fdeceb;
  --red-ink: #a1301f;
  --sans: "Outfit", "Avenir Next", system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body.adm { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14.5px; min-height: 100vh; }
body[data-loading] .adm-main { opacity: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--leaf); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.only-m { display: none; }

.adm-app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.adm-side {
  position: sticky; top: 0; height: 100vh; overflow: auto;
  background: #fbfdfa; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.adm-brand { display: flex; align-items: center; justify-content: space-between; }
.adm-brand img { height: 54px; mix-blend-mode: multiply; }
.adm-tag { margin: 4px 6px 16px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--leaf); }
.adm-nav { display: grid; gap: 4px; }
.adm-nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 0; background: transparent; border-radius: 12px; padding: 11px 12px;
  font-weight: 600; text-align: left; cursor: pointer; color: #3b453e;
}
.adm-nav button:hover { background: #f0f6ee; }
.adm-nav button.active { background: var(--soft); color: var(--green); }
.badge {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: #d9480f; color: #fff; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center;
}
.badge[hidden] { display: none !important; }
.adm-nav .badge { flex: none; }
.adm-side-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 18px; }
.adm-side-foot a, .adm-side-foot button {
  border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px;
  font-weight: 600; text-decoration: none; color: #3b453e; text-align: left; cursor: pointer;
}
.scrim { display: none; }

.adm-main { padding: 18px 24px 40px; min-width: 0; transition: opacity .2s; }
.adm-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.adm-top h1 { font-family: var(--serif); font-weight: 560; font-size: 32px; letter-spacing: -.02em; }
.adm-top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { font-weight: 700; color: var(--green); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #fff;
  display: inline-grid; place-items: center; cursor: pointer; font-size: 22px; line-height: 1;
}
.icon-btn.spin svg { animation: spin .7s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 38px; height: 22px; border-radius: 999px; background: #cfd8cd; position: relative; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--leaf); }
.switch input:checked + span::after { left: 19px; }
.switch input:focus-visible + span { outline: 2px solid var(--leaf); outline-offset: 2px; }
.switch em { font-style: normal; font-size: 13px; font-weight: 600; color: #3b453e; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px;
  box-shadow: 0 8px 20px rgba(30, 50, 30, .03); margin-bottom: 16px; min-width: 0;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.card-head h2 { font-size: 17px; font-weight: 700; }
.link { border: 0; background: transparent; color: var(--leaf); font-weight: 700; cursor: pointer; padding: 0; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.grid-2 > .card { margin-bottom: 16px; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px;
  display: grid; gap: 4px; text-align: left; cursor: pointer;
}
.kpi:hover { border-color: #c8dcc5; }
.kpi small { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.kpi b { font-size: 26px; font-family: var(--serif); font-weight: 600; letter-spacing: -.02em; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.kpi.hot { background: #fff7ed; border-color: #f6d7b4; }
.kpi.hot b { color: #b45309; }

.chart { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; align-items: end; height: 170px; padding-top: 10px; }
.bar { display: grid; gap: 4px; align-items: end; height: 100%; text-align: center; }
.bar i { display: block; background: linear-gradient(#3e9a58, #1d4a38); border-radius: 6px 6px 3px 3px; min-height: 3px; }
.bar small { font-size: 10.5px; color: var(--muted); }
.bar.zero i { background: #e2ebe0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.toolbar p { margin: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 13px;
  font-weight: 600; cursor: pointer; font-size: 13.5px;
}
.chips button.on { background: var(--green); border-color: var(--green); color: #fff; }
.search input {
  width: min(320px, 100%); border: 1px solid var(--line); border-radius: 12px; background: #fff;
  padding: 10px 12px;
}
.btn {
  border: 0; background: var(--green); color: #fff; border-radius: 12px; padding: 11px 16px;
  font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none;
}
.btn:hover { background: #16392c; }
.btn.light { background: #fff; color: var(--green); border: 1px solid #cfe0cc; }
.btn.danger { background: #fff; color: var(--red-ink); border: 1px solid #f1c7c1; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.list-head, .row { display: grid; gap: 12px; align-items: center; padding: 12px 18px; }
.list-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: #f8fbf7; border-bottom: 1px solid var(--line); }
.row { border-bottom: 1px solid #eef3ed; cursor: pointer; text-align: left; width: 100%; background: #fff; border-left: 0; border-right: 0; border-top: 0; }
.row:hover { background: #f8fbf7; }
.row:last-child { border-bottom: 0; }
.row b { font-weight: 700; }
.row small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.row .clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.orders-cols { grid-template-columns: 1fr 1.3fr 1.8fr .7fr 1fr .9fr; }
.customers-cols { grid-template-columns: 1.8fr 1fr .6fr .8fr .9fr .7fr; }
.products-cols { grid-template-columns: 2.2fr 1fr .9fr .7fr .6fr .5fr; }
.card:not(.flush) .row { padding: 10px 0; }
.empty { padding: 22px 18px; color: var(--muted); }
.card:not(.flush) .empty { padding: 12px 0; }
.thumb { display: flex; align-items: center; gap: 10px; min-width: 0; }
.thumb img { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; background: #f1f5f0; flex: none; }
.low { color: #b45309; font-weight: 700; }
.out { color: var(--red-ink); font-weight: 700; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px;
  font-size: 12px; font-weight: 700; white-space: nowrap; justify-self: start;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.placed { background: #fff1e6; color: #b45309; }
.pill.packed { background: var(--blue); color: var(--blue-ink); }
.pill.shipped { background: #efe8fb; color: #5b3a9b; }
.pill.delivered, .pill.paid, .pill.active { background: var(--soft); color: var(--leaf); }
.pill.cancelled, .pill.refunded, .pill.disabled { background: var(--red); color: var(--red-ink); }
.pill.pending { background: var(--amber); color: var(--amber-ink); }
.pill.demo { background: #eef1f4; color: #4b5563; margin-left: 6px; padding: 2px 8px; font-size: 11px; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.pager:empty { display: none; }

.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: #3b453e; }
.form input, .form select, .form textarea {
  width: 100%; border: 1px solid #dbe5d9; border-radius: 12px; background: #fff; padding: 11px 12px; font-weight: 500;
}
.form textarea { min-height: 80px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus, .search input:focus { outline: 2px solid var(--leaf); outline-offset: 1px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.check { display: flex !important; align-items: center; gap: 8px; grid-template-columns: none; }
.check input { width: 18px; height: 18px; }
.form-msg { margin: 0; font-size: 13px; color: var(--red-ink); min-height: 1em; }
.form-msg.ok { color: var(--leaf); }
.howto { margin: 0 0 12px; padding-left: 18px; display: grid; gap: 8px; color: #3b453e; }

.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer-back { position: absolute; inset: 0; border: 0; background: rgba(18, 28, 22, .38); cursor: pointer; animation: fade .2s ease; }
.drawer-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: min(560px, 100%);
  background: #f9fbf8; display: flex; flex-direction: column; animation: slide .25s ease;
  box-shadow: -20px 0 40px rgba(20, 30, 20, .12);
}
.drawer-panel > header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--line); background: #fff;
}
.drawer-panel > header h2 { font-family: var(--serif); font-weight: 560; font-size: 24px; }
.drawer-body { flex: 1; overflow: auto; padding: 16px 18px 40px; display: grid; gap: 14px; align-content: start; }
.block { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 8px; }
.block h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.block p { margin: 0; line-height: 1.45; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.items { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; }
.item img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #f1f5f0; }
.totals { border-top: 1px dashed #d8e2d6; padding-top: 8px; display: grid; gap: 4px; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-weight: 800; font-size: 16px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.steps span { text-align: center; padding: 7px 4px; border-radius: 10px; background: #f1f5f0; color: #8b958c; font-size: 12.5px; font-weight: 700; }
.steps span.on { background: var(--soft); color: var(--leaf); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.timeline li { display: grid; grid-template-columns: 10px 1fr; gap: 10px; font-size: 13.5px; }
.timeline li::before { content: ""; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--leaf); }
.timeline small { color: var(--muted); }
.preview { width: 100%; max-width: 180px; aspect-ratio: 1; object-fit: cover; border-radius: 14px; background: #f1f5f0; border: 1px solid var(--line); }
.photo-pick { display: grid; gap: 8px; }
.photo-list { max-height: 220px; overflow: auto; border: 1px solid #dbe5d9; border-radius: 12px; background: #fff; }
.photo-list button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid #eef3ed; background: #fff; padding: 9px 12px; cursor: pointer; font-weight: 550; }
.photo-list button:last-child { border-bottom: 0; }
.photo-list button.on, .photo-list button.on:hover { background: #1d4a38; color: #fff; }
.photo-list button:hover { background: #f0f6ee; }
.photo-list .empty { margin: 0; padding: 10px 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); z-index: 80;
  background: var(--green); color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: .25s ease; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red-ink); }
.adm-tabs { display: none; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .adm-app { display: block; }
  .only-m { display: inline-grid; }
  .adm-side {
    position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); height: 100%; z-index: 70;
    transform: translateX(-105%); transition: transform .25s ease; box-shadow: 12px 0 40px rgba(20, 30, 20, .14);
    padding-top: calc(18px + env(safe-area-inset-top));
  }
  .adm-side.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; z-index: 65; border: 0; background: rgba(18, 28, 22, .38); }
  .adm-main { padding: 12px 14px calc(96px + env(safe-area-inset-bottom)); }
  .adm-top { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: calc(6px + env(safe-area-inset-top)) 0 10px; margin-bottom: 8px; }
  .adm-top h1 { font-size: 24px; }
  .who { display: none; }
  .switch em { display: none; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi b { font-size: 22px; }
  .chart { height: 130px; gap: 3px; }
  .bar small { font-size: 9px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .chips button { flex: none; }
  .search input { width: 100%; font-size: 16px; }
  .list-head { display: none; }
  .row { grid-template-columns: 1fr auto !important; gap: 4px 10px; padding: 12px 14px; }
  .row > :nth-child(n+3) { grid-column: 1 / -1; }
  .row .hide-m { display: none; }
  .row .pill { justify-self: start; }
  .form input, .form select, .form textarea { font-size: 16px; }
  .form .three { grid-template-columns: 1fr 1fr; }
  .drawer-panel { width: 100%; }
  .drawer-panel > header { padding-top: calc(14px + env(safe-area-inset-top)); }
  .drawer-body { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
  .adm-tabs {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: #fff; border-top: 1px solid var(--line);
    padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  }
  .adm-tabs button {
    position: relative; border: 0; background: transparent; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 48px; font-size: 11px; font-weight: 650; color: #667068;
  }
  .adm-tabs button.active { color: var(--green); }
  .adm-tabs svg { width: 22px; height: 22px; }
  .adm-tabs .badge {
    position: absolute; top: 2px; left: calc(50% + 6px); z-index: 1;
    margin: 0; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px;
  }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media print {
  body.adm { background: #fff; }
  .adm-app, .adm-tabs, .drawer-back, .drawer-panel > header .icon-btn, .no-print, .toast { display: none !important; }
  .drawer { position: static; }
  .drawer-panel { position: static; width: 100%; box-shadow: none; background: #fff; }
  .block { break-inside: avoid; }
}
