:root {
  --violet: #7924e5;
  --violet-dark: #57219d;
  --violet-pale: #f2eaff;
  --orange: #ff8a24;
  --orange-pale: #fff3e6;
  --ink: #283347;
  --ink-soft: #58657a;
  --muted: #8b96aa;
  --line: #e5e9f0;
  --bg: #f8f7fd;
  --red: #c75a68;
  --radius: 17px;
  --shadow: 0 12px 30px rgba(57, 37, 91, .065);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: radial-gradient(800px 420px at 50% -180px, #eee4ff 0, rgba(238, 228, 255, 0) 72%), var(--bg);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease; }
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #dbcbfa; outline-offset: 2px; }

.app-head, .public-head {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 max(22px, calc((100vw - 1360px) / 2));
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
}

.app-head { position: sticky; top: 0; z-index: 20; backdrop-filter: blur(15px); }

.brand, .login-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand img, .login-brand img { width: 39px; height: 39px; object-fit: contain; }
.brand strong, .login-brand strong { display: block; font-size: 12px; line-height: 1.05; color: #30394a; }
.brand span, .login-brand span { display: block; margin-top: 3px; color: var(--orange); font-size: 8px; font-weight: 800; letter-spacing: .085em; text-transform: uppercase; }

.head-actions, .top-buttons, .action-pair { display: flex; align-items: center; gap: 8px; }
.save-state { color: var(--muted); font-size: 11px; }

.primary, .soft, .danger, .icon-btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 13px;
  font-size: 11px;
  font-weight: 760;
  line-height: 1.2;
  text-decoration: none;
}

.primary { color: #fff; background: linear-gradient(135deg, #7025d4, #913cf0); box-shadow: 0 7px 17px rgba(111, 38, 210, .19); }
.primary:hover { transform: translateY(-1px); box-shadow: 0 11px 22px rgba(111, 38, 210, .26); }
.soft { color: var(--violet-dark); background: #f3ebff; border-color: #e2d2fb; }
.soft:hover { background: #eadcff; border-color: #d6bffd; }
.danger { color: #ad4c59; background: #fff0f1; border-color: #f4d7db; }
.danger:hover { background: #ffe5e8; }
.icon-btn { display: grid; width: 36px; height: 36px; padding: 0; place-items: center; color: var(--violet-dark); background: #f6f0ff; font-size: 17px; }

.app-shell { width: min(1280px, 100%); margin: 0 auto; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; padding: 26px 22px 64px; }
.project-sidebar { padding-top: 139px; }
.sidebar-intro { padding: 15px; border: 1px solid #e6dcf6; border-radius: var(--radius); background: linear-gradient(135deg, #fff, #fbf8ff); box-shadow: var(--shadow); }
.sidebar-intro p, .side-title { margin: 0; color: #9586a7; font-size: 9px; font-weight: 850; letter-spacing: .11em; }
.wide { width: 100%; display: flex; align-items: center; justify-content: space-between; margin-top: 11px; }
.wide span { font-size: 18px; line-height: 0; }
.side-title { margin: 24px 0 9px; padding-left: 3px; }
.project-list { display: grid; gap: 6px; }
.project-item { width: 100%; padding: 10px; border: 1px solid transparent; border-radius: 11px; color: var(--ink); background: transparent; text-align: left; }
.project-item:hover, .project-item.selected { background: #fff; border-color: #e4daed; }
.project-item.selected { box-shadow: 0 6px 16px rgba(62, 41, 98, .06); }
.project-item b, .project-item span { display: block; }
.project-item b { font-size: 11px; }
.project-item span { overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.side-note { display: grid; grid-template-columns: auto 1fr; gap: 9px; align-items: center; margin-top: 24px; padding: 11px; border: 1px solid #f1dec3; border-radius: 12px; color: #7b694e; background: #fffaf4; font-size: 10px; }
.side-note span { display: grid; padding: 5px; border-radius: 7px; place-items: center; color: #c46616; background: var(--orange-pale); font-size: 10px; font-weight: 850; }

.workspace { min-width: 0; }
.topline { display: flex; flex-direction: column; align-items: center; gap: 13px; padding: 47px 10px 10px; text-align: center; }
.eyebrow { margin: 0; color: var(--violet); font-size: 9px; font-weight: 850; letter-spacing: .11em; }
.topline h1 { margin: 2px 0 4px; color: #202a3c; font-size: 28px; letter-spacing: -.055em; line-height: 1.08; }
.topline-note, .section-head p { margin: 0; color: var(--ink-soft); font-size: 11px; }
.top-buttons { flex-wrap: wrap; justify-content: center; }

.tabs { display: flex; justify-content: center; gap: 7px; margin: 18px 0 24px; padding: 0; border: 0; overflow-x: auto; }
.tabs button { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border: 1px solid #e3d2fa; border-radius: 8px; color: var(--violet-dark); background: #f4edff; font-size: 10px; font-weight: 760; white-space: nowrap; }
.tabs button:hover { border-color: #cdb1f7; background: #ecddff; }
.tabs button span { color: #ae88e8; font-size: 9px; }
.tabs button.active { color: #fff; background: linear-gradient(135deg, #7727dd, #943df1); border-color: transparent; box-shadow: 0 6px 13px rgba(116, 39, 219, .2); }
.tabs button.active span { color: #f5c69d; }
.tab { display: none; animation: enter .22s ease; }
.tab.active { display: block; }
@keyframes enter { from { opacity: .25; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.card, .table-scroll, .rail-card, .material { border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow); }
.card { padding: 25px; border-radius: var(--radius); }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid #eef0f4; }
.card-heading h2, .section-head h2 { margin: 3px 0 0; font-size: 19px; letter-spacing: -.04em; }
.card-heading > p { max-width: 230px; margin: 0; color: var(--muted); font-size: 11px; text-align: right; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 17px; margin-top: 21px; }
.grid label { color: #596477; font-size: 11px; font-weight: 750; }
.grid label small { color: var(--muted); font-weight: 500; }
input, select { display: block; width: 100%; margin-top: 5px; padding: 9px 10px; border: 1px solid #dce2ea; border-radius: 8px; color: var(--ink); background: #fff; transition: border .18s, box-shadow .18s; }
input:hover, select:hover { border-color: #c7d0db; }
input:focus, select:focus { border-color: #a66ee9; outline: 0; box-shadow: 0 0 0 3px #f0e6ff; }

.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-title { margin: 29px 0 12px; color: #303a4d; font-size: 15px; letter-spacing: -.025em; }
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .94); box-shadow: 0 4px 13px rgba(57, 40, 85, .025); }
.choice:hover { border-color: #dac6f7; transform: translateY(-1px); }
.choice-icon { display: grid; width: 33px; height: 33px; flex: 0 0 33px; border-radius: 9px; color: var(--violet); background: linear-gradient(145deg, #f3eaff, #fff5fd); place-items: center; font-size: 15px; }
.choice b, .choice span, .choice small { display: block; }
.choice b { font-size: 11px; }
.choice span, .choice small { color: var(--muted); font-size: 9px; }
.counter { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.counter button { width: 25px; height: 25px; padding: 0; border: 0; border-radius: 7px; color: var(--violet-dark); background: #f1e8ff; font-size: 17px; line-height: 1; }
.counter b { min-width: 12px; text-align: center; }
.equip { width: 100%; color: inherit; text-align: left; font: inherit; }
.equip i { position: relative; width: 32px; height: 19px; flex: 0 0 32px; margin-left: auto; border-radius: 20px; background: #dce1e8; transition: .2s; }
.equip i:after { content: ""; position: absolute; top: 3px; left: 3px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #0002; transition: .2s; }
.equip.chosen { border-color: #d3b6f4; background: #fdfaff; }
.equip.chosen i { background: linear-gradient(135deg, var(--violet), #a74ff1); }
.equip.chosen i:after { left: 16px; }

.table-scroll { overflow: auto; border-radius: var(--radius); }
table { width: 100%; min-width: 650px; border-collapse: collapse; }
th { padding: 14px 13px; border-bottom: 1px solid var(--line); color: #8c96a5; background: #fcfcfe; font-size: 9px; letter-spacing: .09em; text-align: left; }
td { padding: 7px 10px; border-bottom: 1px solid #edf0f4; }
tr:last-child td { border-bottom: 0; }
td input { margin: 0; padding: 7px 8px; }
.delete-line { padding: 4px 9px; border: 0; border-radius: 7px; color: var(--red); background: #fff0f1; font-size: 18px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 15px; }
.stats div { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(135deg, #fff, #fbf9ff); text-align: center; }
.stats b { display: block; color: var(--violet); font-size: 23px; letter-spacing: -.05em; line-height: 1; }
.stats span { color: var(--muted); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.rail-card { margin: 12px 0; padding: 13px; border-radius: 14px; }
.rail-head { display: flex; justify-content: space-between; padding: 0 3px 10px; }
.rail-head b { font-size: 12px; }
.rail-head span { color: var(--muted); font-size: 10px; }
.rail { display: flex; gap: 5px; min-height: 145px; padding: 25px 9px 9px; overflow-x: auto; border-radius: 9px; background: linear-gradient(#d9dce1 0 8px, #f6f7f8 8px 18px, #babfc7 18px 22px, #eceef1 22px); }
.device { display: flex; min-height: 108px; flex: 0 0 102px; flex-direction: column; padding: 7px; border: 1px solid #cbd2db; border-top: 5px solid var(--orange); border-radius: 5px; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }
.device.diff { flex-basis: 113px; border-top-color: var(--violet); }
.device.drag { opacity: .45; }
.device em { color: var(--muted); font-size: 9px; font-style: normal; }
.device b { margin-top: 7px; color: var(--violet); font-size: 10px; }
.device strong { margin-top: 5px; font-size: 17px; }
.device small { margin-top: auto; font-size: 9px; line-height: 1.15; word-break: break-word; }
.reserve { display: grid; min-width: 78px; flex: 1; border: 1px dashed #bfc7d2; color: #9aa4b2; place-items: center; font-size: 10px; }

.materials { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.material { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; border-radius: 13px; }
.material b { font-size: 12px; }
.material span { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.material input { width: 62px; margin: 0; text-align: center; }

.modal { position: fixed; z-index: 30; inset: 0; display: grid; padding: 20px; background: rgba(28, 20, 41, .48); place-items: center; backdrop-filter: blur(4px); }
.modal.hidden { display: none; }
.modal-box { position: relative; width: min(490px, 100%); padding: 28px; border-radius: 19px; background: #fff; box-shadow: 0 20px 65px rgba(18, 12, 32, .28); }
.modal-box .close { position: absolute; top: 10px; right: 13px; border: 0; color: #7d7586; background: transparent; font-size: 25px; }
.share-url { margin: 16px 0; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: #f7f5fa; font-size: 11px; word-break: break-all; }
.empty { padding: 12px; color: var(--muted); font-size: 12px; }
#toast { position: fixed; z-index: 40; right: 22px; bottom: 22px; padding: 11px 15px; border-radius: 10px; color: #fff; background: #283247; box-shadow: 0 10px 25px #16203333; opacity: 0; transform: translateY(12px); transition: .24s; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }

.install { display: grid; min-height: 100vh; padding: 22px; background: radial-gradient(460px 300px at 6% 5%, #e8ddff 0, transparent 80%), radial-gradient(450px 300px at 95% 95%, #fff0df 0, transparent 80%), var(--bg); place-items: center; }
.install-card { width: min(445px, 100%); padding: 29px; border: 1px solid #e7eaf0; border-radius: 21px; background: rgba(255, 255, 255, .97); box-shadow: 0 22px 58px rgba(47, 32, 80, .11); }
.login-brand { justify-content: center; margin-bottom: 24px; }
.login-brand img { width: 53px; height: 53px; }
.login-brand strong { font-size: 15px; }
.login-brand span { font-size: 8px; }
.install-card h1 { margin: 4px 0 7px; color: #242d40; font-size: 27px; letter-spacing: -.055em; }
.install-card h1 em { color: var(--orange); font-style: normal; }
.install-card > p:not(.eyebrow) { margin: 0 0 22px; color: var(--ink-soft); }
.install-card form { display: grid; gap: 13px; }
.install-card label { color: #556071; font-size: 11px; font-weight: 750; }
.install-card .primary { margin-top: 4px; padding: 12px; }
.alert { margin-bottom: 13px; padding: 10px 11px; border: 1px solid #f4d7dc; border-radius: 9px; color: #a8424c; background: #fff0f1; font-size: 12px; }
.install-card > p.install-recovery { margin: 17px 0 0; text-align: center; font-size: 11px; }
.install-recovery a { color: var(--violet); font-weight: 800; text-decoration: none; }
.install-recovery a:hover { text-decoration: underline; }

.presentation { background: radial-gradient(800px 400px at 100% 0, #eee5ff 0, transparent 75%), var(--bg); }
.public-head small { color: var(--muted); font-size: 10px; }
.public-wrap { max-width: 900px; margin: 62px auto; padding: 0 22px; }
.public-wrap h1 { margin: 3px 0; font-size: 40px; letter-spacing: -.06em; }
.muted { color: var(--muted); }
.public-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; margin: 29px 0; }
.public-grid div, .public-block { border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.public-grid div { padding: 17px; }
.public-grid b { display: block; color: var(--violet); font-size: 24px; letter-spacing: -.05em; }
.public-grid span { color: var(--muted); font-size: 10px; }
.public-block { margin: 14px 0; padding: 19px; }
.public-block h2 { margin: 0 0 10px; font-size: 17px; }
.public-list { margin: 0; padding-left: 20px; }
.public-list li { padding: 4px 0; }

@media (max-width: 1000px) {
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-shell { gap: 20px; }
}

@media (max-width: 800px) {
  .app-head, .public-head { min-height: 58px; padding: 0 14px; }
  .brand img { width: 33px; height: 33px; }
  .brand strong { font-size: 11px; }
  .head-actions .soft, .save-state { display: none; }
  .app-shell { display: block; padding: 16px 14px 42px; }
  .project-sidebar { margin-bottom: 23px; padding-top: 0; }
  .project-list { display: flex; overflow: auto; padding-bottom: 2px; }
  .project-item { min-width: 188px; }
  .side-note { display: none; }
  .topline { padding: 20px 0 8px; }
  .topline h1 { font-size: 26px; }
  .tabs { justify-content: flex-start; margin: 17px -2px 19px; }
  .tabs button { padding: 8px 10px; }
  .grid, .materials { grid-template-columns: 1fr; }
  .choices { grid-template-columns: 1fr; }
  .card { padding: 19px; }
  .card-heading, .section-head { display: block; }
  .card-heading > p { display: none; }
  .section-head > div:last-child { margin-top: 12px; }
  .action-pair { display: flex; }
  .action-pair button, .top-buttons button { flex: 1; }
  .stats, .public-grid { grid-template-columns: repeat(2, 1fr); }
  .public-head small { display: none; }
  .public-wrap { margin: 40px auto; padding: 0 16px; }
  .public-wrap h1 { font-size: 32px; }
}

@media (max-width: 420px) {
  .tabs button span { display: none; }
  .tabs button { padding: 8px 9px; }
  .primary, .soft, .danger { padding: 9px 10px; }
  .install-card { padding: 25px 20px; }
}

@media print {
  body { background: #fff; }
  .app-head, .project-sidebar, .tabs, .top-buttons, #printBtn, .section-head button { display: none !important; }
  .app-shell { display: block; padding: 0; }
  .tab { display: none !important; }
  .tab.active { display: block !important; }
  .card, .rail-card, .table-scroll { box-shadow: none; }
}
