/* FSM Backlink workspace UI v8 — prototype 2-column */
:root {
  --bg: #e9edf5;
  --surface: #ffffff;
  --side: #1a1030;
  --side-2: #241545;
  --side-line: rgba(255, 255, 255, 0.08);
  --text: #152033;
  --text-inv: #f4f0ff;
  --muted: #5c6b82;
  --muted-inv: #b7a8d9;
  --line: #d5dceb;
  --accent: #e11d48;
  --accent-2: #f43f5e;
  --accent-soft: #fff1f3;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --radius: 12px;
  --shell: 1100px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --side-w: 260px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}
body { display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.bg { display: none; }

/* top nav compact */
.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}
.top-inner, .top-inner-wide {
  max-width: none;
  margin: 0;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--side);
  text-decoration: none;
  min-width: 0;
}
.brand:hover { color: var(--accent); text-decoration: none; }
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  flex-shrink: 0;
  display: block;
  box-shadow: 0 1px 0 rgba(26, 16, 48, 0.08);
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.brand-name {
  font-size: 0.98rem;
  letter-spacing: 0.01em;
}
.brand-tag {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.top nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.top nav a {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 7px 11px;
  border-radius: 8px;
  text-decoration: none;
}
.top nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.top nav a.on {
  background: var(--accent-soft);
  color: var(--accent);
}
.who {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.is-studio {
  height: 100vh;
  overflow: hidden;
}
body.is-studio .wrap.wrap-app {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.is-studio .wrap.wrap-app > .alert {
  margin: 10px 14px 0;
  flex-shrink: 0;
}

/* ===== Workspace shell ===== */
.ws {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  height: 100%;
  border-top: 1px solid var(--line);
}

/* LEFT sidebar domains */
.ws-side {
  background: linear-gradient(180deg, var(--side-2), var(--side));
  color: var(--text-inv);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 3px solid #0f0a1c;
}
.ws-side-head {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--side-line);
}
.ws-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(255,255,255,.12);
}
.ws-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.ws-side-head strong { display: block; font-size: 0.95rem; }
.ws-side-head span { font-size: 0.75rem; color: var(--muted-inv); }
.ws-side-search { padding: 10px 12px; }
.ws-side-search input {
  width: 100%;
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--side-line);
  background: rgba(0,0,0,.25);
  color: #fff;
  padding: 8px 10px;
  font: inherit;
}
.ws-side-search input::placeholder { color: #8b7aad; }
.ws-domain-list {
  flex: 1;
  overflow: auto;
  padding: 6px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ws-domain-item {
  text-align: left;
  border: 1px solid transparent;
  background: rgba(255,255,255,.03);
  color: var(--text-inv);
  border-radius: 10px;
  padding: 10px 11px;
  cursor: pointer;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ws-domain-item:hover {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.1);
}
.ws-domain-item.on {
  background: linear-gradient(90deg, rgba(225,29,72,.35), rgba(225,29,72,.12));
  border-color: rgba(251,113,133,.5);
  box-shadow: inset 3px 0 0 var(--accent);
}
.ws-d-label { font-weight: 800; font-size: 0.88rem; }
.ws-d-host { font-size: 0.72rem; color: var(--muted-inv); word-break: break-all; }
.ws-d-eng {
  font-size: 0.68rem;
  font-weight: 700;
  color: #fda4af;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 2px;
}
.ws-side-foot {
  padding: 12px;
  border-top: 1px solid var(--side-line);
  display: flex;
  gap: 12px;
  font-size: 0.82rem;
}
.ws-side-foot a { color: var(--muted-inv); text-decoration: none; }
.ws-side-foot a:hover { color: #fff; }

/* MAIN */
.ws-main {
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Metrics top bar */
.ws-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(70px, 1fr)) minmax(160px, 1.6fr);
  gap: 8px;
}
.ws-metrics .m {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  min-width: 0;
}
.ws-metrics .m span {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.ws-metrics .m b {
  display: block;
  font-size: 1.15rem;
  color: var(--side);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.ws-metrics .m.wide { text-align: left; }
.ws-metrics .m.wide b { font-size: 0.95rem; color: var(--accent); }

/* Editor card */
.ws-editor-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  box-shadow: 0 10px 30px rgba(26, 16, 48, 0.06);
}
.ws-top-fields {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.ws-top-fields .grow { flex: 1; min-width: 0; }
.row-inline {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px;
}
.folder-path-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: stretch;
}
.folder-fixed {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid #f5c2cc;
  background: linear-gradient(180deg, #fff1f3, #ffe4e9);
  color: #9f1239;
  font-weight: 800;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.95rem;
  white-space: nowrap;
  user-select: none;
}
.ws-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field { margin-bottom: 12px; }
.field label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--side);
}
.field-hint {
  margin-top: 5px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}
.ctrl, .ws-editor-card input, .ws-editor-card select, .ws-editor-card textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  padding: 9px 11px;
  font: inherit;
}
.ctrl-title {
  min-height: 48px !important;
  font-size: 1.15rem !important;
  font-weight: 700 !important;
}
.ctrl:focus, .ws-editor-card input:focus, .ws-editor-card select:focus {
  outline: 2px solid rgba(225, 29, 72, 0.2);
  border-color: var(--accent);
  background: #fff;
}

/* Toolbar */
.ws-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: linear-gradient(180deg, #f8f5ff, #f3f0fb);
  border: 1px solid #e4dcf5;
}
.tb-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-right: 8px;
  border-right: 1px solid #ddd3f0;
}
.tb-group:last-child { border-right: 0; }
.ws-toolbar button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid #d8d0ea;
  background: #fff;
  color: var(--side);
  font-weight: 800;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
}
.ws-toolbar button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Contenteditable red zone from prototype → soft rose panel */
.ws-editor-wrap {
  flex: 1;
  min-height: 280px;
  border-radius: 12px;
  border: 2px solid #f5c2cc;
  background: linear-gradient(180deg, #fff7f8, #ffffff 40%);
  overflow: auto;
}
.ws-editor {
  min-height: 320px;
  padding: 18px 20px;
  outline: none;
  line-height: 1.65;
  font-size: 1rem;
  color: var(--text);
}
.ws-editor:empty:before,
.ws-editor[data-placeholder]:empty:before {
  content: attr(data-placeholder);
  color: #a3a9b8;
}
.ws-editor h1, .ws-editor h2, .ws-editor h3, .ws-editor h4 {
  color: var(--side);
  line-height: 1.25;
  margin: 0.8em 0 0.4em;
}
.ws-editor img, .ws-editor video {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}
.ws-editor a { color: var(--blue); }

.ws-bottom-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.status-actions { max-width: none; min-width: 0; flex: 1.2; }
.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.status-row .ctrl { min-width: 140px; max-width: 180px; flex: 0 0 auto; }
.status-row .btn { white-space: nowrap; min-height: 42px; }
.ws-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 0;
}
.ws-stats .mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.75rem;
  word-break: break-all;
  color: var(--side);
}
.btn, a.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  background: var(--blue);
  color: #fff !important;
  font-weight: 800;
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none !important;
}
.btn:hover { filter: brightness(1.05); text-decoration: none !important; }
.btn-secondary {
  background: #fff;
  color: var(--text) !important;
  border: 1px solid var(--line);
}
.btn-publish {
  min-height: 48px;
  padding: 0 22px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 8px 20px rgba(225, 29, 72, 0.25);
  font-size: 0.98rem;
}

.ws-success {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--ok-soft);
  border: 1px solid #a7f3d0;
}
.ws-success strong { color: var(--ok); display: block; margin-bottom: 4px; }
.ws-success-title { font-weight: 800; margin-bottom: 4px; }
.ws-live-link {
  word-break: break-all;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--blue);
}
.ws-success-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.alert {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
}
.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}
.alert-success {
  background: var(--ok-soft);
  border: 1px solid #a7f3d0;
  color: var(--ok);
}

/* Login / other pages */
.wrap {
  width: 100%;
  max-width: 440px;
  margin: 28px auto 0;
  padding: 0 16px 40px;
  flex: 1;
}
.wrap.wrap-wide { max-width: var(--shell); }
.wrap.wrap-fluid {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 16px 20px 40px;
  box-sizing: border-box;
}
.panel-fluid {
  width: 100%;
  max-width: none;
}
.table-full { width: 100%; }
table.grid-riwayat { min-width: 1100px; width: 100%; }
table.grid-riwayat th.th-actions,
table.grid-riwayat td.td-actions {
  text-align: right;
  white-space: nowrap;
  min-width: 240px;
}
table.grid-riwayat .td-link a {
  word-break: break-all;
  font-size: 0.86rem;
}
table.grid-riwayat .td-time {
  font-size: 0.8rem;
  white-space: nowrap;
  color: var(--muted);
}
.row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}
.btn-sm {
  min-height: 34px !important;
  padding: 0 12px !important;
  font-size: 0.8rem !important;
}
.idx-time {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}
.sm-status {
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 4px;
}
.sm-status.sm-ok { color: var(--ok); }
.sm-status.sm-miss { color: #b91c1c; }
table.grid-riwayat th.th-check-index,
table.grid-riwayat td.td-check-index {
  text-align: center;
  white-space: nowrap;
  min-width: 120px;
  vertical-align: middle;
}
.check-index-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.ix-status {
  font-size: 0.72rem;
  font-weight: 800;
  max-width: 110px;
  line-height: 1.2;
}
.ix-status.ix-ok { color: var(--ok); }
.ix-status.ix-miss { color: #b91c1c; }
.ix-status.ix-unk { color: var(--muted); }
.card, .panel, .simple-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.card h1 { margin: 0 0 6px; font-size: 1.35rem; }
.card .sub { margin: 0 0 16px; color: var(--muted); }
label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.85rem;
  font-weight: 700;
}
.field { margin-bottom: 14px; }
input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 160px; resize: vertical; }
.btn-block { width: 100%; }
.meta { margin-top: 16px; text-align: center; color: var(--muted); font-size: 0.9rem; }
.foot {
  color: var(--muted);
  font-size: 0.8rem;
  padding: 18px 16px 28px;
  border-top: 1px solid var(--line);
  background: #f4f6fb;
}
.foot-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 20px;
}
.foot-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--side);
  font-weight: 800;
  text-decoration: none;
}
.foot-brand:hover { color: var(--accent); text-decoration: none; }
.foot-brand img { border-radius: 6px; }
.foot-meta a { color: var(--muted); font-weight: 600; }
.hero-home {
  max-width: 560px;
  margin: 40px auto 32px;
  text-align: center;
  padding: 28px 20px 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(26, 16, 48, 0.06);
}
.hero-brand { margin-bottom: 14px; }
.hero-logo {
  width: min(280px, 100%);
  height: auto;
  display: inline-block;
}
.hero-home h1 {
  margin: 0 0 10px;
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  color: var(--side);
}
.hero-home p { color: var(--muted); margin: 0 0 18px; line-height: 1.55; }
.hero-home code {
  font: 600 0.84em ui-monospace, Consolas, monospace;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
}
.hero-points {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  text-align: left;
}
.hero-points li {
  position: relative;
  padding: 10px 12px 10px 34px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}
.hero-points li::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
}
.row-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.auth-logo img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(26, 16, 48, 0.12);
}
.auth-logo strong { display: block; font-size: 1rem; color: var(--side); }
.auth-logo span { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.card-auth { max-width: 420px; margin-left: auto; margin-right: auto; }
.page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.page-head h1 { margin: 0; font-size: 1.4rem; }
.page-head .sub { margin: 6px 0 0; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.grid th, table.grid td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
table.grid th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--bg);
}
.status-ok {
  display: inline-block;
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 800;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 6px;
}
.status-bad {
  display: inline-block;
  background: #fef2f2;
  color: #b91c1c;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 6px;
}
.panel-note { margin: 0; padding: 16px; color: var(--muted); }
.dash-list { list-style: none; margin: 0; padding: 0; }
.dash-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.stat b { display: block; font-size: 1.3rem; color: var(--accent); }
.stat span { font-size: 0.75rem; color: var(--muted); font-weight: 600; }

@media (max-width: 980px) {
  body.is-studio { height: auto; overflow: auto; }
  body.is-studio .wrap.wrap-app { overflow: visible; }
  .ws {
    grid-template-columns: 1fr;
    height: auto;
  }
  .ws-side { max-height: 280px; }
  .ws-metrics {
    grid-template-columns: repeat(3, 1fr);
  }
  .ws-metrics .m.wide { grid-column: 1 / -1; }
  .row-inline, .ws-grid-2, .ws-top-fields { grid-template-columns: 1fr; display: grid; }
  .ws-top-fields { display: grid; }
}
