/* Donatek ERP v4.2.1 — design system */
:root {
  --brand: #2563eb;
  --brand-h: #1d4ed8;
  --brand-tint: #eff6ff;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-soft: #475569;
  --text-mute: #94a3b8;
  --success: #10b981;
  --success-tint: #d1fae5;
  --warning: #f59e0b;
  --warning-tint: #fef3c7;
  --danger: #ef4444;
  --danger-tint: #fee2e2;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --sh-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --sh: 0 4px 12px rgba(15, 23, 42, .06);
  --sh-lg: 0 16px 40px rgba(15, 23, 42, .12);
  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-h); }
button { font-family: inherit; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

#app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sb-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; cursor: pointer; transition: background .15s var(--ease); }
.sb-head:hover { background: var(--bg); }
.logo-sm { width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; overflow: hidden; flex-shrink: 0; }
.logo-sm img { width: 100%; height: 100%; object-fit: cover; }
.sb-name { font-weight: 700; font-size: 15px; color: var(--text); }

.sb-nav { padding: 12px 10px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--r); color: var(--text-soft); font-weight: 500; font-size: 13.5px; cursor: pointer; user-select: none; transition: all .12s var(--ease); margin-bottom: 2px; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 4px; }

.sb-foot { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--text-mute); }
.logout-btn { background: none; border: none; cursor: pointer; color: var(--text-mute); padding: 6px; border-radius: var(--r-sm); }
.logout-btn:hover { background: var(--bg); color: var(--danger); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30; }
.page-title { font-size: 19px; font-weight: 700; color: var(--text); }
.content { padding: 24px 28px 60px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8.5px 15px; border-radius: var(--r); font-size: 13.5px; font-weight: 600; line-height: 1; border: 1px solid transparent; cursor: pointer; user-select: none; transition: all .15s var(--ease); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-h); box-shadow: var(--sh); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--bg); border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6.5px 11px; font-size: 12.5px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: .4px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); font-size: 14px; color: var(--text); outline: none; transition: border .12s var(--ease), box-shadow .12s var(--ease); font-family: inherit; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.field textarea { resize: vertical; min-height: 70px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid2 .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

.margin-pill { background: var(--surface); border: 1px solid var(--border); color: var(--text-soft); padding: 5px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; cursor: pointer; transition: all .12s var(--ease); }
.margin-pill:hover { border-color: var(--brand); color: var(--brand); }
.margin-pill.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--sh-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 15px; font-weight: 700; color: var(--text); }

.tbl-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sh-sm); }
.tbl-wrap table { width: 100%; border-collapse: collapse; }
.tbl-wrap th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-mute); text-transform: uppercase; letter-spacing: .5px; padding: 11px 14px; background: var(--bg); border-bottom: 1px solid var(--border); }
.tbl-wrap td { padding: 12px 14px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.tbl-wrap tbody tr:hover { background: var(--bg); }
.tbl-wrap tbody tr:last-child td { border-bottom: none; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--brand); }
.td-acts { display: flex; gap: 4px; align-items: center; }
.icon-btn { width: 30px; height: 30px; border-radius: 7px; background: transparent; border: none; cursor: pointer; color: var(--text-mute); display: inline-flex; align-items: center; justify-content: center; transition: all .12s var(--ease); }
.icon-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.edit:hover { color: var(--brand); }
.icon-btn.del:hover { background: var(--danger-tint); color: var(--danger); }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; line-height: 1.4; }
.badge-blue   { background: var(--brand-tint); color: var(--brand); }
.badge-green  { background: var(--success-tint); color: var(--success); }
.badge-red    { background: var(--danger-tint);  color: var(--danger); }
.badge-yellow { background: var(--warning-tint); color: var(--warning); }
.badge-gray   { background: var(--bg); color: var(--text-soft); }

.s-ok  { color: var(--success); font-weight: 600; }
.s-low { color: var(--warning); font-weight: 600; }
.s-out { color: var(--danger);  font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--sh-sm); transition: transform .15s var(--ease); }
.stat:hover { transform: translateY(-1px); box-shadow: var(--sh); }
.stat-val { font-size: 28px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.stat-lbl { font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }

#toasts { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; pointer-events: none; }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 3px solid var(--brand); border-radius: var(--r); padding: 11px 18px; box-shadow: var(--sh-lg); font-size: 13.5px; font-weight: 500; pointer-events: auto; animation: toastIn .25s var(--ease); max-width: 360px; }
.toast.ok  { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.toast.warn{ border-left-color: var(--warning); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

#overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px; overflow-y: auto; animation: overlayIn .18s var(--ease); }
#overlay.open { display: flex; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border-radius: var(--r-xl); width: 100%; max-width: 600px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--sh-lg); animation: modalIn .22s var(--ease); }
.modal.lg { max-width: 760px; }
.modal.xl { max-width: 960px; }
@keyframes modalIn { from { transform: translateY(20px) scale(.97); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title { font-size: 17px; font-weight: 700; color: var(--text); }
.modal-close { width: 34px; height: 34px; border-radius: 50%; background: transparent; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-mute); transition: all .15s var(--ease); }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-close svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; background: var(--bg); border-radius: 0 0 var(--r-xl) var(--r-xl); }

#login-screen { display: none; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: linear-gradient(135deg, #f8fafc, #e2e8f0); }
.login-box { background: var(--surface); border-radius: var(--r-xl); padding: 36px 32px; width: 100%; max-width: 400px; box-shadow: var(--sh-lg); }
.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-logo .logo-d { width: 48px; height: 48px; border-radius: 12px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; overflow: hidden; }
.login-logo .logo-d img { width: 100%; height: 100%; object-fit: cover; }
.login-title { font-size: 22px; font-weight: 800; color: var(--text); }
.login-sub { font-size: 12.5px; color: var(--text-mute); margin-top: 2px; }
.err-box, .ok-box { border-radius: var(--r); padding: 10px 14px; font-size: 13px; margin-bottom: 12px; }
.err-box { background: var(--danger-tint); color: var(--danger); border: 1px solid #fecaca; }
.ok-box  { background: var(--success-tint); color: var(--success); border: 1px solid #a7f3d0; }

.empty { text-align: center; padding: 50px 20px; color: var(--text-mute); }
.empty p { font-size: 15px; font-weight: 600; color: var(--text-soft); margin: 0 0 6px; }
.empty small { font-size: 13px; color: var(--text-mute); }

.page-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 14px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg); border-radius: var(--r); border: 1px solid var(--border); width: fit-content; }
.tab { padding: 8px 16px; border-radius: var(--r-sm); font-size: 13.5px; font-weight: 600; color: var(--text-soft); cursor: pointer; user-select: none; transition: all .15s var(--ease); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--brand); box-shadow: var(--sh-sm); }

.builder-grid { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .builder-grid { grid-template-columns: 1fr; } }
.cart-rail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; position: sticky; top: 80px; max-height: calc(100vh - 110px); display: flex; flex-direction: column; }
.cart-rail-head { padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--bg); font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; }
.cart-rail-body { flex: 1; overflow-y: auto; padding: 4px; min-height: 60px; max-height: 50vh; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); align-items: center; transition: background .3s var(--ease); }
.cart-line.flash-new { background: var(--success-tint); }
.cart-line.flash-upd { background: var(--brand-tint); }
.cart-line:last-child { border-bottom: none; }
.cart-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-meta { font-size: 11px; color: var(--text-mute); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.cart-qty { width: 56px; padding: 5px; text-align: center; border: 1px solid var(--border); border-radius: var(--r-sm); font-weight: 700; font-size: 13px; }
.cart-rail-totals { padding: 14px 16px; border-top: 1px solid var(--border); background: var(--bg); }
.cart-line-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; color: var(--text-soft); }
.cart-line-row.grand { font-size: 16px; font-weight: 800; color: var(--text); padding-top: 8px; border-top: 1px solid var(--border); margin-top: 6px; }
.search-box { position: relative; display: grid; grid-template-columns: 1fr 90px; gap: 8px; margin-bottom: 6px; }
.search-results { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); margin-top: 4px; box-shadow: var(--sh-lg); max-height: 280px; overflow-y: auto; z-index: 50; }
.search-result-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; transition: background .12s var(--ease); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.kbd-active { background: var(--brand-tint); }

.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.price-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; box-shadow: var(--sh-sm); transition: all .15s var(--ease); }
.price-card:hover { transform: translateY(-1px); box-shadow: var(--sh); }
.pc-name { font-weight: 600; font-size: 13.5px; color: var(--text); margin: 6px 0 4px; line-height: 1.3; min-height: 36px; }
.pc-ref { font-size: 11px; color: var(--text-mute); margin-bottom: 8px; font-family: ui-monospace, monospace; }
.pc-price { font-size: 22px; font-weight: 800; color: var(--brand); font-family: ui-monospace, monospace; }
.pc-lbl { font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }

.vinted-card { grid-column: 1 / -1; background: linear-gradient(135deg, #eff6ff, #f0f9ff); border: 1px solid #bfdbfe; border-radius: var(--r-lg); padding: 14px 16px; margin: 4px 0 10px; }
.vinted-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--brand); }
.vinted-toggle input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.vinted-price { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.vinted-price label { margin: 0; font-size: 11.5px; color: var(--text-soft); flex-shrink: 0; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.vinted-price input { flex: 1; background: var(--surface); border: 2px solid var(--brand); color: var(--brand); font-weight: 800; font-size: 22px; font-family: ui-monospace, monospace; padding: 8px 14px; border-radius: var(--r); text-align: right; }
.vinted-price small { color: var(--brand); font-weight: 600; flex-shrink: 0; }

.settings-grid { display: grid; grid-template-columns: 240px 1fr; gap: 18px; }
@media (max-width: 800px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-menu { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 6px; box-shadow: var(--sh-sm); height: fit-content; }
.sm-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r); cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--text-soft); transition: all .12s var(--ease); }
.sm-item:hover { background: var(--bg); color: var(--text); }
.sm-item.active { background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.sm-item svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.filters input, .filters select { padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--r); font-size: 13.5px; outline: none; background: var(--surface); }
.filters input:focus, .filters select:focus { border-color: var(--brand); }

@media (max-width: 720px) {
  .sidebar { width: 60px; }
  .sb-name, .nav-item span:not(svg), .user-info { display: none; }
  .sb-head { justify-content: center; padding: 14px 0; }
  .nav-item { justify-content: center; padding: 11px; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .modal { max-height: 100vh; max-width: 100%; border-radius: 0; }
  #overlay { padding: 0; }
}
