* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f5f6f8;
  color: #1a1d23;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: #1a1d23;
  color: #fff;
}

header h1 {
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
}

header .row {
  align-items: center;
  margin: 0;
}

header nav {
  display: flex;
  gap: 1rem;
}

header nav a {
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  opacity: 0.85;
}

header nav a:hover {
  opacity: 1;
  text-decoration: underline;
}

header button.secondary,
header a.secondary {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

main {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
}

details {
  border-bottom: 1px solid #e5e7eb;
  padding: 0.5rem 0;
}

details summary {
  cursor: pointer;
  font-weight: 600;
}

details ul {
  margin: 0.5rem 0 0;
  padding-left: 1.5rem;
}

/* A leaf in the reporting-schema tree is a bare link rather than a <details> with nothing to
   disclose - this gives it the same spacing and rule its sibling groups get from `details` above,
   without the bold of a `summary`, so a group still reads as a group. */
.tree-leaf {
  display: block;
  border-bottom: 1px solid #e5e7eb;
  padding: 0.5rem 0;
}

/* The tree itself: no list markers anywhere in it, and one fixed-width slot in front of every row
   so a label starts in the same column whether or not its node has children. A group's slot holds
   the disclosure caret, a leaf's holds nothing - drawn here rather than left to the browser's own
   marker, whose width differs between them and cannot be matched by a placeholder. Scoped to
   .node-tree because <details> lists elsewhere (the schema listing, the company forms) still want
   their markers. */
.node-tree ul {
  list-style: none;
  padding-left: 1.25rem;
}

/* A row is caret, label, pencil - laid out so the caret slot and the gap after it are identical
   for a group and a leaf, which is what keeps labels in one column.
   Aligned to the first line rather than centred: a label here can run to several lines, and
   centring moved the caret and the pencil further down the row the more lines it took, so no two
   rows agreed. line-height is pinned because nothing else in the stylesheet sets one - without a
   known value there is no way to make the caret slot exactly one line tall. */
.node-tree summary,
.node-tree .tree-leaf {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  line-height: 1.5;
}

/* The label takes whatever width is left, so the pencil lands in the same place on every row
   instead of trailing whichever word happened to end the last line. */
.node-tree .tree-label {
  flex: 1 1 auto;
  min-width: 0;
}

.node-tree summary {
  list-style: none;
}

/* Muted until pointed at: the pencil sits on every row, so it should not compete with the labels
   for attention. */
.tree-edit {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 1.5em;
  color: #9ca3af;
}

.tree-edit:hover {
  color: #2563eb;
}

.node-tree summary::-webkit-details-marker {
  display: none;
}

/* The slot every row begins with: a fixed width, so a group and a leaf start their label in the
   same column; exactly one line tall, so it sits on the label's first line however many lines the
   label runs to; and never shrunk by a long label beside it. */
.node-tree summary::before,
.node-tree .tree-leaf::before {
  flex: none;
  display: inline-block;
  width: 1.25rem;
  height: 1.5em;
  content: '';
}

.node-tree summary::before {
  content: '\25B8';
}

.node-tree details[open] > summary::before {
  content: '\25BE';
}

th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

button, a.button {
  display: inline-block;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  background: #2563eb;
  color: #fff;
  font-size: 0.9rem;
  text-decoration: none;
  font-family: inherit;
}

button.secondary, a.button.secondary {
  background: transparent;
  color: #1a1d23;
  border: 1px solid #d1d5db;
}

/* Distinct from .secondary (Cancel's own style) on purpose - Delete sitting right next to Save/
   Cancel in the same row needs to read as destructive at a glance, not just another neutral option. */
button.danger, a.button.danger {
  background: transparent;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

button.danger:hover, a.button.danger:hover {
  background: #fef2f2;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 4rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
}

.checkbox-row input {
  width: auto;
  margin-top: 0;
}

.error {
  color: #b91c1c;
  font-size: 0.85rem;
  margin: 0.5rem 0;
}

.hint {
  color: #6b7280;
  font-size: 0.85rem;
  margin: 0.5rem 0;
}

.hint {
  font-size: 0.8rem;
  color: #6b7280;
}

.status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  margin-right: 0.5rem;
  background: #9ca3af;
}

.status-dot.live {
  background: #16a34a;
}

.badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #eef0f3;
  color: #6b7280;
  font-size: 0.75rem;
  font-weight: 600;
}

.dnd-columns {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.dnd-column {
  flex: 1 1 220px;
  min-width: 220px;
}

.dnd-column h3 {
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}

.dnd-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  min-height: 3rem;
  background: #f5f6f8;
  border: 1px dashed #d1d5db;
  border-radius: 6px;
}

.dnd-list li {
  cursor: grab;
  user-select: none;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.dnd-list li:last-child {
  margin-bottom: 0;
}

.dnd-list li.dragging {
  opacity: 0.4;
}

.row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Confirmation overlay, opened by linking to its id and closed by linking anywhere else - no
   script involved, which keeps it working the same way the rest of these pages do. The trigger is
   an <a href="#thisId">; the button that actually submits lives inside and is tied to its form by
   the form="" attribute, so the form itself can stay outside the overlay. */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  padding: 1rem;
  background: rgba(17, 24, 39, 0.5);
  align-items: center;
  justify-content: center;
}

.overlay:target {
  display: flex;
}

.overlay-card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 26rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.overlay-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.overlay-card p {
  margin: 0;
  color: #4b5563;
  font-size: 0.9rem;
}

/* Right-aligned, and Cancel first: the destructive action shouldn't sit where a reflexive click
   lands. */
.overlay-card .row {
  justify-content: flex-end;
}

/* ---------------------------------------------------------------------------
   Workspace servers.

   A status board, not a register: each instance is a panel rather than a table
   row, because what it has to show - a class name, a capacity, a volume name
   that is a UUID - has no chance side by side in a 720px column. Everything
   below is scoped to that page's classes.
   --------------------------------------------------------------------------- */

/* Machine identifiers - server keys, volume names, company keys. Set apart from
   prose because they are matched character for character against a Kubernetes
   resource or an OpenStack panel, and allowed to break anywhere: a UUID has no
   spaces to wrap at and must not push the panel sideways. */
.ident {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.muted {
  color: #6b7280;
  font-size: 0.85rem;
}

/* Digits that sit under each other in the stat strip and the capacity readouts. */
.tabular {
  font-variant-numeric: tabular-nums;
}

.notice {
  margin: 0.75rem 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  background: #f0f9ff;
  color: #075985;
  font-size: 0.85rem;
}

/* The lookup: fifty companies to a server means the way to find one is to ask
   for it, not to open lists until it turns up. */
.lookup {
  margin: 1.25rem 0 0;
}

.lookup label {
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.lookup-row {
  display: flex;
  gap: 0.5rem;
}

.lookup-row input {
  flex: 1 1 auto;
  margin-top: 0;
  min-width: 0;
}

.lookup-row button {
  flex: none;
}

.lookup-results {
  margin-top: 0.75rem;
}

.hits {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Name, key, server - the third column right-aligned so the server keys line up
   whatever the names in front of them run to. */
.hits li {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e5e7eb;
}

.hit-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.hit-server {
  margin-left: auto;
  color: #2563eb;
}

/* Totals before particulars: how many instances, how many companies they carry,
   and how many are earning nothing. */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 1.5rem 0 0.5rem;
  padding: 0.9rem 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fafbfc;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.2;
}

.stat-label {
  color: #6b7280;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.server-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.server {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

/* An idle instance is the one thing on this page that asks for a decision, so
   its panel is tinted rather than left to be told apart by a word. */
.server.is-idle {
  border-color: #fde68a;
  background: #fffdf5;
}

.server-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.server-identity {
  min-width: 0;
}

.server-key {
  font-size: 0.9rem;
  font-weight: 600;
}

.server-class {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: #4b5563;
}

.server-state {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}

.pill {
  padding: 0.1rem 0.55rem;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #f5f6f8;
  color: #6b7280;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill.live {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
}

.pill.idle {
  border-color: #fde68a;
  background: #fffbeb;
  color: #b45309;
}

.server-load-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.3rem;
  color: #6b7280;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* How full an instance is, in the one form that reads without arithmetic. */
.meter {
  height: 0.375rem;
  border-radius: 999px;
  background: #eef0f3;
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: #2563eb;
}

/* A class whose limit was lowered under it - the instance holds more than it is
   now allowed to, which is worth seeing rather than rounding away. */
.meter > span.over {
  background: #b91c1c;
}

.server-idle {
  margin: 0;
  color: #6b7280;
  font-size: 0.85rem;
  font-style: italic;
}

/* The names are not on the page until this is followed - an ordinary link that
   reloads with one server's companies, so the page needs no script to be able
   to leave fifty names unfetched. */
.disclose {
  align-self: flex-start;
  color: #2563eb;
  font-size: 0.85rem;
  text-decoration: none;
}

.disclose::before {
  display: inline-block;
  width: 1rem;
  content: '\25B8';
}

.disclose.is-open::before {
  content: '\25BE';
}

.disclose:hover {
  text-decoration: underline;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
  padding-left: 1rem;
}

.chip {
  padding: 0.15rem 0.55rem;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #f5f6f8;
  font-size: 0.8rem;
}

.server-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
}

/* Two labelled fields rather than two more columns - the volume name is long
   enough that it needs the width of the panel to itself. */
.server-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin: 0;
  min-width: 0;
}

.server-meta dt {
  color: #6b7280;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.server-meta dd {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
}

.server-action {
  flex: none;
}

/* Panels stack on a narrow screen: the state pills drop under the identity and
   the action under the fields, rather than each squeezing the other. */
@media (max-width: 32rem) {

  .server-head,
  .server-foot {
    flex-direction: column;
    align-items: flex-start;
  }

  .server-state {
    justify-content: flex-start;
  }

}

/* ---------------------------------------------------------------------------
   Backups. Reuses the workspace panels - a backup belongs to a server, and the
   page groups them the same way - and adds only what a table inside a panel
   needs.
   --------------------------------------------------------------------------- */

/* A backup table has a date, a size, a location and a button; on a narrow
   screen that is wider than the panel, and the panel must not be what scrolls. */
.table-scroll {
  overflow-x: auto;
}

.table-scroll table {
  min-width: 26rem;
}

.table-scroll th {
  color: #6b7280;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.table-scroll td {
  font-size: 0.85rem;
  vertical-align: middle;
}

/* The button column: hard against the right, and never wrapped onto two lines. */
.row-action {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

/* A backup ArangoDB flagged as possibly torn. Rare - the API is asked for a
   consistent one - but if it ever says so, restoring it is a different
   decision and the row has to say which kind it is. */
.warn-text {
  color: #b45309;
}

/* The reporting-schema page's two catalogues. Underline rather than a pill row: these sit directly
   above the card they switch, and a line joining the active tab to it reads as the same surface. */
.tabs {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.tabs .tab {
  padding: 0.5rem 0.15rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: #6b7280;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.tabs .tab:hover {
  color: #1a1d23;
}

.tabs .tab.is-current {
  border-bottom-color: #2563eb;
  color: #1a1d23;
}

/* The Atlas roots. A plain list - there is nothing to group them by and nothing to badge them
   with, so anything more would be decoration. */
.roots {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.roots li {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #e5e7eb;
}

.roots li:last-child {
  border-bottom: none;
}
