:root {
  --chrome: #0d1114;
  --chrome-soft: #161c20;
  --workspace: #f6f3ee;
  --panel: #ffffff;
  --panel-soft: #fbfaf7;
  --ink: #171a1e;
  --muted: #66727d;
  --line: rgba(23, 26, 30, 0.13);
  --accent: #ef6b20;
  --green: #2d9a4a;
  --teal: #238a92;
  --red: #c8322f;
  --yellow: #d78b0f;
  --shadow: 0 14px 34px rgba(17, 20, 24, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--chrome);
  color: var(--ink);
}

body {
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
  background: var(--chrome);
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(239, 107, 32, 0.14), transparent 38%),
    linear-gradient(230deg, rgba(35, 138, 146, 0.16), transparent 44%),
    var(--chrome);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--workspace);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
  padding: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.brand-mark.small {
  width: 28px;
  height: 28px;
  font-size: 14px;
}

.login-panel h1 {
  margin: 18px 0 4px;
  font-size: 34px;
  line-height: 1;
}

.login-panel p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(239, 107, 32, 0.72);
  box-shadow: 0 0 0 3px rgba(239, 107, 32, 0.15);
}

.form-error {
  min-height: 22px;
  margin-top: 12px;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}

.dashboard,
.workspace {
  min-width: 0;
}

.dashboard {
  min-height: 100vh;
  background: var(--workspace);
}

.workspace {
  padding-bottom: 24px;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill,
.mini-status {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(246, 248, 250, 0.13);
  color: #f6f8fa;
  border: 1px solid rgba(246, 248, 250, 0.18);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.running {
  background: rgba(45, 154, 74, 0.2);
  color: #bdf5d7;
}

.status-pill.stopped {
  background: rgba(200, 50, 47, 0.2);
  color: #ffd1cd;
}

.mini-status.running {
  background: rgba(45, 154, 74, 0.12);
  color: #176031;
  border-color: rgba(45, 154, 74, 0.24);
}

.mini-status.stopped {
  background: rgba(200, 50, 47, 0.11);
  color: #8d2530;
  border-color: rgba(200, 50, 47, 0.22);
}

.control-strip,
.command-feedback,
.summary-strip,
.operations-grid,
.support-grid {
  margin-left: 24px;
  margin-right: 24px;
}

.control-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) 48px;
  gap: 10px;
  margin-top: 0;
  padding-top: 18px;
  margin-bottom: 8px;
}

.command-feedback {
  min-height: 34px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.command-feedback.running {
  border-color: rgba(215, 139, 15, 0.25);
  background: rgba(215, 139, 15, 0.1);
  color: #8d5a08;
}

.command-feedback.ok {
  border-color: rgba(45, 154, 74, 0.25);
  background: rgba(45, 154, 74, 0.09);
  color: #176031;
}

.command-feedback.error {
  border-color: rgba(200, 50, 47, 0.25);
  background: rgba(200, 50, 47, 0.09);
  color: #8d2530;
}

.primary,
.secondary,
.danger,
.ghost {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: white;
}

.secondary {
  background: var(--chrome-soft);
  color: #f6f8fa;
}

.danger {
  background: var(--red);
  color: white;
}

.ghost {
  background: var(--chrome-soft);
  color: #f6f8fa;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.primary:hover,
.secondary:hover,
.danger:hover,
.ghost:hover {
  filter: brightness(0.94);
}

.control-strip [data-action="start"] {
  background: var(--green);
}

.control-strip [data-action="stop"] {
  background: var(--red);
}

.control-strip [data-action="restart"] {
  background: var(--accent);
}

.control-strip [data-action="savebackup"] {
  background: var(--teal);
}

.control-strip button.is-loading {
  filter: saturate(0.9) brightness(0.96);
}

.control-strip button.is-done {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.32);
}

.control-strip button.is-error {
  background: var(--red);
}

.loading-ellipsis::after {
  content: "";
  display: inline-block;
  width: 18px;
  text-align: left;
  animation: ellipsis 1.2s steps(4, end) infinite;
}

@keyframes ellipsis {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75%,
  100% {
    content: "...";
  }
}

.wide {
  width: 100%;
  margin-top: 14px;
}

.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.icon-only {
  width: 42px;
  padding: 0;
}

.summary-strip {
  display: grid;
  grid-template-columns: 0.9fr 1fr minmax(180px, 1.5fr) 0.7fr 1fr 1.25fr;
  gap: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.summary-strip div {
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.summary-strip div:last-child {
  border-right: 0;
}

.summary-strip label {
  margin: 0 0 6px;
  font-size: 12px;
}

.summary-strip strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.status-text.running {
  color: #17713b;
}

.status-text.stopped {
  color: var(--red);
}

.status-text.starting {
  color: var(--yellow);
}

.operations-grid {
  display: grid;
  grid-template-columns: minmax(300px, 1.02fr) minmax(350px, 1.1fr) minmax(300px, 0.95fr);
  gap: 14px;
  align-items: stretch;
}

.support-grid {
  display: block;
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.ops-panel {
  min-width: 0;
  min-height: 610px;
  display: flex;
  flex-direction: column;
}

.operations-grid > *,
.support-grid > * {
  min-width: 0;
}

.panel-title,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.panel-title > span:first-child,
.section-heading > span:first-child {
  color: var(--ink);
  font-size: 16px;
  text-transform: none;
}

.search {
  width: min(210px, 100%);
}

.mod-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.stat-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px 8px;
  text-align: center;
}

.stat-card strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.stat-card span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat-card.good strong {
  color: #17713b;
}

.stat-card.warn strong {
  color: #c0630a;
}

.stat-card.danger-stat strong {
  color: var(--red);
}

.sync-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.sync-summary strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

.sync-summary span {
  display: block;
}

.file-list,
.event-list,
.mod-list,
.sync-list {
  display: grid;
  gap: 7px;
}

.mod-table {
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.mod-table-head,
.mod-table-row {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) 86px 86px;
  gap: 10px;
  align-items: center;
}

.mod-table-head {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  border-bottom: 1px solid var(--line);
}

.mod-table-body {
  max-height: 434px;
  overflow: auto;
}

.mod-table-row {
  min-height: 39px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(23, 26, 30, 0.08);
  font-size: 13px;
}

.mod-table-row:last-child {
  border-bottom: 0;
}

.mod-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.mod-version {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  justify-self: end;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 900;
}

.status-badge.enabled {
  color: #17713b;
  background: rgba(45, 154, 74, 0.12);
  border: 1px solid rgba(45, 154, 74, 0.24);
}

.status-badge.disabled {
  color: #a44e04;
  background: rgba(215, 139, 15, 0.13);
  border: 1px solid rgba(215, 139, 15, 0.26);
}

.sync-stack {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.sync-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.sync-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 900;
}

.sync-card-title strong {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
}

.add-card {
  background: rgba(45, 154, 74, 0.07);
  border-color: rgba(45, 154, 74, 0.22);
}

.add-card .sync-card-title {
  color: #17713b;
}

.add-card .sync-card-title strong {
  background: rgba(45, 154, 74, 0.12);
}

.update-card {
  background: rgba(215, 139, 15, 0.09);
  border-color: rgba(215, 139, 15, 0.24);
}

.update-card .sync-card-title {
  color: #9d5b00;
}

.update-card .sync-card-title strong {
  background: rgba(215, 139, 15, 0.14);
}

.remove-card {
  background: rgba(200, 50, 47, 0.07);
  border-color: rgba(200, 50, 47, 0.22);
}

.remove-card .sync-card-title {
  color: #9d2421;
}

.remove-card .sync-card-title strong {
  background: rgba(200, 50, 47, 0.12);
}

.sync-list {
  max-height: 128px;
  overflow: auto;
  padding-right: 2px;
}

.file-row,
.event-row,
.mod-row,
.empty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  border: 1px solid rgba(23, 26, 30, 0.08);
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--ink);
  font-size: 13px;
}

.mod-row span,
.file-row span {
  overflow-wrap: anywhere;
}

.sync-list .mod-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-list .mod-row {
  background: rgba(255, 255, 255, 0.64);
}

.event-row {
  justify-content: flex-start;
}

.event-row .time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 64px;
}

.event-row.error {
  border-color: rgba(200, 50, 47, 0.25);
}

.resource-meters {
  display: grid;
  gap: 13px;
}

.resource-meter {
  display: grid;
  gap: 7px;
}

.resource-meter div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.resource-meter strong {
  color: var(--ink);
  white-space: nowrap;
}

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e0da;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 180ms ease;
}

#diskBar {
  background: var(--teal);
}

#processMemoryBar {
  background: var(--accent);
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.resource-grid div {
  min-width: 0;
  border-left: 3px solid rgba(239, 107, 32, 0.42);
  padding-left: 10px;
}

.resource-grid label {
  margin: 0 0 5px;
}

.resource-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.resource-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.resource-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.events-section .event-list {
  max-height: 130px;
  overflow: auto;
  padding-right: 3px;
}

.support-panel {
  min-height: 430px;
}

.details-title {
  align-items: center;
}

.details-actions {
  flex-wrap: nowrap;
}

.details-actions select {
  width: min(300px, 38vw);
}

.log-date {
  width: 150px;
  min-height: 34px;
}

.detail-view.active {
  display: block;
}

.log-output {
  max-width: 100%;
  min-width: 0;
  height: 360px;
  overflow: auto;
  margin: 0;
  background: #0c1115;
  color: #dce5ea;
  border-radius: 8px;
  border: 1px solid rgba(246, 248, 250, 0.1);
  padding: 14px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.48;
  white-space: pre-wrap;
}

.console-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 10px;
}

.panel .primary,
.panel .secondary {
  color: white;
}

.panel .secondary {
  background: var(--teal);
}

.panel .ghost {
  background: var(--chrome-soft);
}

[hidden] {
  display: none !important;
}

@media (max-width: 1180px) {
  .operations-grid,
  .support-grid,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .summary-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-strip div:last-child {
    border-bottom: 0;
  }

  .ops-panel {
    min-height: auto;
  }

}

@media (max-width: 760px) {
  .control-strip,
  .command-feedback,
  .summary-strip,
  .operations-grid,
  .support-grid {
    margin-left: 16px;
    margin-right: 16px;
  }

  .control-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .control-strip,
  .command-feedback,
  .summary-strip,
  .operations-grid,
  .support-grid {
    margin-left: 12px;
    margin-right: 12px;
  }

  .control-strip,
  .resource-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 13px;
  }

  .panel-title,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-title .inline-actions,
  .section-heading .ghost,
  .inline-actions,
  .inline-actions button,
  .details-actions select,
  .log-date,
  .search,
  select {
    width: 100%;
  }

  .log-output {
    height: 300px;
    font-size: 11px;
  }

  .console-form {
    grid-template-columns: 1fr;
  }
}
