:root {
  --wood-50:#faf6f1; --wood-100:#f0e4d6; --wood-200:#e0c8a8;
  --wood-500:#a9713f; --wood-600:#8a5a2f; --wood-700:#6b4423;
  --ink-900:#2b2320; --ink-600:#5a4d44; --ink-400:#8c7d72;
  --line:#e6dccf; --bg:#fbf9f6; --card:#ffffff;
  --green:#2e7d32; --green-bg:#e8f5e9;
  --red:#c62828; --red-bg:#fdecea;
  --amber:#b8860b; --amber-bg:#fff8e1;
  --radius:12px; --shadow:0 1px 3px rgba(43,35,32,.08), 0 1px 2px rgba(43,35,32,.06);
  font-size:16px;
}
* { box-sizing:border-box; }
html,body { margin:0; padding:0; background:var(--bg); color:var(--ink-900);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif; }
a { color:var(--wood-600); text-decoration:none; }
h1,h2,h3 { margin:.2em 0 .5em; color:var(--ink-900); line-height:1.25; }
h1 { font-size:1.5rem; } h2 { font-size:1.2rem; } h3 { font-size:1.05rem; }
p { line-height:1.5; }

.container { max-width:960px; margin:0 auto; padding:16px 16px 96px; }

/* ---- Topbar (desktop) ---- */
.topbar { background:var(--wood-700); color:#fff; }
.topbar-inner { max-width:960px; margin:0 auto; padding:10px 16px; display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; }
.brand { color:#fff; font-weight:700; font-size:1.1rem; }
.topnav { display:none; gap:16px; }
.topnav a { color:#f1e4d3; font-size:.92rem; }
.topnav a.active, .topnav a:hover { color:#fff; text-decoration:underline; }
@media (min-width:720px) { .topnav { display:flex; align-items:center; } }

/* ---- Bottom nav (mobile) ---- */
.bottomnav { position:fixed; bottom:0; left:0; right:0; background:#fff; border-top:1px solid var(--line);
  display:flex; justify-content:space-around; padding:6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow:0 -2px 8px rgba(0,0,0,.05); z-index:50; }
@media (min-width:720px) { .bottomnav { display:none; } .container { padding-bottom:16px; } }
.bottomnav a { flex:1; text-align:center; font-size:.68rem; color:var(--ink-400); padding:4px 2px; border-radius:8px; }
.bottomnav a span { display:block; font-size:1.25rem; }
.bottomnav a.active { color:var(--wood-600); font-weight:600; }
.bottomnav-cta span { background:var(--wood-600); color:#fff; border-radius:50%; width:40px; height:40px; line-height:40px; margin:0 auto; font-size:1.3rem; }

/* ---- Cards / layout helpers ---- */
.card { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:16px; margin-bottom:16px; box-shadow:var(--shadow); }
.grid { display:grid; gap:12px; }
.grid-2 { grid-template-columns:1fr; } .grid-3 { grid-template-columns:1fr; } .grid-4 { grid-template-columns:1fr 1fr; }
@media (min-width:560px) { .grid-2 { grid-template-columns:1fr 1fr; } .grid-3 { grid-template-columns:1fr 1fr 1fr; } .grid-4 { grid-template-columns:repeat(4,1fr); } }

.stat { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:14px; box-shadow:var(--shadow); }
.stat .value { font-size:1.6rem; font-weight:700; color:var(--wood-700); }
.stat .label { font-size:.8rem; color:var(--ink-400); text-transform:uppercase; letter-spacing:.03em; }

.bar-row { display:flex; align-items:center; gap:8px; margin:6px 0; font-size:.85rem; }
.bar-row .name { width:120px; flex-shrink:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.bar-track { flex:1; background:var(--wood-100); border-radius:6px; height:14px; overflow:hidden; }
.bar-fill { background:var(--wood-500); height:100%; border-radius:6px; }
.bar-val { width:90px; text-align:right; flex-shrink:0; color:var(--ink-600); }

/* ---- Forms ---- */
label { display:block; font-size:.85rem; font-weight:600; color:var(--ink-600); margin:10px 0 4px; }
input[type=text], input[type=number], input[type=password], input[type=search], input[type=date], select, textarea {
  width:100%; padding:11px 12px; border:1px solid var(--line); border-radius:10px; font-size:1rem; background:#fff; color:var(--ink-900); }
textarea { resize:vertical; min-height:70px; }
input:focus, select:focus, textarea:focus { outline:2px solid var(--wood-500); outline-offset:1px; }
.field-row { display:flex; gap:8px; align-items:flex-end; }
.field-row > div { flex:1; }
.unit-select { max-width:70px; flex:0 0 70px; }
.help { font-size:.78rem; color:var(--ink-400); margin-top:3px; }

button, .btn { display:inline-block; background:var(--wood-600); color:#fff; border:none; border-radius:10px;
  padding:11px 18px; font-size:.95rem; font-weight:600; cursor:pointer; text-align:center; }
button:hover, .btn:hover { background:var(--wood-700); }
.btn-secondary { background:#fff; color:var(--wood-700); border:1px solid var(--wood-500); }
.btn-secondary:hover { background:var(--wood-50); }
.btn-danger { background:var(--red); } .btn-danger:hover { background:#a11f1f; }
.btn-sm { padding:6px 12px; font-size:.82rem; border-radius:8px; }
.btn-block { display:block; width:100%; }
.btn-row { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }

.chip-row { display:flex; flex-wrap:wrap; gap:6px; margin:6px 0 2px; }
.chip { background:var(--wood-100); color:var(--wood-700); border:1px solid var(--wood-200); border-radius:999px;
  padding:5px 11px; font-size:.8rem; cursor:pointer; }
.chip:hover { background:var(--wood-200); }

/* ---- Tables ---- */
table { width:100%; border-collapse:collapse; font-size:.9rem; }
th, td { text-align:left; padding:9px 8px; border-bottom:1px solid var(--line); vertical-align:top; }
th { color:var(--ink-400); font-size:.75rem; text-transform:uppercase; letter-spacing:.03em; }
tr:last-child td { border-bottom:none; }
.table-wrap { overflow-x:auto; }
td.num, th.num { text-align:right; white-space:nowrap; }

/* ---- Badges / flash ---- */
.badge { display:inline-block; padding:2px 9px; border-radius:999px; font-size:.75rem; font-weight:600; }
.badge-open { background:var(--green-bg); color:var(--green); }
.badge-closed { background:#eee; color:var(--ink-400); }
.badge-low { background:var(--red-bg); color:var(--red); }
.badge-ia { background:var(--amber-bg); color:var(--amber); }

.flash { padding:10px 14px; border-radius:10px; margin-bottom:14px; font-size:.9rem; }
.flash-success { background:var(--green-bg); color:var(--green); }
.flash-error { background:var(--red-bg); color:var(--red); }
.flash-info { background:var(--wood-100); color:var(--wood-700); }

/* ---- Misc ---- */
.muted { color:var(--ink-400); }
.text-right { text-align:right; }
.mt-0 { margin-top:0; } .mb-0 { margin-bottom:0; }
.empty-state { text-align:center; padding:40px 16px; color:var(--ink-400); }
.photo-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(90px,1fr)); gap:8px; margin:10px 0; }
.photo-grid img, .photo-thumb { width:100%; aspect-ratio:1; object-fit:cover; border-radius:8px; border:1px solid var(--line); }
.login-wrap { max-width:380px; margin:60px auto; padding:0 16px; }
.login-wrap .card { text-align:center; }
.logo-big { font-size:2.6rem; }
.item-card { border:1px solid var(--line); border-radius:10px; padding:12px; margin-bottom:10px; }
.item-card .item-head { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.ai-box { border:2px dashed var(--wood-200); border-radius:12px; padding:16px; text-align:center; background:var(--wood-50); }
.spinner { display:inline-block; width:16px; height:16px; border:2px solid var(--wood-200); border-top-color:var(--wood-600); border-radius:50%; animation:spin .7s linear infinite; vertical-align:middle; }
@keyframes spin { to { transform:rotate(360deg); } }
