:root {
  --bg: #050505;
  --panel: #0d0d0e;
  --panel-raised: #121214;
  --panel-soft: #171719;
  --line: #262629;
  --line-strong: #37373b;
  --text: #f4f4f5;
  --muted: #96969d;
  --faint: #696970;
  --white: #ffffff;
  --black: #050505;
  --green: #45d483;
  --amber: #f0b84b;
  --red: #f16d70;
  --blue: #68a6ff;
  --radius: 18px;
  --radius-small: 12px;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.48);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: #0a0a0b; color: var(--text); padding: 12px 13px; outline: none; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
input:focus, select:focus, textarea:focus { border-color: #6c6c72; box-shadow: 0 0 0 3px rgba(255,255,255,.07); background: #0f0f10; }
input:disabled, select:disabled { opacity: .46; cursor: not-allowed; }
textarea { resize: vertical; }
label { display: grid; gap: 7px; color: #b8b8bd; font-size: 12px; font-weight: 650; letter-spacing: .01em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(22px, 2vw, 30px); letter-spacing: -.035em; }
h2 { margin-bottom: 10px; font-size: clamp(25px, 3vw, 38px); letter-spacing: -.045em; line-height: 1.05; }
h3 { margin-bottom: 0; font-size: 16px; letter-spacing: -.02em; }
.is-hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 7px; color: var(--faint); font-size: 10px; line-height: 1; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }

#loading-bar { position: fixed; z-index: 1000; inset: 0 auto auto 0; width: 0; height: 2px; opacity: 0; background: var(--white); transition: width .28s ease, opacity .2s; }
#loading-bar.is-loading { width: 70%; opacity: 1; }
#loading-bar.is-done { width: 100%; opacity: 0; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 50% 22%, #1b1b1d 0, #09090a 33%, #050505 70%); }
.login-panel { width: min(430px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 26px; background: rgba(12,12,13,.94); box-shadow: var(--shadow); }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 30px; border-radius: 17px; background: var(--white); color: var(--black); font-size: 21px; font-weight: 900; letter-spacing: -.06em; }
.brand-mark-small { width: 38px; height: 38px; margin: 0; border-radius: 11px; font-size: 14px; }
.login-panel h1 { margin-bottom: 12px; font-size: 34px; }
.login-copy { color: var(--muted); margin-bottom: 28px; }
.stack-form { display: grid; gap: 16px; }
.security-note { margin: 22px 0 0; color: var(--faint); text-align: center; font-size: 12px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(240,184,75,.09); }
.status-green { background: var(--green); box-shadow: 0 0 0 4px rgba(69,212,131,.09); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 16px; border-right: 1px solid var(--line); background: #080809; }
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 2px 8px 28px; }
.sidebar-brand div:last-child { display: grid; gap: 3px; }
.sidebar-brand strong { font-size: 14px; }
.sidebar-brand span { color: var(--faint); font-size: 11px; }
.primary-nav { display: grid; gap: 4px; }
.nav-item { min-height: 43px; display: flex; justify-content: space-between; align-items: center; border: 0; border-radius: 11px; background: transparent; padding: 0 12px; color: #85858c; font-size: 13px; font-weight: 620; text-align: left; transition: color .16s, background .16s; }
.nav-item:hover { color: var(--text); background: #111113; }
.nav-item.is-active { color: var(--white); background: #1a1a1d; }
.lock-glyph { color: #5f5f66; font-size: 8px; }
.sidebar-footer { margin-top: auto; padding: 18px 8px 2px; border-top: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.user-avatar { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: #151517; font-size: 11px; font-weight: 800; }
.user-chip div { min-width: 0; display: grid; gap: 3px; }
.user-chip strong, .user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { font-size: 12px; }
.user-chip div span { color: var(--faint); font-size: 10px; text-transform: capitalize; }

.workspace { min-width: 0; }
.topbar { min-height: 92px; display: flex; align-items: center; gap: 18px; padding: 18px 34px; border-bottom: 1px solid var(--line); background: rgba(5,5,5,.86); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 40; }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.security-pill { display: flex; align-items: center; min-height: 36px; padding: 0 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; }
.security-pill.is-unlocked { color: var(--green); border-color: rgba(69,212,131,.25); background: rgba(69,212,131,.05); }
.security-pill.is-unlocked .status-dot { background: var(--green); }
.menu-button { display: none !important; }
.view { display: none; max-width: 1500px; margin: 0 auto; padding: 36px 34px 70px; }
.view.is-active { display: block; animation: view-in .2s ease-out; }
@keyframes view-in { from { opacity: .2; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); border-radius: 11px; padding: 0 15px; background: var(--panel-soft); color: var(--text); font-size: 12px; font-weight: 750; transition: transform .15s, background .15s, border-color .15s; }
.button:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button-primary { border-color: var(--white); background: var(--white); color: var(--black); }
.button-primary:hover { background: #e3e3e5; }
.button-secondary { background: #151517; }
.button-danger { border-color: rgba(241,109,112,.35); background: rgba(241,109,112,.1); color: var(--red); }
.button-wide { width: 100%; }
.text-button { padding: 0; border: 0; background: none; color: #a6a6ad; font-size: 11px; font-weight: 700; }
.text-button:hover { color: var(--white); }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 11px; background: #111113; }

.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 30px; margin-bottom: 32px; padding: 22px 4px 12px; }
.hero-row > div:first-child { max-width: 720px; }
.hero-row.compact { padding-top: 4px; }
.hero-row .muted { margin-bottom: 0; }
.inline-actions { display: flex; align-items: center; gap: 10px; }
.inline-actions select { width: auto; min-width: 125px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric-grid-finance { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric-card { min-height: 142px; display: flex; flex-direction: column; justify-content: space-between; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, #111113, #0b0b0c); }
.metric-label { color: var(--faint); font-size: 10px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.metric-value { margin: 18px 0 2px; font-size: clamp(25px, 2.5vw, 36px); font-weight: 760; letter-spacing: -.055em; }
.metric-detail { color: var(--muted); font-size: 11px; }
.metric-value.is-locked { color: #4e4e53; letter-spacing: .05em; }
.split-grid { display: grid; grid-template-columns: 1.12fr .88fr; gap: 16px; margin-bottom: 16px; }
.panel { margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.panel-heading { min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-table .panel-heading { min-height: 78px; }
.count-badge { min-width: 32px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; text-align: center; }
.team-overview { display: grid; gap: 0; padding: 7px 20px 12px; }
.team-row { display: grid; grid-template-columns: minmax(150px, 1.1fr) 2fr auto; align-items: center; gap: 14px; min-height: 52px; border-bottom: 1px solid #1d1d1f; font-size: 12px; }
.team-row:last-child { border-bottom: 0; }
.team-bar { height: 5px; overflow: hidden; border-radius: 999px; background: #1e1e21; }
.team-bar span { display: block; height: 100%; border-radius: inherit; background: #c7c7ca; }
.bar-0 { width: 0; }
.bar-10 { width: 10%; }
.bar-20 { width: 20%; }
.bar-30 { width: 30%; }
.bar-40 { width: 40%; }
.bar-50 { width: 50%; }
.bar-60 { width: 60%; }
.bar-70 { width: 70%; }
.bar-80 { width: 80%; }
.bar-90 { width: 90%; }
.bar-100 { width: 100%; }
.team-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.alert-list { padding: 8px 20px 12px; }
.alert-item { display: flex; align-items: center; gap: 12px; min-height: 57px; border-bottom: 1px solid #1d1d1f; }
.alert-item:last-child { border-bottom: 0; }
.alert-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: rgba(240,184,75,.09); color: var(--amber); font-size: 11px; }
.alert-copy { min-width: 0; flex: 1; display: grid; gap: 4px; }
.alert-copy strong, .alert-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-copy strong { font-size: 12px; }
.alert-copy span { color: var(--muted); font-size: 10px; }
.empty-state { padding: 42px 20px; color: var(--faint); text-align: center; font-size: 12px; }

.filter-bar { display: grid; grid-template-columns: minmax(300px, 1fr) 190px 170px; gap: 10px; margin-bottom: 12px; }
.search-box { position: relative; display: block; }
.search-box span { position: absolute; left: 14px; top: 12px; color: var(--faint); font-size: 18px; }
.search-box input { padding-left: 42px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.chip { min-height: 31px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; }
.chip.is-active { border-color: #55555b; background: #1b1b1e; color: var(--white); }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { height: 42px; padding: 0 15px; border-bottom: 1px solid var(--line); color: var(--faint); font-size: 9px; font-weight: 850; letter-spacing: .1em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { height: 60px; padding: 10px 15px; border-bottom: 1px solid #1b1b1d; color: #c5c5ca; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .13s; }
tbody tr[data-asset-id]:hover { background: #121214; cursor: pointer; }
.table-primary { display: grid; gap: 3px; }
.table-primary strong { color: var(--text); font-size: 12px; }
.table-primary span { color: var(--faint); font-size: 10px; }
.asset-code { color: #a4a4aa; font-size: 10px; font-weight: 800; letter-spacing: .07em; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 23px; padding: 0 8px; border-radius: 999px; background: #1a1a1d; color: #aaaab0; font-size: 9px; font-weight: 750; text-transform: capitalize; }
.status-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-badge.status-available, .status-badge.status-active { color: var(--green); background: rgba(69,212,131,.08); }
.status-badge.status-in_use, .status-badge.status-trial { color: var(--blue); background: rgba(104,166,255,.08); }
.status-badge.status-repair { color: var(--amber); background: rgba(240,184,75,.08); }
.status-badge.status-missing, .status-badge.status-expired, .status-badge.status-written_off { color: var(--red); background: rgba(241,109,112,.08); }

.locked-panel { max-width: 680px; margin: 10vh auto; padding: 58px 40px; border: 1px solid var(--line); border-radius: 24px; background: radial-gradient(circle at 50% 0, #1b1b1d, #0d0d0e 50%); text-align: center; box-shadow: var(--shadow); }
.locked-panel h2 { font-size: 34px; }
.locked-panel p:not(.eyebrow) { max-width: 500px; margin: 0 auto 24px; color: var(--muted); line-height: 1.6; }
.lock-icon { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 26px; border: 1px solid var(--line-strong); border-radius: 17px; color: #8b8b92; }

.dialog { width: min(94vw, 720px); max-height: 92vh; padding: 0; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--panel-raised); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0,0,0,.76); backdrop-filter: blur(5px); }
.dialog-wide { width: min(1100px, 95vw); }
.dialog-small { width: min(440px, 92vw); }
.dialog-card { position: relative; display: grid; gap: 18px; padding: 30px; }
.dialog-close { position: absolute; z-index: 2; top: 16px; right: 16px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: #19191b; color: var(--muted); font-size: 20px; line-height: 1; }
.dialog-heading, .section-heading, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.dialog-actions { justify-content: flex-end; padding-top: 4px; }
.form-section { display: grid; gap: 15px; padding-top: 22px; border-top: 1px solid var(--line); }
.form-section:first-of-type { padding-top: 0; border-top: 0; }
.form-grid { display: grid; gap: 13px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.financial-section { padding: 20px; border: 1px solid #2f2f33; border-radius: 15px; background: #0d0d0f; }
.finance-hint { margin: 0; color: var(--faint); font-size: 10px; }
.upload-row { display: grid; grid-template-columns: 170px 1fr auto; gap: 10px; }
.document-list { display: grid; gap: 7px; }
.document-row { min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.document-row span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.form-error { min-height: 16px; margin: 0; color: var(--red); font-size: 11px; }

.toast-region { position: fixed; z-index: 2000; right: 22px; bottom: 22px; display: grid; gap: 9px; pointer-events: none; }
.toast { min-width: 260px; max-width: 390px; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: 12px; background: #18181a; color: var(--text); box-shadow: var(--shadow); font-size: 11px; animation: toast-in .2s ease-out; }
.toast.is-error { border-color: rgba(241,109,112,.4); color: #ffd2d3; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1180px) {
  .metric-grid-finance { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 100; left: -270px; width: 248px; transition: left .2s ease; box-shadow: var(--shadow); }
  .sidebar.is-open { left: 0; }
  .menu-button { display: grid !important; }
  .topbar { min-height: 78px; padding: 14px 18px; }
  .topbar .eyebrow, .security-pill { display: none; }
  .topbar-actions { gap: 6px; }
  .view { padding: 24px 16px 54px; }
  .hero-row { align-items: flex-start; flex-direction: column; gap: 18px; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .search-box { grid-column: 1 / -1; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .metric-grid-finance { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .login-panel { padding: 30px 22px; }
  .topbar h1 { font-size: 18px; }
  .topbar .button { padding: 0 10px; }
  .metric-grid, .metric-grid-finance { grid-template-columns: 1fr; }
  .filter-bar, .form-grid-3, .upload-row { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .dialog-card { padding: 26px 18px; }
  .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
  .inline-actions { width: 100%; align-items: stretch; flex-direction: column; }
  .inline-actions select { width: 100%; }
}
