:root {
  --blue: #071b8f;
  --chrome: #d7d7d7;
  --chrome-dark: #9b9b9b;
  --chrome-light: #f4f4f4;
  --panel: #eeeeee;
  --white: #ffffff;
  --text: #111111;
  --muted: #565656;
  --line: #9f9f9f;
  --green: #008000;
  --yellow: #c49a00;
  --red: #d00000;
  --link: #001ebd;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #b9b9b9;
  color: var(--text);
  font-family: Tahoma, "MS Sans Serif", "Segoe UI", sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}

a {
  color: var(--link);
}

button,
input,
textarea {
  font: inherit;
}

.desktop-shell {
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  display: grid;
  grid-template-rows: 30px 38px 72px minmax(0, 1fr) 230px 30px;
  background: var(--chrome);
  border: 2px solid var(--chrome-light);
  box-shadow: inset -2px -2px 0 #707070, inset 2px 2px 0 #ffffff;
}

.window-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  color: #fff;
  background: linear-gradient(90deg, #05107a, #0b2bb3);
  font-weight: 700;
}

.app-icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  background: #e7e7e7;
  color: #001b8e;
  border: 1px solid #fff;
  font-size: 10px;
}

.menubar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  padding: 3px 8px;
  border-bottom: 1px solid #777;
  background: var(--chrome);
}

.menubar a {
  color: #111;
  text-decoration: none;
  padding: 5px 10px;
}

.menubar a:hover {
  border: 1px solid #777;
  padding: 4px 9px;
  background: #ededed;
}

.toolbar {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: 0;
  overflow-x: auto;
  padding: 7px 8px;
  border-top: 1px solid #fff;
  border-bottom: 2px groove #bbb;
  background: #dfdfdf;
}

.toolbar form {
  display: contents;
}

.tool-button {
  min-width: 82px;
  border: 1px solid transparent;
  border-right: 2px groove #aaa;
  color: #111;
  background: transparent;
  text-decoration: none;
  padding: 28px 10px 6px;
  text-align: center;
  cursor: pointer;
}

.tool-button:hover {
  border: 1px solid #808080;
  background: #eeeeee;
}

.console-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 6px;
  padding: 6px;
}

.tree-pane {
  min-width: 0;
  overflow: auto;
  background: var(--white);
  border: 2px inset var(--chrome);
  padding: 8px;
}

.tree-root {
  font-weight: 700;
  margin-bottom: 6px;
}

.tree,
.tree ul {
  list-style: none;
  margin: 0;
  padding-left: 18px;
}

.tree li {
  position: relative;
  margin: 6px 0;
}

.tree li::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 9px;
  width: 9px;
  border-top: 1px dotted #555;
}

.tree a,
.tree span {
  color: #111;
  text-decoration: none;
  padding: 2px 4px;
}

.tree a.active {
  color: #fff;
  background: var(--blue);
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 33px minmax(0, 1fr) auto;
}

.tabs {
  display: flex;
  align-items: end;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  padding-left: 6px;
}

.tab {
  color: #111;
  text-decoration: none;
  border: 2px outset var(--chrome);
  border-bottom: 0;
  background: var(--chrome);
  padding: 7px 14px;
}

.tab.active {
  background: var(--white);
  font-weight: 700;
}

.work-area {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 6px;
  background: var(--white);
  border: 2px inset var(--chrome);
  padding: 8px;
}

.main-panels {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(180px, 1.2fr) minmax(145px, 0.8fr) 76px;
  gap: 8px;
}

.right-rail {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(140px, 1fr);
  gap: 8px;
}

.group-box,
.rail-box,
.action-panel {
  min-width: 0;
  border: 2px groove #c7c7c7;
  background: #f4f4f4;
  padding: 10px;
}

.group-box h2,
.rail-box h2,
.log-pane h2 {
  margin: -2px 0 8px;
  font-size: 15px;
}

.table-wrap {
  min-width: 0;
  overflow: auto;
}

.grid-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

.grid-table th,
.grid-table td {
  border: 1px solid #b5b5b5;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.grid-table th {
  background: linear-gradient(#f7f7f7, #d9d9d9);
  font-weight: 400;
  border-color: #8f8f8f;
}

.grid-table td {
  overflow-wrap: anywhere;
}

.compact-table td,
.compact-table th {
  padding: 5px 6px;
}

.selected-row td {
  background: #eef3ff;
}

.lamp {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid #555;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.7);
}

.lamp-green { background: #16b83e; }
.lamp-yellow { background: #ffd231; }
.lamp-red { background: #f32929; }

.text-green { color: var(--green); }
.text-orange { color: #f07800; }
.text-red,
.error-line { color: var(--red); }

.status-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.status-tiles article {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 2px groove #c7c7c7;
  background: #ededed;
  padding: 10px;
}

.status-tiles span {
  font-weight: 700;
}

.status-tiles strong {
  font-size: 26px;
  color: #0b22b5;
}

.property-list,
.summary-list {
  display: grid;
  gap: 6px;
  margin: 0;
}

.property-list div,
.summary-list div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px;
  border-bottom: 1px solid #c7c7c7;
  padding-bottom: 5px;
}

.property-list dt,
.summary-list dt {
  color: var(--muted);
}

.property-list dd,
.summary-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.tag-snippet {
  display: block;
  max-height: 96px;
  overflow: auto;
  margin: 8px 0;
  padding: 8px;
  border: 2px inset var(--chrome);
  background: var(--white);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.queue-list {
  display: grid;
  gap: 8px;
}

.queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  border: 1px solid #b7b7b7;
  background: #f7f7f7;
  padding: 7px;
}

.queue-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.queue-item span:not(.status-token) {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.status-token {
  border: 1px solid #9f9f9f;
  background: #ededed;
  padding: 2px 6px;
  white-space: nowrap;
}

.action-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.action-panel {
  padding: 0;
}

.action-panel summary {
  cursor: pointer;
  padding: 8px 10px;
  font-weight: 700;
  background: #dfdfdf;
  border-bottom: 1px solid #aaa;
}

.action-panel form {
  padding: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.compact-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  margin-top: 4px;
  border: 2px inset var(--chrome);
  background: var(--white);
  padding: 5px 6px;
}

textarea {
  min-height: 62px;
  resize: vertical;
}

button {
  border: 2px outset var(--chrome);
  background: var(--chrome);
  padding: 5px 13px;
  color: #111;
  cursor: pointer;
}

button:active {
  border-style: inset;
}

button:disabled {
  color: #777;
  cursor: default;
}

.validation-check {
  display: flex;
  align-items: start;
  gap: 8px;
  margin: 8px 0;
}

.validation-check input {
  width: auto;
  margin-top: 2px;
}

.flow-list {
  display: grid;
  gap: 8px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  counter-reset: flow-step;
}

.flow-list li {
  counter-increment: flow-step;
  border: 1px solid #b7b7b7;
  background: #f7f7f7;
  padding: 8px;
}

.flow-list h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.flow-list h3::before {
  content: counter(flow-step) ". ";
}

.log-pane {
  min-height: 0;
  overflow: auto;
  margin: 0 6px;
  border: 2px inset var(--chrome);
  background: var(--white);
  padding: 6px;
}

.log-table th,
.log-table td {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.statusbar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  align-items: center;
  gap: 2px;
  padding: 3px 6px;
  background: var(--chrome);
}

.statusbar span {
  height: 22px;
  padding: 4px 8px;
  border: 2px inset var(--chrome);
  background: #e7e7e7;
}

pre {
  max-height: 95px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .desktop-shell {
    grid-template-rows: auto auto auto auto auto auto;
  }

  .console-grid,
  .work-area,
  .action-row {
    grid-template-columns: 1fr;
  }

  .tree-pane {
    max-height: 240px;
  }

  .right-rail,
  .main-panels {
    grid-template-rows: auto;
  }

  .status-tiles,
  .compact-grid,
  .form-grid,
  .statusbar {
    grid-template-columns: 1fr;
  }
}
