/* dos-rda — UI v2
   DOS Cloud shared identity (see ../../../docs/design-system.md): centered
   wordmark + short red brand line + Digital Governance footer. Editorial-clean
   with a restrained neo-brutalist touch. RDA's functional accent is teal;
   the brand line stays DOS red. */

:root {
  /* Warm-paper research-journal palette. Canvas is a mint-tinted warm white,
     never pure white; surfaces layer by tone (mint card / blush panel), and
     depth is color, not shadow. RDA's functional accent is deep teal; the
     brand line stays DOS red. */
  --bg: #f2f8f7;              /* page canvas — warm mint-tinted white */
  --surface: #e4f0f1;         /* card / section — mint */
  --surface-warm: #f2e8e2;    /* form / alternating panel — blush sand */
  --field: #f7fbfb;           /* input fill — near-white for contrast on mint */
  --wash: #cae1e2;            /* sea-foam highlight / row hover */
  --ink: #283338;             /* charcoal navy — headings, nav */
  --ink-soft: #333333;
  --ink-muted: #52615f;
  --line: #d3e4e3;
  --line-strong: #bcd6d4;

  --brand-line: #c9143f;      /* DOS Design red — shared Cloud brand mark */

  --accent: #1c5d5f;          /* deep teal — sole primary action */
  --accent-ink: #0e4749;      /* pine shadow — ghost border/text, links */
  --accent-deep: #156152;     /* filled hover / selected */
  --accent-soft: #cae1e2;     /* sea-foam wash — focus ring, soft fills */
  --navy: #16325a;            /* second product direction */
  --sage: #65b8a2;            /* decorative / secondary strokes */
  --rose: #d6aec1;            /* warm accent / return badges */

  --dark: #16325a;            /* dark pill (navy) */

  --serif: "Source Serif 4", Lora, Georgia, serif;
  --mono: "IBM Plex Mono", "Geist Mono", ui-monospace, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 48px;
  --shadow: none;             /* flat: distinguished by tone + hairline, not elevation */

  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Geist", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--ink-muted); }

/* ---------- Header / brand ---------- */

.site-header {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.6rem 1.25rem 0;
  text-align: center;
}

/* Canonical Cloud brand mark: centered wordmark + short red underline,
   shared with every DOS Cloud app. */
.brand {
  display: inline-block;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-word { font-size: 1.6rem; font-weight: 900; letter-spacing: 1px; }
.brand-word span { font-weight: 400; color: var(--ink-soft); }
.brand-line { height: 3px; width: 56px; background: var(--brand-line); margin: .5rem auto 0; }

.site-title {
  margin: 1.4rem 0 .35rem;
  font-family: var(--serif);
  font-size: 2.4rem;
  font-weight: 500;
  line-height: 1.16;
  letter-spacing: -.01em;
  color: var(--ink);
}

.site-sub {
  margin: 0 0 1.4rem;
  color: var(--ink-muted);
  font-size: .95rem;
}

/* ---------- Main / cards ---------- */

.app-main {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 1.25rem clamp(.75rem, 2vw, 2rem);
}

/* Only authentication stays compact; operational pages use the viewport. */
.app-main:has(> .auth-login) { max-width: 880px; }
.home-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: .75rem;
  margin-top: 1.4rem;
}
.home-actions a { display: flex; align-items: center; justify-content: center; }

.admin-menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); gap: 1rem; margin-top: 1.25rem; }
.admin-menu-group { min-width: 0; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.admin-menu-group h3 { margin: 0 0 .75rem; font-family: var(--serif); font-size: 1.2rem; font-weight: 500; }
.admin-menu-group ul { list-style: none; margin: 0; padding: 0; }
.admin-menu-group li + li { border-top: 1px solid var(--line); }
.admin-menu-group a { display: block; padding: .8rem .5rem; border-radius: var(--radius-sm); overflow-wrap: anywhere; }
.admin-menu-group a:hover { background: var(--accent-soft); text-decoration: none; }
.admin-menu-group a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.admin-menu-group strong { display: block; font-size: .95rem; }
.admin-menu-group span { display: block; margin-top: .35rem; font-size: .85rem; line-height: 1.55; color: var(--ink-muted); }

.app-main > section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem 1.7rem;
}

.app-main > section > h1 {
  margin: 0 0 .8rem;
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--ink);
}

.auth-login { text-align: center; }

/* ---------- Buttons / login actions ---------- */

.login-actions {
  display: flex;
  flex-direction: column;
  gap: .7rem;
  max-width: 22rem;
  margin: 1.4rem auto 0;
}

.btn-primary,
.btn-ghost {
  display: inline-block;
  font: inherit;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  padding: .65rem 1.35rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  transition: background .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease);
}
.btn-primary {
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
}
.btn-primary:hover { text-decoration: none; background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-ghost {
  color: var(--accent-ink);
  background: transparent;
  border: 1px solid var(--accent-ink);
}
.btn-ghost:hover { text-decoration: none; background: var(--wash); }

/* Navy secondary — a distinct product direction alongside the teal primary */
.btn-navy {
  display: inline-block;
  font: inherit;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  padding: .65rem 1.35rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  color: #fff;
  background: var(--navy);
  border: 1px solid var(--navy);
  transition: background .16s var(--ease);
}
.btn-navy:hover { text-decoration: none; background: #0f2745; color: #fff; }

/* Eyebrow — mono uppercase label with a small colored dot (section annotation) */
.eyebrow {
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .055em;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}
.eyebrow::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}
.eyebrow.is-navy::before { background: var(--navy); }
.eyebrow.is-sage::before { background: var(--sage); }
.eyebrow.is-rose::before { background: var(--rose); }

.logout-form { margin-top: 1.4rem; }
.logout-form button { font: inherit; }

/* ---------- Footer ---------- */

.site-footer {
  max-width: 880px;
  margin: 2.4rem auto 1.6rem;
  padding: 0 1.25rem;
  text-align: center;
  font-family: var(--mono);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-muted);
}
.site-footer strong { color: var(--ink-soft); font-weight: 600; }

/* ============================================================
   ADMIN UI — nav, tables, forms, BPM workflow
   Additive layer; every class below was previously unstyled
   (browser default) — this is the polish pass.
   ============================================================ */

.admin-section > h2 {
  margin: 2rem 0 .9rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--ink);
}
.admin-section > h2:first-of-type { border-top: 0; padding-top: 0; margin-top: 1rem; }
.admin-section > h3 {
  margin: 1.6rem 0 .7rem;
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .055em;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.admin-section > h3::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

/* ---------- Breadcrumb nav as pill buttons ---------- */

.admin-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin: 0 0 1.6rem;
}
.admin-crumbs a {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .4rem .8rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: .85rem;
  font-weight: 600;
  line-height: 1;
  transition: background .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease);
}
.admin-crumbs a:hover {
  text-decoration: none;
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Admin banner shown to admins inside /me */
.admin-nav {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  margin: 0 0 1.4rem;
  padding: .7rem 1rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: .9rem;
}

/* ---------- Tables ---------- */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  background: var(--surface);
}
.table-tools {
  display: flex;
  justify-content: flex-end;
  padding: .6rem .7rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-warm);
}
.table-search {
  width: min(18rem, 100%);
  padding: .45rem .7rem .45rem 2rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .88rem;
  background: var(--field)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b8b95' stroke-width='2' stroke-linecap='round'><circle cx='7' cy='7' r='5'/><path d='M15 15l-4-4'/></svg>")
    no-repeat .55rem center;
}
.table-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.admin-table, .rda-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.admin-table th, .admin-table td,
.rda-table th, .rda-table td {
  text-align: left;
  padding: .7rem .85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.admin-table thead th,
.rda-table thead th {
  position: sticky;
  top: 0;
  background: #d9e9ea;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .052em;
  white-space: nowrap;
}
.admin-table tbody tr:last-child td,
.rda-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover td,
.rda-table tbody tr:hover td { background: var(--accent-soft); }

/* sortable header (enhanced by table.js) */
th.sortable { cursor: pointer; user-select: none; }
th.sortable::after {
  content: "\2195";
  margin-left: .35rem;
  opacity: .35;
  font-size: .8em;
}
th.sort-asc::after { content: "\2191"; opacity: .9; color: var(--accent); }
th.sort-desc::after { content: "\2193"; opacity: .9; color: var(--accent); }
.table-empty-row td { color: var(--ink-muted); font-style: italic; }

/* ---------- Forms ---------- */

.admin-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .9rem 1.1rem;
  padding: 1.1rem 1.2rem;
  background: var(--surface-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: .4rem 0 1rem;
}
.admin-form > label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-soft);
  flex: 1 1 12rem;
  min-width: 8rem;
}
.admin-form > label.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: .45rem;
  flex: 0 0 auto;
  font-size: .88rem;
  font-weight: 500;
  color: var(--ink);
}
.admin-form .btn-primary { flex: 0 0 auto; }

/* base controls */
input[type="text"], input[type="number"], input[type="date"],
input[type="email"], input[type="password"], select, textarea {
  font: inherit;
  font-size: .9rem;
  padding: .5rem .6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--ink);
  width: 100%;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"] { width: auto; accent-color: var(--accent); }

.inline-form { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
.inline-form .btn-ghost { padding: .35rem .7rem; font-size: .82rem; }
td .inline-form + .inline-form { margin-left: .3rem; }

.plain-list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.plain-list li { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; }

.login-actions .btn-primary + .btn-primary { margin-top: 0; }

/* ---------- BPM workflow: read-only diagram ---------- */

.wf-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 1.4rem 1rem;
  background:
    radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0) 0 0 / 22px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: .4rem 0 1.4rem;
}
.wf-node {
  width: min(30rem, 100%);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: .8rem 1rem;
}
.wf-terminal {
  width: auto;
  padding: .5rem 1.1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  box-shadow: none;
}
.wf-start { background: var(--ink); color: #fff; border-color: var(--ink); }
.wf-end { background: #dff6e3; color: #1c6b31; border-color: #b7e6c4; }

.wf-step { display: flex; gap: .85rem; align-items: flex-start; }
.wf-step.is-conditional { border-style: dashed; border-color: var(--accent); }
.wf-step-n {
  flex: 0 0 auto;
  width: 1.9rem; height: 1.9rem;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  border-radius: 999px;
  font-weight: 700; font-size: .9rem;
  font-family: "Geist Mono", ui-monospace, monospace;
}
.wf-step-body { display: flex; flex-direction: column; gap: .45rem; min-width: 0; }
.wf-step-role { font-weight: 700; font-size: .98rem; }
.wf-badges { display: flex; flex-wrap: wrap; gap: .4rem; }
.wf-badge {
  display: inline-block;
  padding: .18rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  font-family: "Geist Mono", ui-monospace, monospace;
}
.wf-scope { background: var(--accent-soft); color: var(--accent-ink); }
.wf-cond-always { background: var(--line); color: var(--ink-soft); }
.wf-cond-amount { background: #fff3cd; color: #7a5b00; }
.wf-ret { background: #fbe0e5; color: #9c1030; }
.wf-badge-sync { background: var(--accent-soft); color: var(--accent-ink); }
.wf-badge-manual { background: var(--line); color: var(--ink-soft); }
.wf-badge-nonblocking { background: #fff3cd; color: #7a5b00; }
.wf-badge-target { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- Org tree (entita) ---------- */

.tree-cell { font-family: "Geist Mono", ui-monospace, monospace; }
.tree-depth-0 { padding-left: .8rem; }
.tree-depth-1 { padding-left: 2rem; }
.tree-depth-2 { padding-left: 3.2rem; }
.tree-depth-3 { padding-left: 4.4rem; }
.tree-depth-4 { padding-left: 5.6rem; }
.tree-depth-5 { padding-left: 6.8rem; }
.tree-depth-6 { padding-left: 8rem; }

.wf-arrow {
  width: 2px; height: 1.5rem;
  background: var(--line-strong);
  position: relative;
  flex: 0 0 auto;
}
.wf-arrow::after {
  content: "";
  position: absolute; bottom: 0; left: 50%;
  width: 8px; height: 8px;
  border-right: 2px solid var(--line-strong);
  border-bottom: 2px solid var(--line-strong);
  transform: translate(-50%, 2px) rotate(45deg);
}

/* ---------- BPM step editor (cards) ---------- */

.bpm-step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.bpm-step {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 1rem 1.1rem;
}
.bpm-step-summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  padding-bottom: .8rem; margin-bottom: .9rem;
  border-bottom: 1px solid var(--line);
  font-size: .92rem;
}
.bpm-step-summary strong {
  font-family: "Geist Mono", ui-monospace, monospace;
  background: var(--accent); color: #fff;
  padding: .12rem .5rem; border-radius: 999px; font-size: .78rem;
}
.bpm-step .admin-form { margin: 0; }
.step-actions { display: flex; gap: .4rem; margin-top: .8rem; }
.step-actions .btn-ghost { padding: .35rem .7rem; font-size: .82rem; }
