:root {
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  color: #172720;
  background: #f3f1e9;
  font-synthesis: none;
  --forest: #17362e;
  --forest-soft: #244c40;
  --paper: #fffefa;
  --cream: #f3f1e9;
  --line: #dedbd1;
  --muted: #65736d;
  --accent: #ef745e;
  --accent-dark: #d85a47;
  --green: #2d8a61;
  --red: #bd5047;
  --amber: #c48a36;
  --shadow: 0 20px 50px rgba(27, 43, 36, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 80% 0%, rgba(231, 220, 193, 0.48), transparent 32rem),
    var(--cream);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(239, 116, 94, 0.28);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 54, 46, 0.98), rgba(30, 71, 59, 0.94)),
    var(--forest);
}

.login-panel {
  width: min(440px, 100%);
  padding: 42px;
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 35px 90px rgba(0, 0, 0, 0.25);
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 25px;
  border-radius: 18px 18px 18px 6px;
  color: white;
  background:
    linear-gradient(145deg, transparent 0 67%, rgba(255, 255, 255, 0.12) 67%),
    var(--forest);
  font-size: 28px;
  font-weight: 850;
  box-shadow: 0 12px 26px rgba(239, 116, 94, 0.3);
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  margin: 0;
  border-radius: 13px 13px 13px 4px;
  font-size: 21px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(31px, 4vw, 45px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
  letter-spacing: -0.025em;
}

.eyebrow {
  margin-bottom: 8px;
  color: #7a8781;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.form-stack,
.form-grid {
  display: grid;
  gap: 17px;
}

.form-stack {
  margin-top: 28px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #34483f;
  font-size: 12px;
  font-weight: 760;
}

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

input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid #d9d5cb;
  border-radius: 13px;
  color: #172720;
  background: white;
}

input:focus {
  border-color: var(--accent);
}

.file-field {
  padding: 15px;
  border: 1px dashed #c9c5bb;
  border-radius: 15px;
  background: #faf8f2;
}

.file-field input {
  height: auto;
  padding: 9px;
  background: transparent;
}

.file-field small {
  color: var(--muted);
  font-weight: 500;
}

.button {
  min-height: 45px;
  border: 0;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.button.primary {
  color: white;
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(239, 116, 94, 0.24);
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.secondary {
  border: 1px solid var(--line);
  color: var(--forest);
  background: var(--paper);
}

.button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.text-button {
  border: 0;
  padding: 0;
  color: var(--accent-dark);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: 12px;
}

.app-view {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 245px;
  display: flex;
  flex-direction: column;
  padding: 27px 20px;
  color: white;
  background: var(--forest);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 5px 27px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand > div:last-child {
  display: grid;
  gap: 3px;
}

.brand span {
  color: #a9beb5;
  font-size: 10px;
}

.sidebar nav {
  display: grid;
  gap: 7px;
  margin-top: 27px;
}

.sidebar nav button,
.sidebar nav a {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: #bfd0c8;
  background: transparent;
  font-size: 12px;
  font-weight: 760;
  text-decoration: none;
  cursor: pointer;
}

.sidebar nav .nav-active {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-bottom {
  display: grid;
  gap: 9px;
  margin-top: auto;
  padding: 20px 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-bottom span {
  color: #c5d4cd;
  font-size: 11px;
}

.sidebar-bottom .text-button {
  justify-self: start;
  color: #ff9e8d;
}

.main-area {
  margin-left: 245px;
  padding: 45px clamp(24px, 5vw, 70px) 70px;
}

.topbar,
.section-heading,
.modal-card header,
.modal-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.top-actions {
  display: flex;
  gap: 9px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
  margin: 34px 0;
}

.summary-grid article {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 254, 250, 0.88);
  box-shadow: var(--shadow);
}

.summary-grid .summary-active {
  border-color: rgba(45, 138, 97, 0.2);
  background: linear-gradient(145deg, rgba(45, 138, 97, 0.1), var(--paper) 70%);
}

.summary-grid .summary-inactive {
  border-color: rgba(189, 80, 71, 0.18);
  background: linear-gradient(145deg, rgba(189, 80, 71, 0.09), var(--paper) 70%);
}

.summary-active strong {
  color: var(--green);
}

.summary-inactive strong {
  color: var(--red);
}

.summary-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.summary-grid strong {
  color: var(--forest);
  font-size: 31px;
}

.apps-section,
.jobs-panel {
  margin-top: 34px;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.app-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.app-card-head,
.app-title,
.app-actions,
.status-line {
  display: flex;
  align-items: center;
}

.app-card-head {
  justify-content: space-between;
  gap: 15px;
}

.app-title {
  min-width: 0;
  gap: 11px;
}

.app-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--forest);
  background: #e6eee9;
  font-weight: 850;
}

.app-title > div:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.app-title strong,
.app-title a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-title a {
  color: var(--muted);
  font-size: 10px;
  text-decoration: none;
}

.status-line {
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #98a19c;
}

.state-running .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(45, 138, 97, 0.12);
}

.state-starting .status-dot,
.state-degraded .status-dot {
  background: var(--amber);
}

.state-error .status-dot {
  background: var(--red);
}

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

.app-meta div {
  min-width: 0;
  padding: 10px;
  border-radius: 11px;
  background: #f7f5ef;
}

.app-meta span,
.app-meta strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-meta span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
}

.app-meta strong {
  font-size: 11px;
}

.app-actions {
  flex-wrap: wrap;
  gap: 7px;
  padding-top: 15px;
  border-top: 1px solid #ebe8e0;
}

.app-actions .button {
  min-height: 37px;
  border: 1px solid transparent;
  padding: 0 11px;
  font-size: 10px;
  box-shadow: none;
}

.button.action-start {
  border-color: rgba(45, 138, 97, 0.2);
  color: #236f50;
  background: #e8f5ee;
}

.button.action-restart {
  border-color: rgba(196, 138, 54, 0.24);
  color: #90611d;
  background: #fff3dc;
}

.button.action-stop {
  border-color: rgba(189, 80, 71, 0.2);
  color: #a3423b;
  background: #fae9e7;
}

.button.action-logs {
  border-color: rgba(55, 113, 172, 0.2);
  color: #326ca6;
  background: #eaf2fb;
}

.button.action-start:hover {
  background: #d9eee3;
}

.button.action-restart:hover {
  background: #fbe8c5;
}

.button.action-stop:hover {
  background: #f5dad7;
}

.button.action-logs:hover {
  background: #dceafb;
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-content: center;
  justify-items: center;
  margin-top: 18px;
  padding: 35px;
  border: 1px dashed #c9c5bb;
  border-radius: 20px;
  text-align: center;
  background: rgba(255, 254, 250, 0.5);
}

.empty-state p {
  max-width: 430px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.empty-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 17px;
  border-radius: 15px;
  color: white;
  background: var(--accent);
  font-size: 25px;
}

.jobs-panel {
  padding: 20px;
  border: 1px solid #efd7ba;
  border-radius: 20px;
  background: #fff8e9;
}

#jobsList {
  display: grid;
  gap: 8px;
  margin-top: 15px;
}

.job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.65);
  font-size: 11px;
}

.job-row strong,
.job-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-row span {
  color: var(--muted);
}

.modal {
  width: min(720px, calc(100% - 30px));
  max-height: calc(100vh - 30px);
  border: 0;
  border-radius: 23px;
  padding: 0;
  background: transparent;
  box-shadow: 0 35px 100px rgba(18, 30, 25, 0.28);
}

.modal::backdrop {
  background: rgba(19, 35, 29, 0.63);
  backdrop-filter: blur(5px);
}

.modal-card {
  display: block;
  overflow: auto;
  max-height: calc(100vh - 30px);
  padding: 26px;
  border-radius: 23px;
  background: var(--paper);
}

.modal-card > .muted {
  margin: 14px 0 22px;
  font-size: 12px;
}

.close-button {
  width: 37px;
  height: 37px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: white;
  font-size: 23px;
  cursor: pointer;
}

.modal-card footer {
  margin-top: 22px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.modal-card footer > div {
  display: flex;
  gap: 8px;
}

.progress {
  margin-top: 18px;
}

.progress > div {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9e5dc;
}

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

.progress small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
}

.logs-modal {
  width: min(960px, calc(100% - 30px));
}

.confirm-modal {
  width: min(430px, calc(100% - 30px));
  text-align: center;
}

.confirm-modal .modal-card {
  padding: 32px;
}

.confirm-symbol {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin: 0 auto 19px;
  border-radius: 17px;
  color: var(--forest);
  background: #f5ead9;
  font-size: 25px;
  font-weight: 850;
}

.confirm-modal .muted {
  margin: 13px auto 24px;
  max-width: 330px;
  font-size: 12px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.button.confirm-stop {
  color: white;
  background: var(--red);
}

.button.confirm-restart {
  color: white;
  background: var(--amber);
}

#logsOutput {
  min-height: 380px;
  max-height: 65vh;
  overflow: auto;
  margin: 20px 0 0;
  padding: 18px;
  border-radius: 13px;
  color: #dce8e2;
  background: #13251e;
  font: 11px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 22px;
  bottom: 22px;
  max-width: min(390px, calc(100% - 30px));
  transform: translateY(30px);
  opacity: 0;
  padding: 13px 16px;
  border-radius: 13px;
  color: white;
  background: var(--forest);
  box-shadow: 0 18px 45px rgba(18, 33, 27, 0.25);
  font-size: 12px;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
    min-height: 74px;
    flex-direction: row;
    align-items: center;
    padding: 14px 18px;
  }

  .brand {
    padding: 0;
    border: 0;
  }

  .sidebar nav {
    display: none;
  }

  .sidebar-bottom {
    display: flex;
    align-items: center;
    gap: 13px;
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
  }

  .main-area {
    margin-left: 0;
    padding: 30px 20px 70px;
  }
}

@media (max-width: 680px) {
  .topbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    display: none;
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 25px 0 30px;
  }

  .summary-grid article:last-child {
    grid-column: auto;
  }

  .summary-grid article {
    min-height: 92px;
    padding: 14px 12px;
    border-radius: 15px;
  }

  .summary-grid strong {
    font-size: 25px;
  }

  .summary-grid span {
    font-size: 9px;
  }

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

  label.wide {
    grid-column: auto;
  }

  .app-card {
    padding: 16px;
  }

  .app-title a,
  .app-meta {
    display: none;
  }

  .app-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 17px;
    padding-top: 14px;
  }

  .app-actions .button {
    min-height: 44px;
    padding: 0 8px;
    font-size: 11px;
  }

  .modal-card footer {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-card footer > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 440px) {
  .login-panel {
    padding: 30px 23px;
  }

  .brand > div:last-child {
    display: none;
  }

  .sidebar-bottom span {
    display: none;
  }

  .main-area {
    padding-inline: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
