/* ─────────────────────────────────────────────────────────────
   ShinServer — Soft/System Design
   Expanded Desktop Fill & Responsive Viewport
   TypeUI Principles · Zero Blinking Dots
   ───────────────────────────────────────────────────────────── */

/* ── TOKENS ── */
:root {
  /* Surface — Ivory */
  --c-bg:          #eeeae3;
  --c-surface:     #f5f2ed;
  --c-surface-2:   #ffffff;
  --c-border:      #ddd8ce;
  --c-border-2:    #ccc6b8;

  /* Text — Charcoal Scale */
  --c-text:        #181824;
  --c-muted:       #646473;
  --c-muted2:      #9c9ca8;

  /* Accent — Cobalt */
  --c-blue:        #2563eb;
  --c-blue-hover:  #1d4ed8;
  --c-blue-light:  #eff4ff;
  --c-blue-mid:    #dbeafe;
  --c-blue-border: #bfdbfe;

  /* Status Colors */
  --c-green:       #15803d;
  --c-green-bg:    #f0fdf4;
  --c-green-border:#bbf7d0;

  --c-amber:       #b45309;
  --c-amber-bg:    #fffbeb;
  --c-amber-border:#fde68a;

  --c-red:         #b91c1c;
  --c-red-bg:      #fef2f2;
  --c-red-border:  #fecaca;

  --c-gray-bg:     #f4f3f0;
  --c-gray-border: #e2ded5;

  /* Soft Ambient Elevation */
  --shadow-sm:     0 1px 3px rgba(24,24,36,0.06);
  --shadow-md:     0 8px 24px rgba(24,24,36,0.07), 0 2px 8px rgba(24,24,36,0.04);
  --shadow-lg:     0 20px 60px rgba(24,24,36,0.12), 0 6px 16px rgba(24,24,36,0.06);

  /* 8-Point Base Grid Scale (Multiples of 8, with 4pt micro-grid) */
  --sp-0-5: 2px;
  --sp-1:   4px;
  --sp-1-5: 6px;
  --sp-2:   8px;   /* 1 grid unit */
  --sp-3:   12px;  /* 1.5 grid units */
  --sp-4:   16px;  /* 2 grid units */
  --sp-5:   20px;  /* 2.5 grid units */
  --sp-6:   24px;  /* 3 grid units */
  --sp-8:   32px;  /* 4 grid units */
  --sp-10:  40px;  /* 5 grid units */
  --sp-12:  48px;  /* 6 grid units (Maurice Geßwein touch target standard) */
  --sp-16:  64px;  /* 8 grid units */
  --sp-20:  80px;  /* 10 grid units */

  /* Radii */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-pill: 999px;

  /* Motion */
  --ease-snappy: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast:    150ms;
  --dur-base:    200ms;
}

/* ── RESET ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mono { font-family: ui-monospace, SFMono-Regular, "Cascadia Code", "Consolas", Menlo, Monaco, monospace; }
.text-muted { color: var(--c-muted); }
.hidden { display: none !important; }
.w-full { width: 100%; }
.flex-1 { flex: 1; }
.sep { color: var(--c-muted2); }

/* ── ICON PRINTS ── */
.icon-xs { width: 15px; height: 15px; flex-shrink: 0; }
.icon-sm { width: 18px; height: 18px; flex-shrink: 0; }
.icon-md { width: 22px; height: 22px; flex-shrink: 0; }

/* ── NAVBAR ── */
.navbar {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.navbar-inner {
  max-width: 1840px;
  width: 100%;
  margin: 0 auto;
  padding: 0 clamp(16px, 2.5vw, 40px);
  height: clamp(64px, 4.5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.brand-icon {
  width: 48px;
  height: 48px;
  background: var(--c-blue);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(37,99,235,0.32);
}

.brand-name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--c-text);
  line-height: 1.15;
}

.brand-sub {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.1em;
  color: var(--c-muted);
  font-weight: 600;
  margin-top: 1px;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* WebSocket badge */
.ws-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: var(--r-pill);
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  font-size: 13.5px;
  color: var(--c-muted);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.ws-badge.ws-live {
  color: var(--c-green);
  border-color: var(--c-green-border);
  background: var(--c-green-bg);
}
.ws-badge.ws-live svg { color: var(--c-green); }

/* ── BUTTON SYSTEM (Maurice Geßwein 48dp Standard) ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  min-height: 48px;
  padding: 0 24px;
  background: var(--c-blue);
  color: #fff;
  border: none;
  border-radius: var(--r-pill);
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-snappy),
              transform var(--dur-fast) var(--ease-snappy),
              opacity var(--dur-fast) var(--ease-snappy);
}
.btn-primary:hover:not(:disabled) { background: var(--c-blue-hover); }
.btn-primary:active:not(:disabled) { transform: scale(0.97); }
.btn-primary:focus-visible { outline: 2px solid var(--c-blue); outline-offset: 2px; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  min-height: 48px;
  padding: 0 22px;
  background: var(--c-surface-2);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-snappy),
              transform var(--dur-fast) var(--ease-snappy),
              opacity var(--dur-fast) var(--ease-snappy);
}
.btn-secondary:hover:not(:disabled) { background: var(--c-bg); }
.btn-secondary:active:not(:disabled) { transform: scale(0.97); }
.btn-secondary:focus-visible { outline: 2px solid var(--c-blue); outline-offset: 2px; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  min-height: 48px;
  padding: 0 22px;
  background: var(--c-red-bg);
  color: var(--c-red);
  border: 1px solid var(--c-red-border);
  border-radius: var(--r-pill);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-snappy),
              transform var(--dur-fast) var(--ease-snappy),
              opacity var(--dur-fast) var(--ease-snappy);
}
.btn-danger:hover:not(:disabled) { background: #fee2e2; }
.btn-danger:active:not(:disabled) { transform: scale(0.97); }
.btn-danger:focus-visible { outline: 2px solid var(--c-red); outline-offset: 2px; }

.btn-power-off {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  min-height: 48px;
  padding: 0 20px;
  background: var(--c-red-bg);
  color: var(--c-red);
  border: 1px solid var(--c-red-border);
  border-radius: var(--r-pill);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-snappy),
              transform var(--dur-fast) var(--ease-snappy),
              opacity var(--dur-fast) var(--ease-snappy);
}
.btn-power-off:hover:not(:disabled) { background: #fee2e2; }
.btn-power-off:active:not(:disabled) { transform: scale(0.97); }
.btn-power-off:focus-visible { outline: 2px solid var(--c-red); outline-offset: 2px; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  background: var(--c-surface-2);
  color: var(--c-muted);
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease-snappy),
              color var(--dur-fast) var(--ease-snappy),
              transform var(--dur-fast) var(--ease-snappy),
              opacity var(--dur-fast) var(--ease-snappy);
}
.btn-icon:hover:not(:disabled) { background: var(--c-bg); color: var(--c-text); }
.btn-icon:active:not(:disabled) { transform: scale(0.94); }
.btn-icon:focus-visible { outline: 2px solid var(--c-blue); outline-offset: 2px; }

/* ── UNIVERSAL DISABLED STATE ── */
button:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled,
.btn-power-off:disabled,
.btn-icon:disabled {
  opacity: 0.38 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  transform: none !important;
}

.btn-primary:disabled {
  background: var(--c-border-2) !important;
  color: var(--c-muted) !important;
  border: 1px solid var(--c-border) !important;
}

.btn-secondary:disabled,
.btn-danger:disabled,
.btn-power-off:disabled,
.btn-icon:disabled {
  background: var(--c-gray-bg) !important;
  color: var(--c-muted2) !important;
  border-color: var(--c-gray-border) !important;
}

/* ── STATUS BADGES (Zero Dots) ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge--unknown  { background: var(--c-gray-bg);  color: var(--c-muted);  border-color: var(--c-gray-border); }
.badge--running  { background: var(--c-green-bg); color: var(--c-green);  border-color: var(--c-green-border); }
.badge--online   { background: var(--c-green-bg); color: var(--c-green);  border-color: var(--c-green-border); }
.badge--offline  { background: var(--c-gray-bg);  color: var(--c-muted);  border-color: var(--c-gray-border); }
.badge--starting { background: var(--c-amber-bg); color: var(--c-amber);  border-color: var(--c-amber-border); }
.badge--crashed  { background: var(--c-red-bg);   color: var(--c-red);    border-color: var(--c-red-border); }
.badge--stopped  { background: var(--c-gray-bg);  color: var(--c-muted);  border-color: var(--c-gray-border); }

/* ── MAIN CONTENT CONTAINER (8pt Grid & Screen-Filling Responsive Scale) ── */
.main-content {
  flex: 1;
  max-width: 1840px;
  width: 100%;
  margin: 0 auto;
  padding: clamp(16px, 2vw, 32px);
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 2vw, 32px);
}

/* ── DASHBOARD VIEW (8pt Vertical Rhythm) ── */
#dashboard-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: clamp(20px, 2.2vw, 32px);
}

/* ── SECTION RHYTHM ── */
.section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.section-label {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--c-muted);
}

.section-meta {
  font-size: 13px;
  color: var(--c-muted2);
}

/* ── CARD PRIMITIVE ── */
.card {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: clamp(20px, 2vw, 32px);
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 1.8vw, 24px);
  box-shadow: var(--shadow-md);
}

.card--active {
  border-color: var(--c-blue-border);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--c-blue-border);
}

/* ── MACHINES GRID ── */
.machines-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(20px, 2vw, 32px);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
}

.machine-identity {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-width: 0;
  flex: 1;
}

.machine-icon {
  width: 56px;
  height: 56px;
  background: var(--c-blue-light);
  border: 1px solid var(--c-blue-border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.machine-icon--active {
  background: var(--c-blue);
  border-color: var(--c-blue);
  box-shadow: 0 4px 12px rgba(37,99,235,0.28);
}
.machine-icon--active svg { color: #fff !important; }

.machine-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--c-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.machine-meta {
  font-size: 13.5px;
  color: var(--c-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  background: var(--c-blue-mid);
  color: var(--c-blue);
  border: 1px solid var(--c-blue-border);
  border-radius: var(--r-pill);
  flex-shrink: 0;
}

/* ── METRICS SECTION ── */
.metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(20px, 2vw, 32px);
  padding-top: clamp(16px, 1.8vw, 24px);
  border-top: 1px solid var(--c-border);
}

.metric-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.metric-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.metric-label {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--c-muted);
}

.metric-value {
  font-size: clamp(28px, 2.4vw, 36px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.bar-track {
  height: 10px;
  background: var(--c-bg);
  border-radius: var(--r-pill);
  overflow: hidden;
  border: 1px solid var(--c-border);
}

.bar-fill {
  height: 100%;
  background: var(--c-blue);
  border-radius: var(--r-pill);
  transition: width var(--dur-base) var(--ease-snappy);
}

.metric-detail {
  font-size: 13px;
  color: var(--c-muted2);
  margin-top: 2px;
  text-align: right;
}

/* ── MACHINE POWER ACTIONS ── */
.machine-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: clamp(16px, 1.8vw, 24px);
  border-top: 1px solid var(--c-border);
}

/* ── HOST CARD FOOTER ── */
.host-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: clamp(16px, 1.8vw, 24px);
  border-top: 1px solid var(--c-border);
  font-size: 14px;
  color: var(--c-muted);
}

.host-footer-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--c-text);
}

/* ── SERVICES GRID (3-Col Desktop, Spacious Fill) ── */
.services-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(20px, 2vw, 32px);
}

.service-card {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 20px;
  padding: clamp(16px, 1.8vw, 24px);
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 1.5vw, 20px);
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--dur-fast) var(--ease-snappy),
              transform var(--dur-fast) var(--ease-snappy);
}
.service-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.service-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
}

.service-identity {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
  flex: 1;
}

.service-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.service-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.service-cmd {
  font-size: 13px;
  color: var(--c-muted2);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

/* ── SERVICE STATS ── */
.service-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  padding: 14px 18px;
  background: var(--c-bg);
  border-radius: var(--r-md);
  border: 1px solid rgba(0,0,0,0.03);
}

.stat-cell { display: flex; flex-direction: column; gap: 2px; }

.stat-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--c-muted2);
}

.stat-value {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--c-text);
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

/* ── SERVICE ACTION ROW ── */
.service-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding-top: clamp(14px, 1.5vw, 20px);
  border-top: 1px solid var(--c-border);
}

.service-action-left { display: flex; align-items: center; gap: var(--sp-2); }
.service-action-right { display: flex; align-items: center; gap: var(--sp-2); }

/* ── INFRASTRUCTURE GRID (Fills Desktop Bottom) ── */
.infra-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(20px, 2vw, 32px);
}

.infra-card {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 16px;
  padding: clamp(14px, 1.5vw, 20px) clamp(16px, 1.8vw, 24px);
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  min-height: 80px;
}

.infra-icon {
  width: 48px;
  height: 48px;
  background: var(--c-blue-light);
  border: 1px solid var(--c-blue-border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.infra-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.25;
}

.infra-desc {
  font-size: 12.5px;
  color: var(--c-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── LOGIN VIEW ── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 68px - 56px);
  padding: var(--sp-6);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  box-shadow: var(--shadow-lg);
}

.login-icon-wrap {
  width: 58px;
  height: 58px;
  background: var(--c-blue-light);
  border: 1px solid var(--c-blue-border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--c-text);
  line-height: 1.15;
}

.login-desc {
  font-size: 14px;
  color: var(--c-muted);
  line-height: 1.5;
  margin-top: -6px;
}

.login-form { display: flex; flex-direction: column; gap: var(--sp-4); }

/* ── FORM FIELDS ── */
.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--c-muted);
}

.field-input {
  width: 100%;
  height: 46px;
  padding: 0 16px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  color: var(--c-text);
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-snappy),
              box-shadow var(--dur-fast) var(--ease-snappy);
}
.field-input::placeholder { color: var(--c-muted2); }
.field-input:focus { border-color: var(--c-blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.error-banner {
  padding: 10px 16px;
  background: var(--c-red-bg);
  border: 1px solid var(--c-red-border);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--c-red);
}

/* ── CHECKBOX ── */
.checkbox-row { display: flex; align-items: center; gap: 24px; padding-top: 6px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--c-muted); cursor: pointer; }
.checkbox-label input { width: 18px; height: 18px; border-radius: 4px; accent-color: var(--c-blue); cursor: pointer; }

/* ── MODALS ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15,15,20,0.55);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}

.modal-shell {
  width: 100%;
  max-width: 560px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-shell--wide { max-width: 920px; height: 78vh; }
.modal-shell--sm { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}

.modal-title { font-size: 16px; font-weight: 700; color: var(--c-text); }

.modal-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border);
}

/* ── TERMINAL ── */
.term-body {
  flex: 1;
  padding: 18px;
  font-size: 13px;
  overflow-y: auto;
  background: #181822;
  color: #d8d8e4;
  user-select: text;
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.6;
}

.term-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
}

.term-prompt { color: var(--c-muted2); font-size: 18px; user-select: none; }

.term-input {
  flex: 1;
  height: 40px;
  padding: 0 14px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  color: var(--c-text);
  font-size: 13px;
  outline: none;
}
.term-input:focus { border-color: var(--c-blue); }
.term-input::placeholder { color: var(--c-muted2); }

.log-line { font-size: 13px; line-height: 1.6; display: flex; gap: 12px; }
.log-stream-stderr { color: #f87171; }
.log-stream-system { color: #6b7280; font-style: italic; }
.log-stream-stdout { color: #d1d5db; }

/* ── TOAST ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--c-text);
  pointer-events: auto;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur-base) var(--ease-snappy),
              transform var(--dur-base) var(--ease-snappy);
}
.toast.toast--visible { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--c-red-bg); border-color: var(--c-red-border); color: var(--c-red); }
.toast--success { background: var(--c-green-bg); border-color: var(--c-green-border); color: var(--c-green); }

/* ── FOOTER ── */
.footer {
  border-top: 1px solid var(--c-border);
  padding: 20px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c-muted2);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  background: var(--c-surface);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS (Maurice Geßwein Smart UI Dimensions)
   ═══════════════════════════════════════════════════════════════ */

/* Tablet & Medium Displays (768px – 1180px) */
@media (max-width: 1180px) {
  .main-content {
    max-width: 100%;
    padding: 24px;
    gap: 28px;
  }

  .services-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }

  .infra-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
}

/* Mobile Screens (< 768px) */
@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  #dashboard-view {
    justify-content: flex-start;
    gap: 24px;
  }

  .navbar-inner {
    padding: 0 16px;
    height: 56px;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .brand-name {
    font-size: 16px;
  }

  .brand-sub {
    display: none;
  }

  .logout-text {
    display: none;
  }

  .ws-badge {
    height: 36px;
    padding: 0 12px;
    font-size: 12px;
  }

  .navbar-right .btn-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .main-content {
    padding: 16px;
    gap: 24px;
  }

  .machines-grid,
  .services-grid,
  .infra-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .card,
  .service-card {
    padding: 16px;
    gap: 16px;
    border-radius: 18px;
    min-width: 0;
  }

  .infra-card {
    padding: 16px;
    gap: 14px;
    border-radius: 16px;
    min-height: auto;
    min-width: 0;
  }

  /* Card Top Row */
  .card-top,
  .service-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: nowrap;
    min-width: 0;
  }

  .machine-identity,
  .service-identity {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
  }

  .machine-identity > div,
  .service-identity > div {
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  .machine-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    max-width: 44px;
    border-radius: 12px;
    flex-shrink: 0;
  }

  .machine-name {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  .machine-meta {
    font-size: 12px;
    gap: 4px;
    flex-wrap: wrap;
    white-space: normal;
    line-height: 1.4;
    min-width: 0;
  }

  .badge {
    padding: 6px 14px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .metrics-row {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding-top: 16px;
  }

  .metric-value {
    font-size: 24px;
  }

  .bar-track {
    height: 8px;
  }

  /* Maurice Geßwein 48dp touch standard for mobile buttons */
  .machine-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 16px;
  }

  .machine-actions .btn-primary {
    flex: 1.25;
    height: 48px;
    min-height: 48px;
    padding: 0 10px;
    font-size: 12.5px;
  }

  .machine-actions .btn-danger {
    flex: 1;
    height: 48px;
    min-height: 48px;
    padding: 0 10px;
    font-size: 12.5px;
  }

  .machine-actions .btn-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    flex-shrink: 0;
  }

  .service-icon {
    width: 42px;
    height: 42px;
    min-width: 42px;
    max-width: 42px;
    flex-shrink: 0;
  }

  .service-name {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  .service-cmd {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .service-stats {
    padding: 12px 14px;
    gap: 8px;
  }

  .stat-value {
    font-size: 15px;
  }

  .service-actions {
    padding-top: 16px;
    gap: 8px;
  }

  .service-actions .btn-primary,
  .service-actions .btn-secondary,
  .service-actions .btn-danger,
  .service-actions .btn-power-off {
    height: 44px;
    min-height: 44px;
    padding: 0 14px;
    font-size: 13px;
  }

  .service-actions .btn-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .infra-icon {
    width: 42px;
    height: 42px;
    min-width: 42px;
    flex-shrink: 0;
  }

  .infra-title {
    font-size: 14.5px;
  }

  .infra-desc {
    font-size: 11.5px;
    white-space: normal;
    line-height: 1.4;
  }

  .footer {
    width: 100%;
    margin-top: auto;
  }
}

/* Small Phone Screens (<= 375px) */
@media (max-width: 375px) {
  .main-content {
    padding: 12px;
    gap: 18px;
  }

  .card,
  .service-card {
    padding: 14px;
    gap: 14px;
  }

  .machine-actions {
    gap: 6px;
  }

  .machine-actions .btn-primary,
  .machine-actions .btn-danger {
    font-size: 12px;
    padding: 0 6px;
    gap: 4px;
    height: 44px;
    min-height: 44px;
  }

  .machine-actions .btn-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}

/* ── REDUCED MOTION PREFERENCE (A11y Standard) ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
