:root{
  --bg:#06101a;
  --bg-2:#081625;
  --panel:rgba(12, 21, 35, .76);
  --line:rgba(255,255,255,.08);
  --line-strong:rgba(255,255,255,.14);
  --text:#eef4ff;
  --muted:#9aaac2;
  --accent:#78d7ff;
  --accent-2:#7b8cff;
  --success:#53d6ab;
  --danger:#ff6d7d;
  --warn:#ffcc66;
  --shadow:0 18px 55px rgba(0,0,0,.34);
  --shadow-soft:0 8px 24px rgba(0,0,0,.22);
  --radius:24px;
  --radius-sm:16px;
  --radius-xs:12px;
  --font:Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --page-max:1720px;
  --row-h:52px;
  --thead-h:58px;
}

*,
*::before,
*::after{ box-sizing:border-box; }

html, body{ height:100%; }

html{
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
  scroll-behavior:smooth;
}

body{
  min-height:100%;
  margin:0;
  font-family:var(--font);
  color:var(--text);
  line-height:1.5;
  -webkit-font-smoothing:auto;
  text-rendering:auto;
  background:
    radial-gradient(circle at top left, rgba(120,215,255,.14), transparent 28%),
    radial-gradient(circle at top right, rgba(123,140,255,.10), transparent 30%),
    radial-gradient(circle at bottom center, rgba(83,214,171,.08), transparent 24%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  overflow-x:hidden;
}

button, input, select, textarea{
  font:inherit;
  color:inherit;
}

button{ cursor:pointer; }

h1,h2,h3,h4,p{ margin:0; }

.hidden{ display:none !important; }

.shell{
  width:min(var(--page-max), calc(100% - 40px));
  margin:0 auto;
  padding:26px 0 34px;
}

.topbar{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:20px;
  padding:8px 0 22px;
}

.eyebrow{
  display:inline-flex;
  align-items:center;
  gap:8px;
  text-transform:uppercase;
  letter-spacing:.18em;
  font-size:11px;
  color:var(--accent);
  margin-bottom:10px;
}

h1{
  font-size:clamp(30px, 3vw, 54px);
  line-height:1.02;
  letter-spacing:-.04em;
}

.subhead{
  margin-top:12px;
  max-width:920px;
  color:var(--muted);
  line-height:1.65;
  font-size:15px;
}

.topbar-meta{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
  margin-top:8px;
}

.badge{
  padding:10px 14px;
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(255,255,255,.05);
  color:var(--text);
  box-shadow:var(--shadow-soft);
  backdrop-filter:blur(16px);
  -webkit-backdrop-filter:blur(16px);
}

.badge.ghost{ color:var(--muted); }

.hero-card,
.draft-card,
.table-panel,
.stat-card{
  border:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.026));
  box-shadow:var(--shadow);
  backdrop-filter:blur(18px);
  -webkit-backdrop-filter:blur(18px);
}

.hero-card{
  display:flex;
  justify-content:space-between;
  gap:18px;
  padding:24px;
  border-radius:var(--radius);
  margin:18px 0 22px;
}

.hero-copy h2{
  font-size:22px;
  letter-spacing:-.02em;
  margin-bottom:8px;
}

.hero-copy p{
  color:var(--muted);
  line-height:1.65;
  max-width:900px;
}

.hero-actions,
.panel-actions,
.action-buttons{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.btn{
  border:none;
  border-radius:16px;
  padding:12px 16px;
  min-height:44px;
  transition:
    transform .16s ease,
    opacity .16s ease,
    box-shadow .16s ease,
    background .16s ease,
    border-color .16s ease;
}

.btn:hover{ transform:translateY(-1px); }
.btn:active{ transform:translateY(0); }

.btn:focus-visible,
.field-select:focus-visible,
.search-input:focus-visible,
textarea:focus-visible{
  outline:2px solid rgba(120,215,255,.65);
  outline-offset:2px;
}

.btn.primary{
  color:#06111b;
  background:linear-gradient(135deg, var(--accent), #b7f0ff);
  font-weight:700;
  box-shadow:0 10px 30px rgba(120,215,255,.18);
}

.btn.secondary{
  color:var(--text);
  background:rgba(255,255,255,.07);
  border:1px solid var(--line);
}

.btn.danger{
  color:#fff;
  background:linear-gradient(135deg, #ff7c88, #ff556b);
  font-weight:700;
  box-shadow:0 10px 30px rgba(255,90,110,.18);
}

.btn.icon-btn{
  width:44px;
  padding:0;
  display:inline-grid;
  place-items:center;
  font-size:20px;
  line-height:1;
  font-weight:700;
  color:#06111b;
  background:linear-gradient(135deg, var(--accent), #b7f0ff);
  border:0;
}

.stats-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(180px, 1fr));
  gap:14px;
  margin-bottom:22px;
}

.stat-card{
  border-radius:20px;
  padding:18px;
}

.stat-card span{
  display:block;
  color:var(--muted);
  margin-bottom:10px;
  font-size:13px;
}

.stat-card strong{
  font-size:28px;
  letter-spacing:-.03em;
}

.tables-layout{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:16px;
  align-items:start;
}

.table-panel{
  border-radius:var(--radius);
  padding:16px;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height:0;
}

.panel-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:12px;
}

.panel-head h3{
  font-size:20px;
  letter-spacing:-.02em;
}

.panel-head p{
  color:var(--muted);
  margin-top:6px;
  font-size:13px;
  line-height:1.55;
}

.panel-tools{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
  margin-bottom:10px;
}

.field-select,
.search-input{
  border:1px solid var(--line);
  background:rgba(6,14,24,.6);
  color:var(--text);
  border-radius:14px;
  min-height:42px;
  transition:border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.field-select:hover,
.search-input:hover{
  border-color:var(--line-strong);
}

.field-select{
  padding:10px 12px;
  max-width:220px;
}

.search-row{ margin-bottom:12px; }

.search-input{
  width:100%;
  padding:0 14px;
}

.filter-grid{
  display:grid;
  gap:8px;
  margin-bottom:10px;
}

.filter-row{
  display:grid;
  grid-template-columns:minmax(120px, 40%) 1fr;
  gap:8px;
}

.panel-meta{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  margin:2px 0 10px;
  font-size:12px;
  color:var(--muted);
  flex-wrap:wrap;
}

.panel-calc{
  margin-left:auto;
  padding-left:10px;
  color:var(--muted);
}

.table-wrap{
  overflow:auto;
  border-radius:20px;
  border:1px solid rgba(255,255,255,.06);
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.015)),
    rgba(3,8,15,.42);
  min-height:0;
  height:clamp(420px, 62vh, 760px);
  max-height:clamp(420px, 62vh, 760px);
  scrollbar-gutter:stable;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:thin;
  scrollbar-color:rgba(148,170,204,.45) rgba(255,255,255,.04);
  transform:none;
  will-change:auto;
}

.table-wrap::-webkit-scrollbar{
  width:10px;
  height:10px;
}

.table-wrap::-webkit-scrollbar-track{
  background:rgba(255,255,255,.04);
  border-radius:999px;
}

.table-wrap::-webkit-scrollbar-thumb{
  background:rgba(148,170,204,.35);
  border-radius:999px;
  border:2px solid rgba(255,255,255,.04);
}

.table-wrap::-webkit-scrollbar-thumb:hover{
  background:rgba(148,170,204,.5);
}

table{
  width:max-content;
  min-width:100%;
  border-collapse:separate;
  border-spacing:0;
  table-layout:fixed;
  font-size:13px;
}

thead th{
  position:sticky;
  top:0;
  z-index:2;
  height:var(--thead-h);
  background:linear-gradient(180deg, rgba(13,23,39,.98), rgba(10,18,30,.98));
  color:#dbe7ff;
  text-align:left;
  padding:14px 12px;
  border-bottom:1px solid var(--line);
  white-space:nowrap;
  text-transform:uppercase;
  letter-spacing:.05em;
  font-size:11px;
}

tbody td{
  height:var(--row-h);
  border-bottom:1px solid rgba(255,255,255,.055);
  padding:12px 12px;
  vertical-align:middle;
  color:#dce7fb;
  line-height:1.35;
}

tbody tr{
  transition:background .15s ease, transform .15s ease;
}

tbody tr:hover{ background:rgba(255,255,255,.04); }
tbody tr.selected{ background:rgba(83,214,171,.14); }
tbody tr.connected{ background:rgba(255,109,125,.14); }

td,
th{
  max-width:300px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

td:first-child,
th:first-child{
  min-width:280px;
}

.spacer-row td{
  padding:0 !important;
  border:0 !important;
  background:transparent !important;
}

.cell-lines{
  display:flex;
  flex-direction:column;
  gap:3px;
  min-width:0;
}

.cell-main{
  font-weight:650;
  color:#eef4ff;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.cell-sub{
  color:var(--muted);
  font-size:11px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.panel-footer{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
  padding-top:12px;
  flex-wrap:wrap;
}

.range-controls{
  display:grid;
  grid-template-columns:1fr 1fr auto;
  gap:8px;
  align-items:center;
  flex:1 1 360px;
}

.range-input{
  min-width:0;
}

.draft-card{
  margin-top:18px;
  border-radius:var(--radius);
  padding:18px;
}

.draft-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:14px;
}

.draft-head h2{
  font-size:22px;
  margin-bottom:6px;
  letter-spacing:-.02em;
}

.draft-head p{
  color:var(--muted);
  line-height:1.6;
}

.draft-sub{
  color:var(--muted);
  border:1px solid var(--line);
  background:rgba(255,255,255,.03);
  border-radius:999px;
  padding:10px 14px;
  white-space:nowrap;
}

.draft-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(240px, 1fr));
  gap:14px;
}

.draft-box{
  border:1px solid rgba(255,255,255,.07);
  background:rgba(255,255,255,.03);
  border-radius:20px;
  padding:14px;
}

.draft-box h4{
  font-size:13px;
  letter-spacing:.04em;
  text-transform:uppercase;
  color:#dbe7ff;
  margin-bottom:10px;
}

.draft-content{
  min-height:120px;
  color:#dbe7ff;
  line-height:1.6;
  overflow:auto;
  scrollbar-width:thin;
}

.draft-content.empty{ color:var(--muted); }

.draft-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:8px 10px;
  margin:0 8px 8px 0;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.05);
}

.draft-chip strong{ font-weight:700; }
.draft-line{ margin-top:6px; color:var(--muted); }

.action-bar{
  position: static;
  bottom: auto;
  margin-top: 18px;
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  padding:14px 16px;
  border-radius:20px;
  border:1px solid var(--line);
  background:rgba(8,16,29,.88);
  backdrop-filter:blur(20px);
  -webkit-backdrop-filter:blur(20px);
  box-shadow:var(--shadow);
}
.action-info{
  color:var(--muted);
  line-height:1.55;
}

.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.66);
  display:grid;
  place-items:center;
  padding:20px;
  z-index:50;
}

.modal{
  width:min(560px, 100%);
  border-radius:26px;
  padding:22px;
  border:1px solid rgba(255,255,255,.08);
  background:linear-gradient(180deg, rgba(12,22,38,.98), rgba(8,16,29,.98));
  box-shadow:var(--shadow);
}

.modal.wide{
  width:min(980px, 100%);
}

.modal h3{
  font-size:22px;
  margin-bottom:10px;
  letter-spacing:-.02em;
}

.modal-body{
  max-height:min(72vh, 760px);
  overflow:auto;
  padding-right:4px;
}

.modal p{
  color:var(--muted);
  line-height:1.65;
}

.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:18px;
}

.editor-form{
  display:flex;
  flex-direction:column;
  gap:14px;
}

.editor-hint{
  margin:0;
  color:var(--muted);
}

.editor-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:12px;
}

.editor-grid.single-column{
  grid-template-columns:1fr;
}

.editor-field{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.editor-field span{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
  color:var(--muted);
}

.editor-field input,
.editor-field textarea,
.editor-field select{
  border:1px solid var(--line);
  background:rgba(6,14,24,.6);
  color:var(--text);
  border-radius:14px;
  min-height:42px;
  padding:11px 12px;
  width:100%;
}

.editor-field textarea{
  min-height:100px;
  resize:vertical;
}

@media (max-width: 1320px){
  .tables-layout{ grid-template-columns:1fr; }
  .draft-grid{ grid-template-columns:1fr; }
  .stats-grid{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .table-wrap{
    height:clamp(380px, 58vh, 700px);
    max-height:clamp(380px, 58vh, 700px);
  }
}

@media (max-width: 760px){
  .shell{
    width:min(100% - 24px, var(--page-max));
    padding:14px 0 22px;
  }

  .topbar,
  .hero-card,
  .draft-head,
  .action-bar{
    flex-direction:column;
    align-items:stretch;
  }

  .topbar-meta,
  .hero-actions,
  .action-buttons{
    justify-content:stretch;
  }

  .stats-grid{
    grid-template-columns:1fr;
  }

  .panel-head{
    flex-direction:column;
  }

  .panel-tools{
    justify-content:stretch;
  }

  .field-select{
    max-width:none;
    width:100%;
  }

  .panel-actions{
    width:100%;
  }

  .panel-actions .btn{
    flex:1 1 120px;
  }

  .panel-footer{
    flex-direction:column;
    align-items:stretch;
  }

  .range-controls{
    grid-template-columns:1fr;
    flex:1 1 auto;
  }

  .btn{
    width:100%;
  }

  td, th{
    max-width:180px;
  }

  td:first-child, th:first-child{
    min-width:220px;
  }

  .table-wrap{
    height:clamp(360px, 54vh, 620px);
    max-height:clamp(360px, 54vh, 620px);
  }

  .editor-grid{
    grid-template-columns:1fr;
  }
}
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  background: rgba(6,14,24,.6);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  min-height: 42px;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
  user-select: none;
}
.toggle-label:hover {
  border-color: var(--line-strong);
  color: var(--text);
}
.toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  width: 14px;
  height: 14px;
  margin: 0;
}
@media (min-width: 1025px){
  .hero-card,
  .draft-card,
  .table-panel,
  .stat-card,
  .badge,
  .action-bar,
  .modal,
  .toggle-label,
  .field-select,
  .search-input,
  .editor-field input,
  .editor-field textarea,
  .editor-field select{
    backdrop-filter:none;
    -webkit-backdrop-filter:none;
  }
}
