:root {
  --bg: #070a12;
  --panel: #0d1321;
  --panel-strong: #111827;
  --surface: rgba(17, 24, 39, .86);
  --surface-soft: rgba(30, 41, 59, .7);
  --line: rgba(148, 163, 184, .16);
  --line-strong: rgba(148, 163, 184, .28);
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-strong: #cbd5e1;
  --blue: #38bdf8;
  --blue-strong: #2563eb;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #fb7185;
  --violet: #a78bfa;
  --gray: #94a3b8;
  --shadow: 0 22px 70px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(56, 189, 248, .18), transparent 34%),
    radial-gradient(circle at 95% 18%, rgba(167, 139, 250, .14), transparent 28%),
    linear-gradient(135deg, #070a12 0%, #0b1020 52%, #070a12 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; }

a { color: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: rgba(8, 13, 25, .78);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand-lockup { display: flex; gap: 13px; align-items: center; padding: 0 6px 10px; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: #03131f; font-weight: 900; background: linear-gradient(135deg, var(--blue), var(--green)); box-shadow: 0 14px 28px rgba(56, 189, 248, .22); }
.brand-name, .brand-subtitle { display: block; }
.brand-name { font-size: 16px; font-weight: 800; letter-spacing: .01em; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 1px; }

.side-nav { display: grid; gap: 8px; }
.side-nav a, .logout-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 11px 13px;
  border-radius: 8px;
  color: var(--muted-strong);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.side-nav a:hover, .logout-link:hover { background: rgba(56, 189, 248, .1); border-color: rgba(56, 189, 248, .22); color: var(--text); }
.logout-link { margin-top: auto; color: #fecdd3; }

.main-area { min-width: 0; padding: 34px clamp(22px, 4vw, 52px) 52px; }
.page-header { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 6px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 46px); line-height: 1.05; letter-spacing: 0; }

.dashboard-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card, .filters, .table-card, .data-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 24, 39, .92), rgba(15, 23, 42, .82));
  box-shadow: var(--shadow);
}
.metric-card { min-height: 116px; border-radius: 8px; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-value { font-size: 32px; line-height: 1; font-weight: 850; margin-top: 12px; }
.metric-note { margin-top: 8px; color: var(--muted); font-size: 12px; }

.filters { border-radius: 8px; padding: 16px; margin-bottom: 18px; display: grid; grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(170px, .8fr)) auto; gap: 10px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.toolbar-spacer { min-height: 1px; }

input, select, button, .btn, .link-btn, .small-btn {
  border: 1px solid var(--line-strong);
  background: rgba(15, 23, 42, .94);
  color: var(--text);
  padding: 11px 13px;
  border-radius: 8px;
  outline: none;
}
input::placeholder { color: #64748b; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(56, 189, 248, .12); }
button { cursor: pointer; }
.btn, .link-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.btn-primary, .btn, .link-btn { background: linear-gradient(135deg, var(--blue-strong), #0891b2); border-color: rgba(56, 189, 248, .52); color: #fff; font-weight: 800; }
.btn-primary:hover, .btn:hover, .link-btn:hover { filter: brightness(1.08); }
.small-btn { padding: 8px 10px; font-size: 12px; font-weight: 800; }
.danger { background: rgba(225, 29, 72, .18); border-color: rgba(251, 113, 133, .5); color: #fecdd3; }

.table-card { border-radius: 8px; overflow: hidden; }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 920px; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th { background: rgba(15, 23, 42, .96); color: var(--muted); font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
tbody tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(255, 255, 255, .025); }
.muted { color: var(--muted); }

.status, .badge { display: inline-flex; align-items: center; justify-content: center; min-height: 26px; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 850; border: 1px solid currentColor; background: rgba(148, 163, 184, .12); color: var(--gray); white-space: nowrap; }
.status-available, .status-active, .active-true { color: var(--green); background: rgba(52, 211, 153, .13); }
.status-reminded, .status-no_stock, .status-replace_no_stock { color: var(--yellow); background: rgba(251, 191, 36, .13); }
.status-bad, .status-bad_blocked, .status-bad_not_found, .status-bad_wrong_password, .status-cancelled { color: var(--red); background: rgba(251, 113, 133, .13); }
.status-disabled, .active-false { color: var(--gray); background: rgba(148, 163, 184, .12); }
.status-renewed, .status-issued, .status-reissued { color: var(--blue); background: rgba(56, 189, 248, .13); }

.alert-error { margin-bottom: 18px; padding: 12px 14px; border: 1px solid var(--red); border-radius: 12px; color: #fecdd3; background: rgba(251, 113, 133, .12); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.mobile-cards { display: none; }
.data-card { border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-title { font-weight: 850; font-size: 16px; word-break: break-word; }
.card-subtitle { color: var(--muted); font-size: 12px; margin-top: 3px; }
.card-row { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px; margin: 9px 0; font-size: 14px; }
.card-label { color: var(--muted); }
.card-value { min-width: 0; word-break: break-word; }

.mobile-nav { display: none; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 230px minmax(0, 1fr); }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  body { padding-bottom: 82px; }
  .app-shell { display: block; min-height: auto; }
  .sidebar { display: none; }
  .main-area { padding: 22px 14px 24px; }
  .page-header { margin-bottom: 18px; }
  h1 { font-size: 30px; }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric-card { min-height: 100px; padding: 14px; }
  .metric-value { font-size: 26px; }
  .filters { grid-template-columns: 1fr; padding: 12px; }
  input, select, button, .btn, .link-btn { width: 100%; min-height: 44px; }
  .toolbar { display: grid; grid-template-columns: 1fr; }
  .table-card { display: none; }
  .mobile-cards { display: block; }
  .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 14px; }
  .actions a, .actions button { width: 100%; }
  .card-row { grid-template-columns: 92px minmax(0, 1fr); }
  .mobile-nav { position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: rgba(8, 13, 25, .92); backdrop-filter: blur(18px); box-shadow: var(--shadow); }
  .mobile-nav a { min-height: 44px; display: grid; place-items: center; color: var(--muted-strong); text-decoration: none; font-size: 12px; font-weight: 800; border-radius: 6px; }
  .mobile-nav a:hover { background: rgba(56, 189, 248, .11); color: var(--text); }
}

@media (max-width: 420px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .actions { grid-template-columns: 1fr; }
  .mobile-nav a { font-size: 11px; }
}
