:root {
  --navy: #0b2545; --navy-2: #13315c; --ink: #1b2733; --muted: #5b6b7f; --line: #dde3ea; --bg: #f4f6f9; --card: #ffffff;
  --accent: #1f6feb; --accent-2: #0e7490; --ok: #1f9d55; --warn: #d97706; --bad: #dc2626; --oem: #1f6feb;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); font-size: 14px; }
a { color: var(--accent); }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
h1, h2, h3 { color: var(--navy); margin: 0 0 .5em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14.5px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; height: 56px; padding: 0 16px; background: var(--navy); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand img { border-radius: 7px; box-shadow: 0 0 0 1px rgba(255,255,255,.22); }
.auth-brand img { border-radius: 9px; }
.project-title { flex: 1; min-width: 120px; }
.project-title input { width: 100%; max-width: 420px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); color: #fff; border-radius: 8px; padding: 7px 10px; font-size: 14px; }
.project-title input::placeholder { color: #9fb3cc; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.user-area { display: flex; align-items: center; gap: 8px; margin-left: 6px; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.15); }
.user-chip { display: flex; align-items: center; gap: 7px; font-size: 13px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #3a86ff; font-weight: 700; font-size: 12px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { background: #f1f4f8; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn-primary:hover { background: #185cc5; }
.btn-accent { background: #2a9d8f; border-color: #2a9d8f; color: #fff; } .btn-accent:hover { background: #23867a; }
.btn-danger { color: var(--bad); border-color: #f3c3c3; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost-light { background: transparent; border-color: rgba(255,255,255,.25); color: #fff; } .btn-ghost-light:hover { background: rgba(255,255,255,.1); }
.btn-niyyasoft { background: #fff; color: #0b2545; border-color: #fff; }
.btn-niyyasoft.is-disabled { opacity: .55; }
.ns-mark { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: linear-gradient(135deg, #ff7a18, #af002d); color: #fff; font-weight: 800; font-size: 12px; }
.topbar .btn:not(.btn-primary):not(.btn-accent):not(.btn-niyyasoft):not(.btn-ghost-light) { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: #fff; }
.topbar .btn:not(.btn-primary):not(.btn-accent):not(.btn-niyyasoft):not(.btn-ghost-light):hover { background: rgba(255,255,255,.2); }

.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 6px; min-width: 290px; z-index: 50; }
.dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 9px 10px; text-align: left; font: inherit; border-radius: 7px; cursor: pointer; }
.dropdown-menu button:hover { background: #f1f4f8; }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.fi { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 5px; background: #e7ebf0; font-weight: 800; font-size: 11px; color: #334; }
.fi-docx { background: #2b579a; color: #fff; } .fi-pptx { background: #c43e1c; color: #fff; } .fi-xlsx { background: #217346; color: #fff; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: calc(100vh - 56px); }
.sidebar { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; background: #fff; border-right: 1px solid var(--line); padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-group { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; color: var(--muted); font-weight: 700; margin: 12px 8px 6px; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 13.5px; }
.sidebar a b, .sidebar a i { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: #eef2f7; font-size: 11.5px; font-style: normal; color: var(--navy); }
.sidebar a:hover { background: #f1f4f8; }
.sidebar a.active { background: #e8f0fe; color: #174ea6; font-weight: 600; }
.sidebar a.active b, .sidebar a.active i { background: var(--accent); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--line); }
.size-status { font-size: 12.5px; font-weight: 600; color: var(--ok); margin-bottom: 4px; }
.size-status.busy { color: var(--warn); } .size-status.err { color: var(--bad); }

.view { padding: 22px 26px 60px; min-width: 0; outline: none; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.view-head p { margin: 4px 0 0; color: var(--muted); max-width: 820px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px) { .layout { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; } .nav-group, .sidebar-foot { display: none; } .g2, .g3, .g4 { grid-template-columns: 1fr; } .project-title { display: none; } .view { padding: 16px; } .top-actions .btn span { display: none; } }

/* ---------- forms ---------- */
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: #334155; }
label.f small { font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 13.5px; padding: 7px 9px; border: 1px solid #cfd7e2; border-radius: 7px; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3ff; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; padding: 6px 0; cursor: pointer; }
.check input { margin-top: 3px; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.oem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.oem-card { border: 2px solid var(--line); border-radius: 10px; padding: 14px 12px; background: #fff; cursor: pointer; text-align: left; font: inherit; display: flex; flex-direction: column; gap: 4px; }
.oem-card strong { font-size: 15px; }
.oem-card span { font-size: 12px; color: var(--muted); }
.oem-card .bar { height: 4px; border-radius: 3px; width: 36px; }
.oem-card.active { border-color: var(--oem); box-shadow: 0 0 0 3px color-mix(in srgb, var(--oem) 18%, transparent); }

.partition { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fff; }
.partition.gpu { border-left-color: #15803d; }
.spec-line { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.6; }
.spec-line b { color: var(--ink); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: #eef2f7; color: #334155; margin-right: 4px; }
.pill.dlc { background: #dbeafe; color: #1e40af; } .pill.air { background: #f1f5f9; } .pill.warn { background: #fef3c7; color: #92400e; } .pill.ok { background: #dcfce7; color: #166534; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; border-top: 3px solid var(--oem); }
.kpi .v { font-size: 22px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; background: #f3f6fa; color: #334155; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
table.t td { padding: 7px 10px; border-bottom: 1px solid #edf1f5; vertical-align: top; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.group td { background: #f8fafc; font-weight: 700; color: var(--navy); }
table.t a { word-break: break-all; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 8px; }
.alert-warn { background: #fffbeb; border: 1px solid #fde68a; color: #7c4a03; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.barrow { display: grid; grid-template-columns: 180px 1fr 90px; gap: 10px; align-items: center; font-size: 12.5px; }
.barrow .track { background: #eef2f7; border-radius: 6px; height: 12px; overflow: hidden; }
.barrow .fill { height: 100%; background: var(--oem); border-radius: 6px; }

/* ---------- rack designer ---------- */
.rack-toolbar select { width: auto; }
.rack-toolbar label { font-size: 12.5px; }
.rack-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.rack-shell { display: grid; grid-template-columns: 1fr 290px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .rack-shell { grid-template-columns: 1fr; } }
.rack-row { display: flex; gap: 14px; overflow-x: auto; padding: 14px; background: #e9edf2; border-radius: 10px; border: 1px solid var(--line); min-height: 300px; align-items: flex-start; }
.rack-col { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }
.rack-col .rack-meta { display: flex; gap: 4px; }
.rack-col .rack-meta input { font-size: 12px; padding: 4px 6px; }
.rack-col .rack-meta input.kw { width: 64px; }
.rack-col svg { display: block; user-select: none; }
.rack-col svg .device:hover rect:first-child { stroke: #3ea6ff; stroke-width: 2; }
.rack-col svg .device.selected > g > rect:first-child { stroke: #ffd60a; stroke-width: 2.5; }
.rack-col.drop-target svg > g > rect:first-child { stroke: #3ea6ff; stroke-width: 3; }
.side-panel { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 12px; }
.tray { min-height: 90px; border: 2px dashed #b8c4d3; border-radius: 10px; padding: 8px; background: #fbfcfd; display: flex; flex-direction: column; gap: 5px; max-height: 320px; overflow-y: auto; }
.tray.drop-target { border-color: var(--accent); background: #eef5ff; }
.tray-item { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; background: #fff; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; cursor: grab; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; background: rgba(11,37,69,.92); color: #fff; padding: 6px 10px; border-radius: 7px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.3); }

.diagram-box { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 78vh; }
.diagram-box svg { display: block; max-width: none; }
.diagram-box.fit svg { width: 100%; height: auto; }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 80; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 12px; padding: 20px; width: min(620px, 100%); max-height: 86vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 13.5px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 90; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: #b91c1c; }

/* ---------- auth page ---------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(160deg, #0b2545, #13315c 55%, #1d4e89); padding: 16px; }
.auth-card { background: #fff; border-radius: 14px; padding: 28px; width: min(430px, 100%); display: flex; flex-direction: column; gap: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.auth-brand { display: flex; gap: 12px; align-items: center; }
.auth-brand h1 { margin: 0; font-size: 19px; } .auth-brand p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.auth-card .btn-niyyasoft { border: 1px solid #0b2545; padding: 11px; font-size: 14.5px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.tabs-inline { display: flex; gap: 6px; }
.tabs-inline a { flex: 1; text-align: center; padding: 7px; border-radius: 8px; background: #f1f4f8; text-decoration: none; color: var(--ink); font-size: 13px; font-weight: 600; }
.tabs-inline a.active { background: var(--navy); color: #fff; }
.form-stack { display: flex; flex-direction: column; gap: 10px; }
.form-stack label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.src { font-size: 11.5px; }

/* lifecycle badges */
.pill.lc-current { background: #dcfce7; color: #166534; }
.pill.lc-legacy { background: #e0f2fe; color: #075985; }
.pill.lc-announced { background: #ede9fe; color: #5b21b6; }
.pill.lc-end-of-sale { background: #fef3c7; color: #92400e; }
.pill.lc-end-of-life, .pill.lc-end-of-support { background: #fee2e2; color: #991b1b; }
.user-chip { color: #fff; text-decoration: none; }
