/* One stylesheet for the whole daemon UI: a wizard, a login form and a status
   page. Deliberately small — no framework, no build step, no third-party
   requests (the CSP forbids them anyway). */

:root {
  color-scheme: light dark;
  --bg: #fbfbfa;
  --panel: #ffffff;
  --ink: #1c1c1a;
  --muted: #6b6b66;
  --line: #e4e4e0;
  --accent: #b4531f;
  --accent-ink: #ffffff;
  --ok: #1f7a4d;
  --warn: #9a6700;
  --bad: #b42318;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --panel: #1e1e23;
    --ink: #ecece8;
    --muted: #9a9a94;
    --line: #2e2e35;
    --accent: #e2793c;
    --accent-ink: #1a1206;
    --ok: #4ec38a;
    --warn: #e0b341;
    --bad: #f2796b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 3rem 1.25rem 5rem;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

main { max-width: 40rem; margin: 0 auto; }

header.brand { display: flex; align-items: baseline; gap: .6rem; margin-bottom: 2rem; }
header.brand h1 { font-size: 1.15rem; margin: 0; letter-spacing: -0.01em; }
header.brand span { color: var(--muted); font-size: .85rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

h2 { font-size: 1.05rem; margin: 0 0 .35rem; }
p  { margin: .35rem 0 1rem; color: var(--muted); }
p.lead { color: var(--ink); }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }

input[type=text], input[type=password] {
  width: 100%;
  padding: .6rem .7rem;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit;
  font-weight: 600;
  padding: .55rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--muted); border-color: var(--line); }
button[disabled] { opacity: .55; cursor: progress; }
.actions { display: flex; gap: .6rem; align-items: center; margin-top: 1rem; }

ol.steps { list-style: none; display: flex; gap: 1rem; padding: 0; margin: 0 0 1.5rem; font-size: .85rem; color: var(--muted); }
ol.steps li { display: flex; gap: .4rem; align-items: center; }
ol.steps li.current { color: var(--ink); font-weight: 600; }
ol.steps li.done::before { content: "✓"; color: var(--ok); }
ol.steps li .n { display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; border: 1px solid var(--line); font-size: .75rem; }
ol.steps li.done .n { display: none; }

table.records { width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: 1rem; }
table.records td { padding: .45rem .3rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.records td.state { width: 1.5rem; }
code, .mono { font-family: var(--mono); font-size: .875em; }
pre.record { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .7rem .8rem; overflow-x: auto; margin: .3rem 0 0; }
/* A disclosure over something long — a system prompt — so the page it sits on
   is not mostly it. The pre inside scrolls rather than stretching the panel. */
details > summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
details > pre.record { max-height: 22rem; overflow: auto; white-space: pre-wrap; }

.ok   { color: var(--ok); }
.warn { color: var(--warn); }
.bad  { color: var(--bad); }

.notice { border-left: 3px solid var(--line); padding: .1rem 0 .1rem .8rem; margin: 1rem 0; font-size: .92rem; }
.notice.error { border-color: var(--bad); color: var(--bad); }
.notice.ok { border-color: var(--ok); }

.code-badge {
  display: inline-block; font-family: var(--mono); font-size: 1.6rem; letter-spacing: .16em;
  padding: .5rem .9rem; border: 1px dashed var(--line); border-radius: 10px; margin: .25rem 0 1rem;
}

dl.status { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.2rem; margin: 0; font-size: .95rem; }
dl.status dt { color: var(--muted); }
dl.status dd { margin: 0; }

footer { color: var(--muted); font-size: .85rem; text-align: center; margin-top: 2rem; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* --- M2: apps, import, deployments -------------------------------------- */

header.brand h1 a { color: inherit; text-decoration: none; }
header.brand nav { margin-left: auto; }

.button-link {
  font-weight: 600; font-size: .9rem; padding: .5rem .9rem; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
}
button.danger { color: var(--bad); border-color: var(--bad); }
.panel.danger { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }

.hint { color: var(--muted); font-size: .85rem; margin: .2rem 0 1rem; }
/* A hint that enumerates rather than explains: the cases a field is for. */
ul.hint { padding-left: 1.1rem; }
ul.hint li { margin: .25rem 0; }
.muted { color: var(--muted); }
.tag { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
       border: 1px solid var(--line); border-radius: 4px; padding: 0 .3rem; }

textarea {
  width: 100%; padding: .6rem .7rem; font: inherit; font-family: var(--mono); font-size: .85rem;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
select {
  width: 100%; padding: .55rem .6rem; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}

/* Apps list */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.2rem;
}
.card-head { display: flex; align-items: center; gap: .5rem; }
/* A card whose dot comes first wants it beside the title, not shoved to the
   far edge — the .dot default pushes itself right, which is what a trailing
   dot needs and a leading one does not. */
.card-head .dot:first-child { margin-left: 0; }
.card-head h2 { margin: 0; font-size: 1rem; }
.card-head h2 a { color: inherit; text-decoration: none; }
.card-host { margin: .15rem 0 .6rem; font-size: .85rem; }
.card-line { margin: .1rem 0; font-size: .85rem; color: var(--ink); }

/* A state is a dot: it has to read at a glance across a grid of cards. */
.dot { width: .6rem; height: .6rem; border-radius: 50%; display: inline-block;
       background: var(--warn); margin-left: auto; flex: none; }
.dot.ok  { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }
.dot.muted { background: var(--line); }

/* Import: the repository picker */
.repo-list { display: flex; flex-direction: column; gap: .25rem; max-height: 24rem; overflow-y: auto; }
button.repo {
  display: grid; grid-template-columns: 1fr auto; gap: .1rem .8rem; text-align: left;
  background: transparent; color: var(--ink); border: 1px solid transparent;
  border-radius: 8px; padding: .5rem .6rem; cursor: pointer; font-weight: 400;
}
button.repo:hover { border-color: var(--line); background: var(--bg); }
.repo-name { font-weight: 600; font-size: .92rem; }
.repo-desc { grid-column: 1; color: var(--muted); font-size: .82rem; }
.repo-branch { grid-row: 1 / span 2; align-self: center; color: var(--muted); }

/* App detail */
.app-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.app-head h2 { margin: 0 0 .2rem; }
.app-head .actions { margin-top: 0; flex: none; }
table.records td { font-size: .87rem; }

/* Deployment: the phase timeline and the log */
ol.phases {
  list-style: none; display: flex; flex-wrap: wrap; gap: .9rem; padding: 0;
  margin: 1rem 0 .5rem; font-size: .85rem; color: var(--muted);
}
ol.phases li::before { content: "○ "; }
ol.phases li.done { color: var(--ok); }
ol.phases li.done::before { content: "✓ "; }
ol.phases li.current { color: var(--ink); font-weight: 600; }
ol.phases li.current::before { content: "▸ "; }

.log-panel { padding-bottom: 1rem; }
label.follow { display: flex; align-items: center; gap: .4rem; font-weight: 400; font-size: .85rem;
               color: var(--muted); margin: 0; }

/* The log is monospace, scrolls itself, and never grows the page — a build can
   emit thousands of lines and the surrounding UI must stay reachable. */
pre.log {
  background: #10100f; color: #e6e4df; border-radius: 10px; border: 1px solid var(--line);
  padding: .8rem 1rem; margin: .6rem 0 .4rem; max-height: 32rem; overflow: auto;
  font-family: var(--mono); font-size: .8rem; line-height: 1.5; white-space: pre-wrap;
  overflow-wrap: anywhere;
}
pre.log .note  { color: #9fc6e8; }
pre.log .phase { color: #d7b36a; }
pre.log .hint  { color: #9a978f; font-size: inherit; margin: 0; }
pre.log .bad   { color: #f2796b; }

.big-url { font-size: 1.15rem; font-weight: 600; margin: 1rem 0 .2rem; overflow-wrap: anywhere; }

button.repo.chosen { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* --- M4: environment, databases, and the generated Dockerfile ------------- */

/* Number inputs were never styled because nothing needed one until the port
   and the start grace did. They match the text inputs exactly. */
input[type=number] {
  width: 100%; box-sizing: border-box; padding: .5rem .6rem; margin-bottom: 1rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  color: var(--ink); font: inherit;
}

/* A row of related fields — port, health path and grace belong together, and
   stacking them makes a settings form nobody reads to the end. */
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row > * { flex: 1 1 12rem; min-width: 0; }

label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; margin: .2rem 0 .6rem; }
label.check input { margin: 0; }
label.check.hint { font-size: .8rem; color: var(--muted); margin-top: .35rem; }

.notice.info { border-color: var(--accent); }
.notice.warn { border-color: var(--warn); color: var(--warn); }
.notice.bad  { border-color: var(--bad); color: var(--bad); }

/* An anchor that has to look like a button: the backup download is a real
   link, because a fetch would put the file in memory instead of on disk. */
a.button {
  display: inline-block; text-decoration: none; padding: .45rem .8rem;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--accent);
  color: var(--panel); font: inherit; font-size: .9rem; cursor: pointer;
}
a.button.secondary { background: transparent; color: var(--muted); border-color: var(--line); }

/* The generated Dockerfile, shown before it becomes a pull request. It scrolls
   inside itself rather than widening the page. */
pre.code {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: .7rem .8rem; overflow-x: auto; margin: .3rem 0 1rem;
  font-family: var(--mono); font-size: .78rem; line-height: 1.5;
}

details > summary { cursor: pointer; color: var(--muted); font-size: .9rem; margin-bottom: .6rem; }

.panel h3 { font-size: .95rem; margin: 1.6rem 0 .4rem; }
.panel h3:first-child { margin-top: 0; }

/* --- the shell: sidebar, project header, tabs ---------------------------- */

/* A shelled page gives up the body padding: the sidebar runs the full height
   and the content column does its own spacing. Pages that never mount the
   shell — login, the setup wizard — keep the centred layout above. */
body.shelled { padding: 0; }
body.shelled main { margin: 0; padding: 0; }

.layout { display: flex; align-items: stretch; min-height: 100vh; }

.sidebar {
  flex: none; width: 20rem; padding: 1.1rem .7rem 1.1rem;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink) 3%, var(--bg));
  position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar-brand { font-weight: 600; font-size: .95rem; padding: .1rem .55rem 1.1rem; }
.sidebar-brand a { color: inherit; text-decoration: none; }

.sidebar-nav { display: flex; flex-direction: column; gap: .1rem; }
.sidebar-link {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .55rem; border-radius: 7px;
  color: var(--ink); text-decoration: none; font-size: .9rem;
}
.sidebar-link:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.sidebar-link.current { background: color-mix(in srgb, var(--ink) 9%, transparent); font-weight: 600; }
.sidebar-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-project { min-width: 0; }
/* The sidebar's own dot: the .dot the cards use pushes itself to the right
   with margin-left:auto, which is exactly wrong in front of a name. */
.sidebar-dot {
  width: .45rem; height: .45rem; border-radius: 50%; flex: none;
  background: var(--line); border: 1px solid var(--muted);
}
.sidebar-dot.ok { background: var(--ok); border-color: var(--ok); }
.sidebar-dot.bad { background: var(--bad); border-color: var(--bad); }
.sidebar-dot.muted { background: transparent; border-color: var(--line); }

.sidebar-heading {
  display: flex; align-items: center; justify-content: space-between;
  margin: 1.5rem .55rem .4rem; font-size: .72rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.sidebar-add { text-decoration: none; color: var(--muted); font-size: 1rem; line-height: 1;
               padding: 0 .25rem; border-radius: 5px; }
.sidebar-add:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.sidebar-empty { font-size: .82rem; color: var(--muted); padding: 0 .55rem; margin: 0; }

/* Who you are and the way out, pinned below the projects — margin-top:auto
   rather than a fixed position, so on a long list it follows the list instead
   of sitting on top of it. */
.sidebar-foot { margin-top: auto; padding: 1rem .55rem 0; }
.sidebar-who { margin: 0 0 .5rem; font-size: .8rem; color: var(--muted); }
.sidebar-foot button { font-size: .82rem; padding: .3rem .7rem; }

/* A count, on a tab or beside a project. Never zero — see shell.js. */
.pill {
  margin-left: auto; flex: none; font-size: .7rem; font-variant-numeric: tabular-nums;
  min-width: 1.15rem; text-align: center; padding: .05rem .3rem; border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--muted);
}
.pill.warn { background: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); }

.content { flex: 1; min-width: 0; padding: 1.75rem 2rem 4rem; }
.content > main { max-width: 56rem; }

/* Inside the shell the page's own brand header is redundant — the sidebar says
   which box this is, and the project header says which project. */
body.shelled header.brand { display: none; }

.project-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: .5rem; }
.project-title h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
.project-meta { margin: .15rem 0 0; font-size: .85rem; color: var(--muted); }
.project-meta .sep { opacity: .5; margin: 0 .4rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; }
.tabs a {
  display: flex; align-items: center; gap: .35rem;
  padding: .5rem .75rem; margin-bottom: -1px;
  color: var(--muted); text-decoration: none; font-size: .9rem;
  border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--ink); }
.tabs a.current { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.tabs .pill { margin-left: 0; }

/* The page's title above the content, for pages that are not inside a project
   and so have no project header of their own. */
.page-head { display: flex; align-items: flex-start; justify-content: space-between;
             gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
.page-head p { margin: .2rem 0 0; font-size: .9rem; }
.page-head .actions { margin: 0; flex: none; }

/* Narrow screens: the sidebar becomes a strip across the top rather than
   disappearing, because it is the only navigation there is. */
@media (max-width: 55rem) {
  .layout { display: block; }
  .sidebar { width: auto; height: auto; position: static; border-right: 0;
             border-bottom: 1px solid var(--line); padding: .8rem 1rem; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  #shell-projects { flex-direction: column; }
  .sidebar-heading { margin: .8rem 0 .3rem; }
  .content { padding: 1.25rem 1rem 3rem; }
}

/* A long settings page says up front what is on it. Anchors, not tabs: the
   panels are all one page and reading past the one you came for is often how
   you find the one you needed. */
.jump { display: flex; flex-wrap: wrap; gap: .35rem; margin: -.5rem 0 1.25rem; }
.jump a { font-size: .82rem; text-decoration: none; color: var(--muted);
          border: 1px solid var(--line); border-radius: 999px; padding: .15rem .6rem; }
.jump a:hover { color: var(--ink); border-color: var(--ink); }

/* --- the usage strip ------------------------------------------------------
   The one thing above the cards that is there every day, so it is built to be
   skipped: muted text at the size of a hint, the box's own numbers. The
   hairline underneath is all that separates it from the grid — a panel around
   this would make it furniture. */
.usage {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: .35rem 1.5rem; font-size: .82rem; color: var(--muted);
  border-bottom: 1px solid var(--line); padding-bottom: .7rem; margin-bottom: 1.2rem;
}
.usage-host { margin: 0; font-variant-numeric: tabular-nums; }

/* A breadcrumb for a page that hangs off a project without being one of its
   tabs: a deployment's log. */
.crumb { font-size: .85rem; color: var(--muted); margin: 0 0 1rem; }
.crumb a { color: var(--muted); }
