:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #6f7a86;
  --line: #e7ebf0;
  --primary: #2454d6;
  --primary-dark: #163da3;
  --success: #16845b;
  --danger: #c73d46;
  --warning: #ad6b09;
  --shadow: 0 18px 45px rgba(23, 32, 42, .08);
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; fill: currentColor; flex: 0 0 auto; }
input, select, textarea, button {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}
input[type="checkbox"] { width: auto; }
textarea { min-height: 104px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36, 84, 214, .12); }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #17202a, #2454d6);
  font-weight: 800;
}
.brand span, .user-menu span, .muted { color: var(--muted); }
.brand span, .user-menu span { display: block; font-size: 12px; margin-top: 2px; }
.nav { display: grid; gap: 6px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  color: #3e4a57;
  border-radius: var(--radius);
}
.nav a.active, .nav a:hover { background: #eef3ff; color: var(--primary); }
.main-area { min-width: 0; flex: 1; }
.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 4;
}
.global-search {
  flex: 1;
  max-width: 760px;
  position: relative;
}
.global-search svg { position: absolute; left: 13px; top: 12px; color: var(--muted); }
.global-search input { padding-left: 40px; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 12px; text-align: right; }
.content { padding: 28px; max-width: 1440px; margin: 0 auto; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.page-head h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: 0; }
.eyebrow { color: var(--primary); text-transform: uppercase; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.grid { display: grid; gap: 16px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-col { grid-template-columns: minmax(0, 1.4fr) minmax(320px, .6fr); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.pad { padding: 18px; }
.metric { padding: 18px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 30px; margin-top: 8px; }
.btn, button.btn {
  border: 0;
  border-radius: var(--radius);
  padding: 11px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  min-height: 42px;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: #eef1f5; color: #27313d; }
.btn.danger { background: #fff1f2; color: var(--danger); }
.btn.full { width: 100%; }
.icon-button {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
.mobile-menu { display: none; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 760px; background: #fff; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); background: #fbfcfe; }
tr:last-child td { border-bottom: 0; }
.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #eef1f5;
}
.status.new { color: #2454d6; background: #eef3ff; }
.status.contacted { color: #75610b; background: #fff8d8; }
.status.negotiation { color: #8a4c00; background: #fff1df; }
.status.won, .status.active { color: var(--success); background: #eaf8f2; }
.status.lost, .status.inactive { color: var(--danger); background: #fff1f2; }
.status.suspended { color: var(--warning); background: #fff8d8; }
.status.cancelled { color: var(--danger); background: #fff1f2; }
.status.pending { color: var(--warning); background: #fff8d8; }
.status.partial { color: #2454d6; background: #eef3ff; }
.status.paid { color: var(--success); background: #eaf8f2; }
.status.stored { color: #2454d6; background: #eef3ff; }
.status.sent { color: var(--warning); background: #fff8d8; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-stack { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: #34404c; font-weight: 650; }
.span-2 { grid-column: span 2; }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.notice, .toast {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 12px 0;
}
.notice.success, .toast.success { background: #eaf8f2; color: var(--success); }
.notice.danger, .toast.danger { background: #fff1f2; color: var(--danger); }
.toast { animation: slideIn .2s ease; }
.toast.hide { opacity: 0; transition: opacity .25s ease; }
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(140deg, rgba(36,84,214,.11), rgba(255,255,255,0) 32%),
    var(--bg);
}
.auth-card, .install-card {
  width: min(100%, 440px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.auth-card h1, .install-card h1 { margin: 14px 0 8px; font-size: 34px; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(23,32,42,.42);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 30;
}
.modal.open { display: flex; }
.modal-panel { width: min(720px, 100%); max-height: 90vh; overflow: auto; }
.activity-list { display: grid; gap: 12px; }
.activity-item { display: grid; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; padding-bottom: 0; }
.detail-grid { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px 16px; margin-top: 12px; }
.detail-grid span { color: var(--muted); }
.detail-grid strong { overflow-wrap: anywhere; }
.checkline { display: flex; align-items: center; gap: 9px; }
.check-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.asset-template { background: #fbfcfe; box-shadow: none; }
.asset-tree { display: grid; justify-items: start; gap: 8px; }
.asset-tree a, .asset-tree strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fff;
}
.asset-tree small { color: var(--muted); }
.tree-connector { color: var(--muted); padding-left: 18px; }
.chart-bars { display: flex; align-items: end; height: 180px; gap: 10px; padding-top: 20px; }
.chart-bars div { flex: 1; background: linear-gradient(180deg, #2454d6, #7b9bff); border-radius: 6px 6px 0 0; min-height: 16px; }
@keyframes slideIn { from { transform: translateY(-6px); opacity: .4; } to { transform: none; opacity: 1; } }

@media (max-width: 980px) {
  .sidebar { position: fixed; left: -280px; z-index: 20; transition: left .2s ease; }
  body.sidebar-open .sidebar { left: 0; }
  .mobile-menu { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .user-menu div { display: none; }
  .stats-grid, .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .content { padding: 18px; }
  .page-head { display: grid; }
  .stats-grid, .two-col, .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .topbar { gap: 10px; }
  .global-search input { font-size: 14px; }
  .auth-card, .install-card { padding: 22px; }
}
