:root {
  color-scheme: light;
  --ink: #15201f;
  --ink-soft: #56615f;
  --paper: #f4f0e8;
  --surface: #fffdf8;
  --line: #d8d2c6;
  --accent: #e85d3f;
  --accent-dark: #bd3e26;
  --teal: #1c8279;
  --navy: #183139;
  --shadow: 0 18px 55px rgba(30, 37, 35, 0.09);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(24, 49, 57, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 49, 57, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, summary, .drop-zone { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 5vw;
  border-bottom: 1px solid rgba(216, 210, 198, 0.85);
  background: rgba(244, 240, 232, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--navy);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px 10px 10px 3px;
  color: white;
  background: var(--accent);
  font-size: 16px;
  box-shadow: 0 6px 14px rgba(232, 93, 63, 0.25);
}

.topbar-actions { display: flex; align-items: center; gap: 20px; }
.topbar-actions form { margin: 0; }
.text-button { border: 0; color: var(--ink-soft); background: none; cursor: pointer; }
.text-button:hover { color: var(--ink); }

.health-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(255, 253, 248, 0.65);
  font-size: 12px;
  font-weight: 700;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #a7aaa6; }
.health-chip.healthy .status-dot { background: #2ca66f; box-shadow: 0 0 0 4px rgba(44, 166, 111, 0.12); }
.health-chip.unhealthy .status-dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(232, 93, 63, 0.12); }
.health-chip.checking .status-dot { animation: pulse 1.2s infinite; }

.shell { width: min(1160px, 90vw); margin: 0 auto; padding: 70px 0 54px; }

.hero {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  align-items: end;
  gap: 50px;
  margin-bottom: 52px;
}

.eyebrow, .section-kicker {
  margin: 0 0 14px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(48px, 7vw, 88px);
  font-weight: 850;
  line-height: 0.93;
  letter-spacing: -0.07em;
}

.hero h1 span { color: var(--accent); }
.hero-copy { max-width: 660px; margin: 27px 0 0; color: var(--ink-soft); font-size: 17px; line-height: 1.7; }
.hero-copy code, .contract code { padding: 2px 5px; border-radius: 5px; color: var(--navy); background: rgba(24, 49, 57, 0.07); font-size: 0.88em; }

.flow {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 9px;
  color: var(--navy);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.flow span { display: grid; width: 58px; height: 58px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); }
.flow span:last-child { color: white; border-color: var(--teal); background: var(--teal); }
.flow i { width: 30px; height: 1px; background: var(--line); }

.upload-panel {
  overflow: hidden;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 24px 24px 24px 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-heading, .section-heading, .modal-card header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.upload-heading { margin-bottom: 24px; }
.upload-heading h2, .section-heading h2, .modal-card h2 { margin: 0; color: var(--navy); font-size: 25px; letter-spacing: -0.045em; }
.section-kicker { margin-bottom: 7px; }
.limit { color: var(--ink-soft); font-size: 12px; font-weight: 700; }

.drop-zone {
  display: flex;
  min-height: 220px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  border: 2px dashed #c9c1b3;
  border-radius: 17px;
  background: #faf7f0;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone:hover, .drop-zone.dragging { border-color: var(--accent); background: #fff4ee; transform: translateY(-2px); }
.drop-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.upload-icon { display: grid; width: 46px; height: 46px; margin-bottom: 15px; place-items: center; border-radius: 14px; color: white; background: var(--navy); font-size: 23px; font-weight: 600; }
.drop-title { color: var(--navy); font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.drop-subtitle { margin-top: 5px; color: var(--ink-soft); font-size: 13px; }
.selected-file { margin-top: 15px; padding: 7px 11px; border-radius: 8px; color: var(--teal); background: rgba(28, 130, 121, 0.09); font-size: 12px; font-weight: 750; }

.upload-controls { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr) auto; align-items: end; gap: 15px; margin-top: 20px; }
.name-field { display: grid; min-width: 0; gap: 7px; color: var(--ink); font-size: 12px; font-weight: 800; }
.name-field em { color: #909692; font-style: normal; font-weight: 500; }
.name-field input, .login-form input { width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--ink); background: white; }
.name-field input:focus, .login-form input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(28, 130, 121, 0.12); }
.domain-input { display: flex; min-width: 0; height: 46px; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: white; }
.domain-input:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(28, 130, 121, 0.12); }
.name-field .domain-input input { min-width: 70px; height: 44px; border: 0; border-radius: 0; box-shadow: none; }
.domain-input b { overflow: hidden; max-width: 58%; padding-right: 13px; color: var(--ink-soft); font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: 0.55; transform: none; cursor: wait; }
.button.primary { color: white; background: var(--accent); box-shadow: 0 7px 16px rgba(232, 93, 63, 0.2); }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { color: var(--navy); border-color: var(--line); background: var(--surface); }
.button.compact { min-height: 39px; padding: 0 15px; }

.progress-wrap { margin-top: 16px; color: var(--ink-soft); font-size: 12px; }
.progress-wrap p { margin: 7px 0 0; }
.progress-track { overflow: hidden; height: 5px; border-radius: 5px; background: #ebe6dc; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--teal); transition: width 100ms linear; }

.alert { margin-top: 15px; padding: 11px 13px; border-radius: 8px; font-size: 13px; }
.alert.error { color: #8d2e1d; border: 1px solid #f0c0b6; background: #fff1ed; }

.apps-section { margin-top: 66px; }
.section-heading { margin-bottom: 20px; }
.app-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.app-card { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255, 253, 248, 0.88); box-shadow: 0 10px 35px rgba(30, 37, 35, 0.055); }
.app-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.app-identity { display: flex; min-width: 0; align-items: center; gap: 12px; }
.python-mark { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border-radius: 11px 11px 11px 4px; color: white; background: var(--navy); font-family: Georgia, serif; font-size: 14px; font-weight: 700; }
.app-identity h3 { overflow: hidden; margin: 0; color: var(--navy); font-size: 17px; letter-spacing: -0.025em; text-overflow: ellipsis; white-space: nowrap; }
.app-identity p { overflow: hidden; max-width: 250px; margin: 4px 0 0; color: #868b87; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 99px; color: #626a67; background: #efede8; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.status i { width: 6px; height: 6px; border-radius: 50%; background: #8b918e; }
.status.running { color: #16724f; background: #e5f5ed; }
.status.running i { background: #269d6b; }
.status.error, .status.missing { color: #a23d2a; background: #fbe9e5; }
.status.error i, .status.missing i { background: var(--accent); }
.status.building, .status.queued, .status.starting, .status.restarting { color: #735c08; background: #fbf2d4; }
.status.building i, .status.queued i, .status.starting i, .status.restarting i { background: #d6a300; animation: pulse 1.2s infinite; }
.app-error { overflow: hidden; margin: 16px 0 0; color: #a23d2a; font-size: 12px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.build-line { overflow: hidden; height: 3px; margin-top: 18px; border-radius: 4px; background: #eee8dc; }
.build-line span { display: block; width: 35%; height: 100%; background: var(--accent); animation: build 1.4s infinite ease-in-out; }
.app-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 23px; padding: 17px 0; border-top: 1px solid #e6e1d7; border-bottom: 1px solid #e6e1d7; }
.app-meta > div { display: grid; gap: 5px; }
.app-meta span { color: #919692; font-size: 10px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }
.app-meta strong, .endpoint { overflow: hidden; color: var(--navy); font-size: 13px; font-weight: 750; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.endpoint span { margin-left: 4px; color: var(--teal); font-size: inherit; }
.endpoint.unavailable { color: #9b9e9b; font-weight: 600; }
.endpoint-wrap { display: grid; min-width: 0; gap: 4px; }
.endpoint-wrap small { overflow: hidden; color: #999d99; font-size: 10px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.app-actions { display: flex; align-items: center; gap: 9px; margin-top: 16px; }
.action-menu { position: relative; margin-left: auto; }
.action-menu summary { display: grid; width: 39px; height: 39px; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-soft); background: var(--surface); cursor: pointer; list-style: none; letter-spacing: 1px; }
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu > div { position: absolute; z-index: 10; right: 0; bottom: 46px; display: grid; min-width: 150px; padding: 6px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); box-shadow: var(--shadow); }
.menu-item { padding: 9px 10px; border: 0; border-radius: 7px; color: var(--ink); background: transparent; font-size: 12px; text-align: left; cursor: pointer; }
.menu-item:hover { background: #f1eee7; }
.menu-item.danger { color: #af3d28; }

.empty-state { grid-column: 1 / -1; display: grid; min-height: 230px; place-items: center; align-content: center; padding: 40px; border: 1px dashed #c9c1b3; border-radius: 17px; color: var(--ink-soft); background: rgba(255, 253, 248, 0.55); text-align: center; }
.empty-state h3 { margin: 10px 0 3px; color: var(--navy); }
.empty-state p { margin: 0; font-size: 13px; }
.empty-icon { color: var(--accent); font-size: 38px; }
.loading-state { gap: 12px; }
.spinner { width: 25px; height: 25px; border: 3px solid #ddd7cc; border-top-color: var(--teal); border-radius: 50%; animation: spin 0.8s linear infinite; }

.contract { display: flex; align-items: center; gap: 22px; margin-top: 32px; padding: 18px 20px; border-left: 4px solid var(--teal); border-radius: 0 10px 10px 0; color: var(--ink-soft); background: rgba(255, 253, 248, 0.66); font-size: 12px; line-height: 1.7; }
.contract strong { flex: 0 0 auto; color: var(--navy); }

.modal[hidden] { display: none; }
.modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16, 28, 30, 0.62); backdrop-filter: blur(3px); }
.modal-card { position: relative; display: flex; width: min(900px, 95vw); max-height: 85vh; flex-direction: column; padding: 24px; border-radius: 19px; background: var(--surface); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.25); }
.icon-button { width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink-soft); background: white; font-size: 23px; cursor: pointer; }
.log-tabs { display: flex; gap: 5px; margin-top: 19px; border-bottom: 1px solid var(--line); }
.log-tabs button { padding: 10px 13px; border: 0; border-bottom: 2px solid transparent; color: var(--ink-soft); background: none; font-size: 12px; font-weight: 800; cursor: pointer; }
.log-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
#log-output { overflow: auto; min-height: 280px; margin: 16px 0 0; padding: 18px; border-radius: 10px; color: #dce7e3; background: #152422; font: 12px/1.65 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.modal-open { overflow: hidden; }

.toast-region { position: fixed; z-index: 100; right: 24px; bottom: 24px; display: grid; gap: 9px; }
.toast { max-width: 360px; padding: 12px 15px; border-radius: 10px; color: white; background: var(--teal); box-shadow: var(--shadow); font-size: 13px; font-weight: 700; animation: toast-in 180ms ease-out; }
.toast.error { background: var(--accent-dark); }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 25px; }
.login-card { width: min(430px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 22px 22px 22px 7px; background: var(--surface); box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 45px; }
.login-card h1 { margin: 0; color: var(--navy); font-size: 40px; letter-spacing: -0.055em; }
.muted { color: var(--ink-soft); font-size: 14px; line-height: 1.6; }
.login-form { display: grid; gap: 10px; margin-top: 25px; }
.login-form label { font-size: 12px; font-weight: 800; }
.login-form .button { margin-top: 7px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes build { from { transform: translateX(-110%); } to { transform: translateX(390%); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 800px) {
  .shell { width: min(92vw, 650px); padding-top: 45px; }
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .flow { justify-content: flex-start; }
  .app-grid { grid-template-columns: 1fr; }
  .upload-controls { grid-template-columns: 1fr 1fr; }
  .upload-controls .button { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .topbar { min-height: 64px; padding: 0 4vw; }
  .health-chip { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .text-button { display: none; }
  .hero h1 { font-size: 48px; }
  .flow span { width: 52px; height: 52px; }
  .upload-panel { padding: 20px; }
  .upload-controls { grid-template-columns: 1fr; align-items: stretch; }
  .upload-controls .button { width: 100%; }
  .app-meta { grid-template-columns: 1fr; }
  .contract { align-items: flex-start; flex-direction: column; gap: 7px; }
  .modal { padding: 10px; }
  .modal-card { padding: 18px; }
}

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