/* WMS — Modern Claymorphism design system */
:root {
  --bg: #EEF3FA; --surface: #F4F7FC; --blue: #4F83E8; --blue-2: #77A6F7; --navy: #263752;
  --text: #27364B; --text-2: #8290A5; --ok: #45B98A; --warn: #F0B75C; --bad: #E87575; --border: #E1E8F2;
  --sh-out: 6px 6px 14px rgba(166,180,200,.25), -6px -6px 14px rgba(255,255,255,.85);
  --sh-hover: 8px 10px 20px rgba(150,165,190,.22), -6px -6px 14px rgba(255,255,255,.9);
  --sh-in: inset 3px 3px 7px rgba(166,180,200,.28), inset -3px -3px 7px rgba(255,255,255,.9);
  --sh-press: inset 4px 4px 9px rgba(40,70,140,.25), inset -3px -3px 7px rgba(255,255,255,.18);
  --r-lg: 24px; --r-md: 16px; --r-sm: 12px;
  --font: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar-w: 268px;
  --bs-body-font-family: var(--font); --bs-body-color: var(--text); --bs-body-bg: var(--bg);
}
* { -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); }
body { font-family: var(--font); font-size: 14px; color: var(--text); margin: 0; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 700; margin: 0; }
small, .small { font-size: 12.5px; }
.muted { color: var(--text-2); }
a { color: var(--blue); text-decoration: none; }
.link-soft { color: var(--blue); font-weight: 600; font-size: 13px; cursor: pointer; }
:focus-visible { outline: 3px solid rgba(79,131,232,.45); outline-offset: 2px; }
[data-lucide] { width: 18px; height: 18px; stroke-width: 2; flex: none; }

/* Surfaces */
.clay-card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-out); padding: 24px; transition: box-shadow .2s; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }

/* Buttons */
.btn-clay { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer;
  font: 600 14px var(--font); color: var(--text); background: var(--surface); padding: 11px 20px; border-radius: 14px;
  box-shadow: var(--sh-out); transition: box-shadow .18s, transform .18s; text-decoration: none; }
.btn-clay:hover { box-shadow: var(--sh-hover); transform: translateY(-1px); color: var(--text); }
.btn-clay:active { box-shadow: var(--sh-in); transform: none; }
.btn-clay.primary { color: #fff; background: linear-gradient(145deg, var(--blue-2), var(--blue)); }
.btn-clay.primary:hover { color: #fff; }
.btn-clay.primary:active { box-shadow: var(--sh-press); }
.btn-clay.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 12px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--surface); color: var(--text); box-shadow: var(--sh-out); transition: box-shadow .18s; }
.icon-btn:hover { box-shadow: var(--sh-hover); } .icon-btn:active { box-shadow: var(--sh-in); }

/* Form */
.clay-input, .form-select.clay-input { background: var(--bg); border: 1px solid transparent; border-radius: var(--r-sm);
  box-shadow: var(--sh-in); padding: 11px 14px; font-size: 14px; color: var(--text); }
.clay-input:focus { background: var(--bg); border-color: var(--blue-2); box-shadow: var(--sh-in), 0 0 0 3px rgba(79,131,232,.18); color: var(--text); }
.clay-input.is-invalid { border-color: var(--bad); }
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.invalid-feedback { color: var(--bad); font-size: 12.5px; }
.form-narrow { max-width: 620px; }
.input-reveal { position: relative; } .input-reveal .clay-input { padding-right: 46px; }
.reveal-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--text-2); padding: 6px; cursor: pointer; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; } .filter-bar .clay-input { flex: 1 1 180px; min-width: 0; }
.perm-item { display: flex; gap: 12px; align-items: flex-start; padding: 9px 4px; cursor: pointer; border-bottom: 1px solid var(--border); }
.perm-item:last-child { border-bottom: 0; } .perm-item small { display: block; color: var(--text-2); }
.perm-item input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--blue); flex: none; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex: none; position: fixed; inset: 0 auto 0 0; z-index: 1040; display: flex; flex-direction: column;
  background: var(--surface); box-shadow: 8px 0 24px rgba(166,180,200,.2); padding: 20px 16px; transition: transform .25s; overflow-y: auto; }
.sidebar-brand { display: flex; gap: 12px; align-items: center; color: var(--navy); padding: 4px 8px 20px; }
.sidebar-brand strong { display: block; font-size: 17px; line-height: 1.1; }
.sidebar-brand small { color: var(--text-2); display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, var(--blue-2), var(--blue)); box-shadow: var(--sh-out); }
.brand-mark.sm { width: 42px; height: 42px; border-radius: 14px; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.nav-group { margin: 18px 12px 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.nav-link-clay { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px; color: var(--text); font-weight: 500; transition: box-shadow .18s, color .18s; }
.nav-link-clay:hover { color: var(--blue); }
.nav-link-clay.active { background: var(--bg); color: var(--blue); font-weight: 600; box-shadow: var(--sh-in); }
.sidebar-foot { display: flex; justify-content: space-between; align-items: center; padding: 14px 10px 0; font-size: 12px; color: var(--text-2); }
.conn { display: inline-flex; align-items: center; gap: 7px; } .conn .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.conn.offline .dot { background: var(--bad); }
.sidebar-backdrop { display: none; }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: 14px; padding: 14px 28px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px)); background: rgba(238,243,250,.88); backdrop-filter: blur(8px); }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; } .crumbs [data-lucide] { width: 14px; height: 14px; }
.crumbs span { color: var(--text); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; border: 0; background: var(--surface); color: var(--text); padding: 6px 12px 6px 6px; border-radius: 18px; box-shadow: var(--sh-out); cursor: pointer; }
.user-chip strong { display: block; font-size: 13px; line-height: 1.2; } .user-chip small { color: var(--text-2); }
.avatar { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; background: linear-gradient(145deg, var(--blue-2), var(--blue)); }
.clay-menu { border: 0; border-radius: var(--r-md); background: var(--surface); box-shadow: var(--sh-hover); padding: 8px; min-width: 200px; }
.clay-menu .dropdown-item { display: flex; align-items: center; gap: 10px; border-radius: 10px; padding: 9px 12px; color: var(--text); width: 100%; }
.clay-menu .dropdown-item:hover { background: var(--bg); }
.content { padding: 8px 28px 40px; padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 8px 0 24px; flex-wrap: wrap; }

/* Data display */
.kpi { display: flex; align-items: center; gap: 16px; padding: 20px; }
.kpi:hover { box-shadow: var(--sh-hover); }
.kpi-icon { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; box-shadow: var(--sh-in); background: var(--bg); }
.tone-blue { color: var(--blue); } .tone-green { color: var(--ok); } .tone-amber { color: var(--warn); } .tone-red { color: var(--bad); }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
.table-clay { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table-clay th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-clay td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-clay tr:last-child td { border-bottom: 0; }
.table-clay tbody tr:hover td { background: rgba(79,131,232,.04); }
.actions { white-space: nowrap; } .actions .icon-btn { width: 34px; height: 34px; margin-left: 4px; }
.badge-clay { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--text); box-shadow: var(--sh-in); }
.badge-clay.ok { color: #2c8f69; } .badge-clay.bad { color: #c94f4f; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.activity li:last-child { border-bottom: 0; } .activity time { margin-left: auto; white-space: nowrap; font-size: 12.5px; }
.empty { text-align: center; padding: 40px 16px; color: var(--text-2); } .empty [data-lucide] { width: 36px; height: 36px; margin-bottom: 8px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; flex-wrap: wrap; gap: 10px; }
.matrix .group-row td { background: var(--bg); font-weight: 700; padding: 8px 14px; }
.matrix .yes { color: var(--ok); width: 17px; } .matrix .no { color: var(--text-2); }
.diff { font-size: 12px; background: var(--bg); border-radius: var(--r-sm); padding: 12px; box-shadow: var(--sh-in); max-width: 420px; max-height: 240px; overflow: auto; margin: 8px 0 0; }

/* Toast & update bar */
.toast-stack { position: fixed; top: calc(16px + env(safe-area-inset-top, 0px)); right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 32px)); }
.toast-clay { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--sh-hover); border-left: 5px solid var(--blue); animation: toast-in .25s ease-out; }
.toast-clay.success { border-color: var(--ok); } .toast-clay.danger { border-color: var(--bad); } .toast-clay.warning { border-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.update-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 2000; display: flex; align-items: center; gap: 16px;
  background: var(--surface); padding: 12px 14px 12px 20px; border-radius: 18px; box-shadow: var(--sh-hover); }

/* Auth */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-wrap { display: grid; grid-template-columns: 1.1fr 1fr; gap: 56px; align-items: center; max-width: 980px; width: 100%; }
.auth-aside h1 { font-size: 38px; line-height: 1.15; margin: 28px 0 14px; color: var(--navy); }
.auth-aside p { color: var(--text-2); font-size: 16px; max-width: 360px; }
.auth-aside .brand-mark { width: 72px; height: 72px; border-radius: 24px; } .auth-aside .brand-mark [data-lucide] { width: 34px; height: 34px; }
.auth-card { padding: 36px; } .auth-card h2 { font-size: 22px; margin-bottom: 6px; } .auth-card .muted { margin-bottom: 24px; }
.error-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); font-family: var(--font); color: var(--text); }
.error-card { text-align: center; max-width: 420px; padding: 40px; } .error-code { font-size: 64px; font-weight: 700; color: var(--blue); line-height: 1; margin-bottom: 8px; }
.error-card p { color: var(--text-2); margin-bottom: 24px; }

/* Responsive */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-105%); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(38,55,82,.35); z-index: 1035; }
  .main { margin-left: 0; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .auth-wrap { grid-template-columns: 1fr; gap: 28px; max-width: 460px; }
  .auth-aside h1 { font-size: 28px; } .auth-aside { text-align: left; }
}
@media (max-width: 575.98px) {
  h1 { font-size: 22px; } .clay-card { padding: 18px; border-radius: 20px; }
  .btn-clay, .icon-btn, .clay-input { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
