:root {
  --bg: #070b16;
  --bg2: #0d1324;
  --panel: #111a2e;
  --panel2: #16213a;
  --line: #22304f;
  --text: #e8edf7;
  --muted: #8b97b3;
  --volt: #ffd23f;
  --volt2: #ffb300;
  --cyan: #45d6ff;
  --danger: #ff5c6c;
  --ok: #33d69f;
  --radius: 14px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--cyan); }
.hidden { display: none !important; }

/* =================== LOGIN =================== */
.login { position: fixed; inset: 0; display: grid; grid-template-columns: 1.1fr 1fr; overflow: hidden; background: radial-gradient(1200px 700px at 15% 20%, #142146 0%, transparent 60%), radial-gradient(900px 600px at 90% 90%, #2a1d05 0%, transparent 55%), var(--bg); }
.login-art { position: relative; overflow: hidden; }
.login-art svg.circuit { position: absolute; inset: 0; width: 100%; height: 100%; }
.circuit .trace { fill: none; stroke: #1c2a4d; stroke-width: 2; }
.circuit .pulse { fill: none; stroke: var(--volt); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 40 1200; filter: drop-shadow(0 0 6px var(--volt)); animation: run 5s linear infinite; }
.circuit .pulse.c { stroke: var(--cyan); filter: drop-shadow(0 0 6px var(--cyan)); }
.circuit .node { fill: #0d1324; stroke: #2a3b66; stroke-width: 2; }
.circuit .node.live { stroke: var(--volt); animation: blink 2.4s ease-in-out infinite; }
@keyframes run { from { stroke-dashoffset: 1240; } to { stroke-dashoffset: 0; } }
@keyframes blink { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.brand-hero { position: absolute; left: 9%; bottom: 12%; max-width: 520px; }
.brand-hero .mark { width: 84px; height: 84px; margin-bottom: 26px; }
.brand-hero h1 { font: 700 64px/1 var(--display); letter-spacing: -2px; margin: 0; }
.brand-hero h1 .v { background: linear-gradient(100deg, var(--volt) 10%, #fff3b0 45%, var(--volt2) 80%); -webkit-background-clip: text; background-clip: text; color: transparent; background-size: 200% 100%; animation: shine 6s ease-in-out infinite; }
@keyframes shine { 0%, 100% { background-position: 0% 0; } 50% { background-position: 100% 0; } }
.brand-hero .by { font: 500 14px var(--display); letter-spacing: 6px; text-transform: uppercase; color: var(--muted); margin-top: 14px; }
.brand-hero p { color: #b3bdd6; font-size: 17px; margin-top: 26px; max-width: 420px; }
.badges { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.badges span { border: 1px solid var(--line); background: rgba(17, 26, 46, .6); padding: 6px 12px; border-radius: 99px; font-size: 12px; color: #c4cde3; }

.login-side { display: grid; place-items: center; padding: 32px; position: relative; }
.glass { width: 100%; max-width: 420px; padding: 40px 36px 32px; border-radius: 22px; background: linear-gradient(160deg, rgba(28, 40, 70, .72), rgba(12, 18, 34, .78)); border: 1px solid rgba(255, 255, 255, .08); box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06); backdrop-filter: blur(18px); position: relative; }
.glass::before { content: ''; position: absolute; inset: -1px; border-radius: 23px; padding: 1px; background: linear-gradient(140deg, rgba(255, 210, 63, .7), transparent 35%, transparent 65%, rgba(69, 214, 255, .5)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.glass h2 { font: 600 26px var(--display); margin: 0 0 4px; }
.glass .sub { color: var(--muted); margin: 0 0 28px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
.field .inp { position: relative; }
.field .inp svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.field input { width: 100%; padding: 14px 14px 14px 44px; border-radius: 12px; border: 1px solid var(--line); background: rgba(7, 11, 22, .7); outline: none; transition: border .2s, box-shadow .2s; }
.field input:focus { border-color: var(--volt); box-shadow: 0 0 0 4px rgba(255, 210, 63, .14); }
.login-row { display: flex; justify-content: space-between; align-items: center; margin: -2px 0 22px; font-size: 13px; color: var(--muted); }
.login-row a { color: var(--muted); text-decoration: none; cursor: pointer; }
.login-row a:hover { color: var(--volt); }
.btn-volt { width: 100%; padding: 15px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 700; color: #1a1300; letter-spacing: .3px; background: linear-gradient(135deg, var(--volt), var(--volt2)); box-shadow: 0 10px 30px rgba(255, 190, 30, .3); position: relative; overflow: hidden; transition: transform .15s, box-shadow .2s; }
.btn-volt:hover { transform: translateY(-1px); box-shadow: 0 14px 36px rgba(255, 190, 30, .42); }
.btn-volt::after { content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent); transform: skewX(-20deg); animation: sweep 3.6s ease-in-out infinite; }
@keyframes sweep { 0%, 60% { left: -60%; } 100% { left: 130%; } }
.btn-volt:disabled { opacity: .6; cursor: wait; }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 12px; text-align: center; }
.demo-note { margin-top: 18px; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; color: #ffe8a3; background: rgba(255, 210, 63, .08); border: 1px dashed rgba(255, 210, 63, .35); }
.login-foot { position: absolute; bottom: 18px; font-size: 12px; color: #56627f; }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-art { position: absolute; inset: 0; opacity: .55; }
  .brand-hero { display: none; }
  .login-side { z-index: 1; }
  .mobile-brand { display: flex !important; }
}
.mobile-brand { display: none; align-items: center; gap: 12px; margin-bottom: 26px; }
.mobile-brand svg { width: 42px; height: 42px; }
.mobile-brand b { font: 700 24px var(--display); }
.mobile-brand small { display: block; color: var(--muted); letter-spacing: 3px; font-size: 10px; text-transform: uppercase; }

/* =================== APP SHELL =================== */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 12px 22px; background: rgba(7, 11, 22, .86); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.logo svg { width: 30px; height: 30px; }
.logo b { font: 700 19px var(--display); letter-spacing: -.4px; }
.logo b span { color: var(--volt); }
.logo small { color: var(--muted); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #1a1300; background: linear-gradient(135deg, var(--volt), var(--volt2)); }
.mode-pill { font-size: 11px; padding: 3px 8px; border-radius: 99px; background: rgba(255, 210, 63, .12); color: var(--volt); border: 1px solid rgba(255, 210, 63, .3); }

.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 14px; font-weight: 600; white-space: nowrap; transition: background .15s, border .15s; }
.btn:hover { background: var(--panel2); border-color: #33466f; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: linear-gradient(135deg, var(--volt), var(--volt2)); color: #1a1300; border: 0; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ok { background: linear-gradient(135deg, #33d69f, #1fb37f); color: #03150e; border: 0; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 6px 10px; font-size: 13px; }

main { max-width: 1240px; margin: 0 auto; padding: 26px 22px 80px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font: 700 30px var(--display); margin: 0; letter-spacing: -.6px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { padding: 16px 18px; border-radius: var(--radius); background: linear-gradient(160deg, var(--panel), var(--bg2)); border: 1px solid var(--line); }
.stat .n { font: 700 28px var(--display); }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.open .n { color: var(--volt); }
.stat.done .n { color: var(--ok); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.tabs { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabs button.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 0 0 1px #33466f; }
.search { flex: 1; min-width: 200px; position: relative; }
.search input, .toolbar select { width: 100%; padding: 10px 12px 10px 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); outline: none; }
.toolbar select { width: auto; padding-left: 12px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--muted); }

.sheet-list { display: grid; gap: 10px; }
.sheet-row { display: grid; grid-template-columns: 6px 120px 1fr 160px 110px auto; align-items: center; gap: 16px; padding: 14px 16px 14px 0; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); cursor: pointer; transition: border .15s, transform .15s; overflow: hidden; }
.sheet-row:hover { border-color: #3a4f7d; transform: translateY(-1px); }
.sheet-row .bar { align-self: stretch; margin: -14px 0; }
.sheet-row .ref { font: 600 14px var(--display); }
.sheet-row .ref small { display: block; color: var(--muted); font: 500 12px var(--font); }
.sheet-row .cust b { display: block; }
.sheet-row .cust span { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.sheet-row .date { color: var(--muted); font-size: 13px; }
.sheet-row .acts { display: flex; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; letter-spacing: .3px; }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.open { color: var(--volt); background: rgba(255, 210, 63, .1); }
.chip.completed { color: var(--ok); background: rgba(51, 214, 159, .1); }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty svg { width: 48px; height: 48px; color: var(--line); }

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .sheet-row { grid-template-columns: 6px 1fr auto; row-gap: 4px; }
  .sheet-row .date { display: none; }
  .sheet-row .cust { grid-column: 2; grid-row: 2; }
  .sheet-row .st { grid-column: 3; grid-row: 2; justify-self: end; }
  .who .nm, .logo small, #new-btn .lbl { display: none; }
  .topbar { gap: 10px; padding: 10px 14px; }
  main { padding: 18px 14px 80px; }
}

/* =================== MODALS & TOASTS =================== */
.modal-bg { position: fixed; inset: 0; z-index: 100; background: rgba(3, 6, 14, .72); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 18px; animation: fade .15s; }
.modal { width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px; background: var(--bg2); border: 1px solid var(--line); box-shadow: 0 30px 90px rgba(0, 0, 0, .6); padding: 26px; animation: pop .18s ease-out; }
.modal.wide { max-width: 760px; }
.modal h3 { font: 700 21px var(--display); margin: 0 0 6px; }
.modal p.sub { color: var(--muted); margin: 0 0 18px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.modal label.l { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 14px 0 6px; }
.modal input, .modal textarea { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); outline: none; }
.modal textarea { min-height: 110px; resize: vertical; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.types { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.type-tile { text-align: left; padding: 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; transition: border .15s, transform .15s; }
.type-tile:hover { transform: translateY(-2px); border-color: var(--c); box-shadow: 0 10px 30px -12px var(--c); }
.type-tile i { display: block; width: 36px; height: 36px; border-radius: 10px; margin-bottom: 12px; background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); display: grid; place-items: center; font-style: normal; }
.type-tile i svg { width: 20px; height: 20px; }
.type-tile b { display: block; font: 600 16px var(--display); }
.type-tile span { color: var(--muted); font-size: 13px; }
.warn-list { margin: 10px 0 0; padding-left: 18px; color: #ffc0c6; }
.lock-note { display: flex; gap: 12px; padding: 14px; border-radius: 12px; background: rgba(255, 92, 108, .07); border: 1px solid rgba(255, 92, 108, .3); color: #ffd3d7; font-size: 14px; }
.lock-note svg { flex: none; width: 22px; color: var(--danger); }
.history { margin-top: 16px; font-size: 13px; color: var(--muted); }
.history div { padding: 6px 0; border-top: 1px solid var(--line); }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 12px; background: #1a2640; border: 1px solid #2f4370; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); font-weight: 500; animation: pop .2s; }
.toast.err { border-color: var(--danger); color: #ffd3d7; }
.toast.ok { border-color: var(--ok); }

.sigpad { width: 100%; height: 220px; border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair; display: block; }

.busy { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: rgba(3, 6, 14, .6); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255, 210, 63, .2); border-top-color: var(--volt); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chip.upload { color: #b8c4d9; background: rgba(148, 163, 184, .12); }
.drop { display: block; border: 2px dashed var(--line); border-radius: 14px; padding: 22px; text-align: center; cursor: pointer; transition: border .15s, background .15s; margin-bottom: 4px; }
.drop:hover, .drop.over { border-color: var(--volt); background: rgba(255, 210, 63, .05); }
.drop span { display: grid; justify-items: center; gap: 4px; color: var(--muted); }
.drop svg { width: 28px; height: 28px; color: var(--volt); }
.drop b { color: var(--text); }
.drop small { font-size: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal select { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.doc-wrap { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
.doc-meta { padding: 18px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.doc-meta dl { margin: 0; display: grid; gap: 4px; }
.doc-meta dt { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 8px; }
.doc-meta dd { margin: 0; word-break: break-word; }
.doc-meta .muted { color: var(--muted); font-size: 12px; }
.doc-view { min-height: 70vh; border-radius: var(--radius); overflow: hidden; background: #2a3142; border: 1px solid var(--line); }
.doc-view iframe { width: 100%; height: 80vh; border: 0; display: block; background: #fff; }
.doc-view img { width: 100%; display: block; }
.page-head .btn { align-self: center; }
@media (max-width: 860px) { .doc-wrap { grid-template-columns: 1fr; } .two { grid-template-columns: 1fr; } }

.hid { display: inline-flex; margin-left: 8px; color: var(--muted); vertical-align: middle; }
.hid svg { width: 16px; height: 16px; }
.portal-sw { color: var(--muted); }
.portal-sw.on { color: var(--ok); border-color: rgba(51, 214, 159, .35); }
.user-row { display: grid; grid-template-columns: 44px 1fr 150px auto; gap: 14px; align-items: center; padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.user-row .avatar { width: 40px; height: 40px; }
.avatar.customer { background: linear-gradient(135deg, #a78bfa, #7c3aed); color: #fff; }
.avatar.engineer { background: linear-gradient(135deg, #45d6ff, #1e88e5); color: #04121c; }
.u-main b { font-size: 15px; }
.u-email { display: block; color: var(--muted); font-size: 13px; }
.role { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; vertical-align: 1px; }
.role.admin { color: var(--volt); background: rgba(255, 210, 63, .12); }
.role.engineer { color: var(--cyan); background: rgba(69, 214, 255, .12); }
.role.customer { color: #c4b5fd; background: rgba(167, 139, 250, .14); }
.u-cust, .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); }
.tag button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 0 0 2px; }
.tag button:hover { color: var(--danger); }
.u-seen { color: var(--muted); font-size: 12.5px; }
.role-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.role-pick button { text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.role-pick button b { display: block; font-size: 14px; }
.role-pick button small { color: var(--muted); font-size: 11.5px; line-height: 1.3; display: block; margin-top: 2px; }
.role-pick button.on { border-color: var(--volt); background: rgba(255, 210, 63, .07); }
.tag-add { display: flex; gap: 8px; margin-top: 8px; }
.tag-add input { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
body.portal .stat.open .n { color: var(--volt); }
@media (max-width: 860px) {
  .user-row { grid-template-columns: 40px 1fr; }
  .user-row .u-seen { display: none; }
  .user-row .acts { grid-column: 1 / 3; }
  .role-pick { grid-template-columns: 1fr; }
}

.site-tag { font-style: normal; display: inline-block; margin-right: 8px; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 600; color: #c4b5fd; background: rgba(167, 139, 250, .12); }
.site-tag.none { color: var(--muted); background: var(--panel2); }
.site-btn { color: #c4b5fd; }
.site-btn.none { color: #ffd58a; }
.avatar.site { background: rgba(167, 139, 250, .16); color: #c4b5fd; }
.avatar.site svg, .tag svg { width: 14px; height: 14px; }
.avatar.site svg { width: 20px; height: 20px; }
.tag svg { margin-right: 2px; color: #c4b5fd; }
.pw-row { display: flex; gap: 8px; }
.pw-row input { flex: 1; }
.site-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 260px; overflow: auto; padding: 2px; }
.chk { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.chk input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--volt); flex: none; }
.chk b { display: block; font-size: 14px; }
.chk small { color: var(--muted); font-size: 12px; }
.chk:has(input:checked) { border-color: var(--volt); background: rgba(255, 210, 63, .06); }
#fsite { max-width: 200px; }
@media (max-width: 760px) { .site-checks { grid-template-columns: 1fr; } }
