:root {
  --bg: #090b10;
  --panel: rgba(18, 23, 34, 0.92);
  --panel-2: rgba(25, 32, 46, 0.86);
  --line: rgba(255,255,255,0.09);
  --text: #f7f8fb;
  --muted: #9ba5b8;
  --accent: #d9b66f;
  --accent-2: #8be9d3;
  --danger: #ff7d8a;
  --success: #79e0a3;
  --warning: #ffd166;
  --shadow: 0 24px 70px rgba(0,0,0,.35);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: 'Montserrat', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 8% 10%, rgba(217, 182, 111, .18), transparent 30%),
    radial-gradient(circle at 85% 15%, rgba(139, 233, 211, .10), transparent 26%),
    linear-gradient(135deg, #07080d 0%, #101522 100%);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 280px;
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: rgba(8, 11, 17, .74);
  backdrop-filter: blur(16px);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 48px; height: 48px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(217,182,111,.95), rgba(255,255,255,.12));
  color: #090b10;
  font-weight: 800;
  box-shadow: 0 12px 40px rgba(217,182,111,.18);
}
.brand-title { font-weight: 800; letter-spacing: .02em; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; text-transform: uppercase; letter-spacing: .13em; }
.nav { display: grid; gap: 8px; margin-top: 36px; }
.nav-link {
  padding: 13px 14px;
  border-radius: 15px;
  color: var(--muted);
  border: 1px solid transparent;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-color: var(--line);
}
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; }
.user-pill {
  padding: 12px 14px;
  border-radius: 15px;
  background: rgba(255,255,255,.05);
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.main {
  flex: 1;
  margin-left: 280px;
  padding: 30px;
  max-width: 1480px;
}
.main-centered {
  margin-left: 0;
  display: grid;
  place-items: center;
  max-width: none;
  width: 100%;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}
.topbar h1 { margin: 0 0 6px; font-size: clamp(28px, 3vw, 44px); letter-spacing: -.04em; }
.topbar p { margin: 0; color: var(--muted); }
.topbar-actions, .action-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.button, .ghost-button {
  border: 0;
  border-radius: 15px;
  padding: 12px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 700;
  transition: transform .15s ease, background .15s ease, border .15s ease;
}
.button:hover, .ghost-button:hover { transform: translateY(-1px); }
.button {
  background: linear-gradient(135deg, var(--accent), #f2dcab);
  color: #10131a;
  box-shadow: 0 15px 45px rgba(217,182,111,.16);
}
.button.secondary { background: rgba(255,255,255,.09); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.ghost-button { background: rgba(255,255,255,.045); color: var(--text); border: 1px solid var(--line); }
.ghost-button.danger { color: var(--danger); border-color: rgba(255,125,138,.28); }
.full { width: 100%; }
.small-button { padding: 9px 12px; min-height: 38px; border-radius: 12px; font-size: 13px; }
.tiny-button { padding: 7px 10px; min-height: 32px; border-radius: 11px; font-size: 12px; }

.flash-stack { display: grid; gap: 10px; margin-bottom: 18px; }
.flash {
  padding: 13px 15px;
  border-radius: 16px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  color: var(--text);
}
.flash.success { border-color: rgba(121,224,163,.3); color: var(--success); }
.flash.error { border-color: rgba(255,125,138,.34); color: var(--danger); }
.flash.info { border-color: rgba(139,233,211,.3); color: var(--accent-2); }

.panel, .stat-card, .auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 22px; margin-bottom: 22px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.panel-head h2 { margin: 0; font-size: 20px; }
.panel-head p { margin: 6px 0 0; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.empty {
  padding: 26px;
  border-radius: 18px;
  background: rgba(255,255,255,.04);
  color: var(--muted);
  text-align: center;
}

.cards-grid { display: grid; gap: 16px; margin-bottom: 22px; }
.cards-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cards-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card { padding: 20px; position: relative; overflow: hidden; }
.stat-card.glow::after {
  content: '';
  position: absolute;
  inset: auto -20% -70% 20%;
  height: 130px;
  background: radial-gradient(circle, rgba(217,182,111,.32), transparent 65%);
}
.stat-card span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.stat-card strong { display: block; font-size: 32px; letter-spacing: -.04em; }
.stat-card small { color: var(--muted); }
.stat-card.small { padding: 16px; }
.stat-card.small strong { font-size: 23px; }
.compact-stats { margin-top: -6px; }

.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.mini-list { display: grid; gap: 10px; }
.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.055);
}
.mini-row div { display: grid; gap: 4px; }
.mini-row span { color: var(--muted); font-size: 12px; }

.auth-card {
  width: min(440px, calc(100vw - 32px));
  padding: 30px;
}
.auth-brand { margin-bottom: 26px; }
.auth-card h2 { margin: 0 0 8px; font-size: 30px; }
.form-stack { display: grid; gap: 16px; margin-top: 22px; }
.small-link { display: inline-block; margin-top: 18px; color: var(--muted); font-size: 13px; }
.otp-input { text-align: center; letter-spacing: .5em; font-size: 22px; font-weight: 800; }

label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.055);
  color: var(--text);
  border-radius: 15px;
  padding: 13px 14px;
  outline: none;
}
select option { background: #121722; color: var(--text); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(217,182,111,.55); box-shadow: 0 0 0 4px rgba(217,182,111,.08); }
label small { color: var(--muted); line-height: 1.45; }

.filters { display: grid; grid-template-columns: 1.4fr repeat(5, minmax(130px, 1fr)) auto; gap: 12px; align-items: end; }
.filter-actions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.wide-label { margin-top: 16px; }
.sheet-form { padding-bottom: 80px; }
.items-list { display: grid; gap: 12px; }
.item-card { padding: 14px; border-radius: 18px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.item-grid { display: grid; grid-template-columns: 2fr .65fr .75fr .9fr .95fr 1.4fr .75fr auto; gap: 10px; align-items: end; }
.item-sum { display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.item-sum strong { color: var(--text); min-height: 45px; display: flex; align-items: center; }
.form-total { margin-top: 18px; padding: 18px; border-radius: 18px; background: rgba(217,182,111,.09); border: 1px solid rgba(217,182,111,.17); display: flex; justify-content: space-between; align-items: center; }
.form-total span { color: var(--muted); }
.form-total strong { font-size: 26px; }
.sticky-actions {
  position: fixed;
  right: 30px;
  bottom: 24px;
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(9,11,16,.82);
  backdrop-filter: blur(14px);
  z-index: 9;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
tfoot td { border-bottom: 0; background: rgba(255,255,255,.035); }
.compact table { min-width: 520px; }
.compact th, .compact td { padding: 11px 10px; }
.row-actions { text-align: right; }
.badge, .lock-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,.11);
  background: rgba(255,255,255,.06);
  color: var(--text);
  white-space: nowrap;
}
.badge.big, .lock-dot.big { padding: 9px 13px; }
.lock-dot { color: var(--warning); border-color: rgba(255,209,102,.28); background: rgba(255,209,102,.08); margin-left: 6px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 18px; color: var(--muted); }

.sheet-head-panel { padding: 26px; }
.sheet-title-row { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; margin-bottom: 10px; }
.sheet-title-row h2 { margin: 0 0 12px; font-size: 32px; letter-spacing: -.03em; }
.meta-line { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.meta-line span { padding: 7px 10px; border-radius: 999px; background: rgba(255,255,255,.05); border: 1px solid var(--line); }
.sheet-actions { display: grid; gap: 12px; justify-items: end; }
.note-box { margin-top: 20px; padding: 16px; border-radius: 17px; background: rgba(255,255,255,.045); border: 1px solid var(--line); color: #d9dfec; white-space: pre-wrap; }
.danger-zone { display: flex; justify-content: flex-end; margin-bottom: 34px; }

@media (max-width: 1180px) {
  .cards-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .item-name, .item-comment { grid-column: span 2; }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .app-shell { display: block; }
  .sidebar {
    position: static;
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .main { margin-left: 0; padding: 18px; }
  .topbar, .sheet-title-row { display: grid; }
  .sheet-actions { justify-items: start; }
  .split-grid, .cards-grid.three, .cards-grid.four { grid-template-columns: 1fr; }
  .filters, .form-grid, .item-grid { grid-template-columns: 1fr; }
  .item-name, .item-comment { grid-column: auto; }
  .sticky-actions { left: 18px; right: 18px; bottom: 14px; justify-content: stretch; }
  .sticky-actions > * { flex: 1; }
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.export-actions, .sheet-row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.export-actions { justify-content: flex-start; }
.export-panel { margin-top: -10px; }
.stat-card small { display: block; color: var(--muted); margin-top: 6px; font-size: 12px; }

@media (max-width: 860px) {
  .inline-form { grid-template-columns: 1fr; }
  .sheet-row-actions { justify-content: flex-start; }
}
