:root {
  --bg: #0b0f14;
  --card: #121826;
  --muted: #7f8aa3;
  --text: #e7ecf5;
  --line: #25304a;
  --accent: #7aa2ff;
  --warn: #ffcc66;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }

.container { max-width: 1100px; margin: 0 auto; padding: 18px; }

.topbar { position: sticky; top: 0; background: rgba(11,15,20,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: #0b0f14; display: grid; place-items: center; font-weight: 800; }
.title { font-weight: 800; letter-spacing: .2px; }
.subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }
.meta { margin-left: auto; text-align: right; color: var(--muted); font-size: 13px; }
.label { color: #aab3c7; }

.topbar .container { display: flex; align-items: center; gap: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin: 16px 0;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.warning { border-color: rgba(255,204,102,.35); }
.warning h2 { margin-top: 0; color: var(--warn); }

.controls-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: #aab3c7; }
.field input, .field select {
  background: #0e1420;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 10px;
  border-radius: 12px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: rgba(122,162,255,.6); box-shadow: 0 0 0 3px rgba(122,162,255,.12); }

.field-actions { justify-content: flex-end; }
.btn {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0e1420;
  color: var(--text);
  cursor: pointer;
}
.btn.secondary:hover { border-color: rgba(122,162,255,.5); }

.hint { margin-top: 12px; color: var(--muted); font-size: 13px; line-height: 1.4; }

.table-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.table-title { font-weight: 800; }
.table-sub { color: var(--muted); font-size: 13px; }

.table-wrap { overflow: auto; border-radius: 12px; border: 1px solid var(--line); }
.table { width: 100%; border-collapse: collapse; min-width: 780px; }
.table th, .table td { padding: 12px; border-bottom: 1px solid var(--line); }
.table th { text-align: left; font-size: 12px; color: #aab3c7; background: rgba(14,20,32,.55); position: sticky; top: 0; }
.table tr:hover td { background: rgba(122,162,255,.06); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

details summary { cursor: pointer; color: #aab3c7; }
.debug { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.debug pre { background: #0e1420; border: 1px solid var(--line); border-radius: 12px; padding: 12px; overflow: auto; max-height: 420px; }

@media (max-width: 980px) {
  .controls-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta { display: none; }
  .debug { grid-template-columns: 1fr; }
}

/* Clickable cell buttons */
.cellbtn{
  width: 100%;
  text-align: left;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.cellbtn:hover{
  color: var(--accent);
  text-decoration: underline;
}

/* Modal */
.modal{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 1000;
  background: rgba(0,0,0,.55);
  padding: 18px;
}
.modal.open{ display: grid; place-items: center; }

.modal-card{
  width: min(720px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 70px rgba(0,0,0,.55);
}
.modal-head{
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.modal-title{ font-weight: 900; font-size: 18px; }
.modal-sub{ color: var(--muted); font-size: 13px; margin-top: 4px; }
.modal-close{
  border: 1px solid var(--line);
  background: #0e1420;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
}
.modal-close:hover{ border-color: rgba(122,162,255,.6); }

.modal-body{
  color: var(--text);
}
.modal-body h3{
  margin: 14px 0 8px;
  font-size: 14px;
  color: #aab3c7;
}
.modal-body table{
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.modal-body th, .modal-body td{
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.modal-body th{
  text-align: left;
  font-size: 12px;
  color: #aab3c7;
  background: rgba(14,20,32,.55);
}
