:root {
  --bg: #f7f4f0; --card: #fff; --ink: #1f1a16; --muted: #6f655c; --line: #e6ded4;
  --accent: #b3542e; --accent-ink: #fff; --ok: #2f7a4b; --warn: #b7791f; --bad: #b33a3a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 20px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); margin: 8px 0 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
button, .button { font: inherit; font-weight: 600; border-radius: 9px; padding: 8px 14px; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; display: inline-block; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--muted); padding: 4px 6px; }
button:disabled { opacity: 0.55; cursor: default; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--ink); width: 100%; }
input[type="checkbox"] { width: auto; }
input[type="color"] { padding: 2px; height: 38px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 12.5px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.mark { width: 18px; height: 18px; border-radius: 6px; background: conic-gradient(from 200deg, #b3542e, #e0a43a, #2f6f73, #b3542e); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top select { width: auto; min-width: 160px; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; }
.tabs a.active { background: var(--bg); color: var(--ink); }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); }
main { max-width: 1120px; margin: 0 auto; padding: 22px 20px 60px; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.row-head select { width: auto; display: inline-block; padding: 4px 8px; font-size: 18px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.kpi .v { font-size: 24px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.meter { height: 12px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; }
.meter-fill.warn { background: var(--warn); }
.meter-fill.full { background: var(--bad); }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 8px; }
.chart .bar { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; opacity: 0.85; position: relative; }
.chart .bar.zero { background: var(--line); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: 12px; font-weight: 600; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.form .form-grid { display: grid; grid-template-columns: 240px 1fr; gap: 18px; }
.fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.fields.two { grid-template-columns: repeat(2, 1fr); }
.fields .wide, .form-actions.wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.photo-pick { display: flex; flex-direction: column; gap: 10px; }
.photo-pick input[type="file"] { padding: 6px; font-size: 12px; }
.drop { border: 2px dashed var(--line); border-radius: 12px; aspect-ratio: 1 / 1; display: grid; place-items: center; text-align: center; color: var(--muted); overflow: hidden; cursor: pointer; font-weight: 500; }
.drop img { width: 100%; height: 100%; object-fit: cover; }

.garments { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.garment { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.garment.inactive { opacity: 0.6; }
.garment .thumb { aspect-ratio: 1 / 1; background: var(--bg); display: grid; place-items: center; color: var(--muted); }
.garment .thumb img { width: 100%; height: 100%; object-fit: cover; }
.garment .body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.garment .name { font-weight: 700; }
.garment .meta { color: var(--muted); font-size: 12.5px; }
.garment .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.garment .actions button, .garment .actions a { padding: 6px 10px; font-size: 12.5px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.badge.ready { background: #e6f3ea; color: var(--ok); }
.badge.processing { background: #fff3d6; color: var(--warn); }
.badge.failed { background: #fbe7e7; color: var(--bad); }
.warn-text { color: var(--warn); font-size: 12px; }

.snippet { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; overflow-x: auto; }
.snippet code { flex: 1; white-space: nowrap; }
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(640px, 94vw); }
dialog::backdrop { background: rgba(20, 16, 12, 0.45); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20; }

@media (max-width: 760px) {
  .form .form-grid, .fields, .fields.two { grid-template-columns: 1fr; }
  .who { margin-left: 0; }
}
