/* ==========================================================================
   Atto — From Requirements to Go-Live
   Brand colours sampled from the logo: blue #1070fd → purple #6924bc.
   ========================================================================== */

:root {
  /* brand */
  --brand:        #6d28d9;
  --brand-600:    #5b21b6;
  --brand-400:    #8b5cf6;
  --brand-100:    #ede9fe;
  --brand-50:     #f5f3ff;
  --brand-blue:   #1070fd;
  --gradient:     linear-gradient(135deg, #1070fd 0%, #6924bc 60%, #7c3aed 100%);
  --gradient-soft:linear-gradient(135deg, #f5f3ff 0%, #eef2ff 50%, #fdf4ff 100%);

  /* surfaces */
  --bg:        #f6f7fb;
  --surface:   #ffffff;
  --border:    #e6e8f0;
  --border-2:  #d9dced;

  /* ink */
  --text:   #1a1d29;
  --muted:  #6b7280;
  --faint:  #9ca3af;

  /* status — always paired with an icon and a label, never colour alone */
  --ok:    #0ca30c;
  --ok-bg: #e8f7e8;
  --warn:    #b45309;
  --warn-bg: #fef3c7;
  --bad:     #d03b3b;
  --bad-bg:  #fdeaea;
  --info:    #1070fd;
  --info-bg: #e7f0ff;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 2px rgba(26,29,41,.04), 0 4px 16px rgba(26,29,41,.06);
  --shadow-lg: 0 8px 32px rgba(105,36,188,.12);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

/* ==========================================================================
   App shell — sidebar + main
   ========================================================================== */

/* The sidebar is sticky and one viewport tall, so on a long page its own
   background would stop at the fold. The column is painted here instead, which
   keeps the white panel and its divider running the full height of the page. */
.app {
  display: flex;
  min-height: 100vh;
  background: linear-gradient(90deg,
    var(--surface) 0 calc(var(--sidebar-w) - 1px),
    var(--border)  calc(var(--sidebar-w) - 1px) var(--sidebar-w),
    var(--bg)      var(--sidebar-w));
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

/* align-items must be set: this is a column flexbox, so the default `stretch`
   pulls the logo to the full sidebar width while its height stays fixed, and
   `width: auto` on a flex item means "stretch", not "keep my aspect ratio". */
.brand {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: .15rem; padding: .25rem .5rem 1.4rem;
}
.brand img { height: 34px; width: auto; flex: none; }
.brand .tagline { font-size: .7rem; color: var(--faint); letter-spacing: .01em; }
a.brand:hover { text-decoration: none; }

.nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .62rem .7rem; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; font-size: .92rem;
}
.nav a:hover { background: var(--brand-50); color: var(--brand); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--brand-100); color: var(--brand-600); font-weight: 600; }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav { display: flex; flex-direction: column; gap: .15rem; }
.sidebar .spacer { flex: 1; }
.sidebar-foot { padding: .5rem; border-top: 1px solid var(--border); }
.sidebar-foot button { width: 100%; justify-content: center; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* top bar */
.appbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1.6rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.appbar .search { flex: 1; max-width: 460px; position: relative; }
.appbar .search input {
  width: 100%; padding-left: 2.3rem; border-radius: 999px; background: var(--bg);
}
.appbar .search svg {
  position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--faint);
}
.appbar .spacer { flex: 1; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--gradient); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none;
}
.whoami { display: flex; align-items: center; gap: .65rem; }
.whoami .name { font-weight: 600; font-size: .88rem; line-height: 1.2; }
.whoami .role { font-size: .76rem; color: var(--muted); text-transform: capitalize; }

.content { padding: 1.6rem; width: 100%; max-width: 1400px; }

/* ==========================================================================
   Page header
   ========================================================================== */

.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; margin-bottom: 1.4rem; }
.page-head .titles { flex: 1 1 320px; min-width: 0; }
.page-head h1 {
  font-size: 1.6rem; margin: 0; letter-spacing: -.02em;
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
}
.page-head .sub { color: var(--muted); font-size: .88rem; margin-top: .3rem; }
.page-head .actions { display: flex; gap: .55rem; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.back-link:hover { color: var(--brand); text-decoration: none; }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow);
  /* A wide table scrolls inside its own card. Without this it widens the whole
     document, and every full-width band above it stops short of the screen. */
  overflow-x: auto;
}
.card h3 { font-size: 1rem; margin: 0 0 .9rem; display: flex; align-items: center; gap: .5rem; }
.card h3 svg { width: 19px; height: 19px; color: var(--brand); }

h2 { font-size: 1.15rem; margin: 1.9rem 0 .8rem; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; }

/* ==========================================================================
   Hero — go-live readiness
   ========================================================================== */

.hero {
  background: var(--gradient-soft);
  border: 1px solid var(--brand-100);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.4rem;
  box-shadow: var(--shadow);
}
.hero-top { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; margin-bottom: 1.3rem; }
.hero-top .titles { flex: 1 1 220px; min-width: 0; }
.hero-icon {
  width: 52px; height: 52px; border-radius: 14px; flex: none;
  background: var(--gradient); color: #fff; display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
}
.hero-icon svg { width: 26px; height: 26px; }
.hero h2 { margin: 0; font-size: 1.35rem; letter-spacing: -.02em; }
.hero .lede { color: var(--muted); font-size: .9rem; margin-top: .2rem; }
.hero .countdown {
  margin-left: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem .9rem; text-align: right; flex: none;
}
.hero .countdown .big { font-weight: 700; font-size: 1rem; }
.hero .countdown .small { font-size: .75rem; color: var(--muted); }

/* stat tiles — icon + label + value, so colour is never the only signal */
.tiles { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--c, var(--brand));
  border-radius: var(--radius-sm); padding: .95rem 1.05rem;
  display: flex; align-items: center; gap: .85rem;
}
.tile .ico {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: grid; place-items: center; background: var(--cbg, var(--brand-100)); color: var(--c, var(--brand));
}
.tile .ico svg { width: 19px; height: 19px; }
.tile .label { font-size: .78rem; color: var(--muted); font-weight: 500; line-height: 1.25; }
.tile .value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.tile.is-info { --c: var(--info); --cbg: var(--info-bg); }
.tile.is-ok   { --c: var(--ok);   --cbg: var(--ok-bg); }
.tile.is-warn { --c: var(--warn); --cbg: var(--warn-bg); }
.tile.is-bad  { --c: var(--bad);  --cbg: var(--bad-bg); }

/* progress meter */
.meter { height: 9px; background: #e8eaf2; border-radius: 999px; overflow: hidden; display: flex; margin-top: 1.2rem; }
.meter span { display: block; height: 100%; }
.meter .done { background: var(--ok); }
.meter .failing { background: var(--bad); }
.meter-legend { display: flex; gap: 1.2rem; font-size: .8rem; color: var(--muted); margin-top: .55rem; flex-wrap: wrap; }
.meter-legend i { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .38rem; }

.gate .verdict { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
.gate.ready .verdict { color: var(--ok); }
.gate.blocked .verdict { color: var(--warn); }
.blockers { margin: .5rem 0 0; padding-left: 1.15rem; color: var(--muted); font-size: .9rem; }
.blockers li { margin-bottom: .25rem; }

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin-bottom: 1.3rem; flex-wrap: wrap; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  padding: .75rem 1rem; color: var(--muted); font-weight: 600; font-size: .92rem;
  display: flex; align-items: center; gap: .45rem; box-shadow: none;
}
.tabs button:hover { background: none; color: var(--text); }
.tabs button svg { width: 17px; height: 17px; }
.tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .count {
  font-variant-numeric: tabular-nums; font-size: .78rem; font-weight: 600;
  background: var(--bg); color: var(--muted); border-radius: 999px; padding: .05rem .45rem;
}
.tabs button[aria-selected="true"] .count { background: var(--brand-100); color: var(--brand-600); }

/* ==========================================================================
   Forms
   ========================================================================== */

label { display: block; margin: 0 0 .32rem; font-size: .82rem; font-weight: 500; color: var(--text); }
label .muted { font-weight: 400; }

input, select, textarea {
  width: 100%; padding: .6rem .75rem; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(139,92,246,.18);
}
textarea { min-height: 5rem; resize: vertical; }

button {
  padding: .6rem 1.1rem; font: inherit; font-weight: 600; font-size: .9rem;
  color: #fff; background: var(--brand); border: 1px solid transparent;
  border-radius: var(--radius-sm); cursor: pointer;
  display: inline-flex; align-items: center; gap: .45rem;
  transition: background .12s, transform .06s;
}
button:hover:not(:disabled) { background: var(--brand-600); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button svg { width: 16px; height: 16px; }
button.secondary { color: var(--text); background: var(--surface); border-color: var(--border-2); }
button.secondary:hover:not(:disabled) { background: var(--bg); }
button.ghost { color: var(--muted); background: none; border-color: transparent; }
button.ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
button.small { padding: .32rem .62rem; font-size: .8rem; }
button.danger { background: var(--bad); }
button.danger:hover:not(:disabled) { background: #b32f2f; }

.row { display: flex; flex-wrap: wrap; gap: .85rem; align-items: flex-end; }
.row > * { flex: 1 1 180px; min-width: 0; }
.row > .shrink { flex: 0 0 auto; }

.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.1rem; }

/* ==========================================================================
   Tables
   ========================================================================== */

table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th, td { padding: .68rem .75rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  background: var(--bg); font-weight: 600; font-size: .78rem; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
}
thead th:first-child { border-top-left-radius: var(--radius-sm); }
thead th:last-child  { border-top-right-radius: var(--radius-sm); }
tbody tr:hover { background: var(--brand-50); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.ref { font-family: ui-monospace, Consolas, monospace; font-size: .84rem; white-space: nowrap; color: var(--brand-600); font-weight: 600; }

/* ==========================================================================
   Tags, notices, misc
   ========================================================================== */

.tag {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .16rem .55rem; font-size: .74rem; font-weight: 600;
  border-radius: 999px; white-space: nowrap;
}
.tag::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; }
/* A tag whose text has not arrived yet would otherwise show as a lone dot. */
.tag:empty { display: none; }
.tag.grey   { color: var(--muted);  background: #eef0f5; }
.tag.blue   { color: #0a4a99;       background: var(--info-bg); }
.tag.violet { color: var(--brand-600); background: var(--brand-100); }
.tag.green  { color: #0b7a0b;       background: var(--ok-bg); }
.tag.amber  { color: var(--warn);   background: var(--warn-bg); }
.tag.red    { color: var(--bad);    background: var(--bad-bg); }

.notice { padding: .75rem .95rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .9rem; display: none; }
.notice.show { display: block; }
.notice[hidden] { display: none; }
.notice.error { color: var(--bad); background: var(--bad-bg); border: 1px solid #f6d5d5; }
.notice.ok    { color: #0b7a0b;    background: var(--ok-bg);  border: 1px solid #cfead0; }

.muted { color: var(--muted); }
.empty { padding: 2.2rem 1rem; text-align: center; color: var(--faint); font-size: .9rem; }

.stat-row { display: flex; flex-wrap: wrap; gap: 1.4rem; }
.stat { flex: 1 1 130px; }
.stat .label { font-size: .78rem; color: var(--muted); }
.stat .value { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; }

dialog {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; min-width: min(540px, 92vw); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(26,29,41,.45); backdrop-filter: blur(2px); }

/* ==========================================================================
   Auth pages — centred card on the brand gradient
   ========================================================================== */

.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem;
  background: var(--gradient);
  position: relative; overflow: hidden;
}
/* soft light blooms so the purple doesn't read as a flat slab */
.auth::before, .auth::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
}
.auth::before { width: 620px; height: 620px; top: -220px; right: -160px;
  background: radial-gradient(circle, rgba(255,255,255,.22), transparent 68%); }
.auth::after  { width: 520px; height: 520px; bottom: -200px; left: -140px;
  background: radial-gradient(circle, rgba(16,112,253,.35), transparent 66%); }

.auth-card {
  position: relative; z-index: 1;
  width: min(420px, 100%);
  background: var(--surface); border-radius: 18px; padding: 2.1rem;
  box-shadow: 0 24px 60px rgba(26,29,41,.28);
}
.auth-card .brand { align-items: center; padding: 0 0 1.5rem; text-align: center; }
.auth-card .brand img { height: 40px; margin: 0 auto; }
.auth-card .brand .tagline { text-align: center; }
.auth-card h1 { font-size: 1.3rem; margin: 0 0 .3rem; letter-spacing: -.02em; }
.auth-card .lede { color: var(--muted); font-size: .88rem; margin: 0 0 1.4rem; }
.auth-card button[type="submit"] { width: 100%; justify-content: center; margin-top: 1.1rem; padding: .7rem; }
.auth-card .field + .field { margin-top: .85rem; }
.links { margin-top: 1.3rem; font-size: .88rem; text-align: center; color: var(--muted); }
.links p { margin: .4rem 0; }
.fineprint { font-size: .8rem; color: var(--muted); margin-top: 1.1rem; line-height: 1.5; }

/* ==========================================================================
   Portal (customer view)
   ========================================================================== */

.portal-head {
  background: var(--gradient); color: #fff; padding: 1.5rem 1.6rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.portal-head img { height: 30px; width: auto; flex: none; }
.portal-head .who { color: rgba(255,255,255,.82); font-size: .85rem; }
.portal-head h1 { margin: 0; font-size: 1.2rem; }
.portal-head .spacer { flex: 1; }
.portal-head button { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.28); color: #fff; }
.portal-head button:hover { background: rgba(255,255,255,.26); }

.project-card { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.project-card:hover { border-color: var(--brand-400); box-shadow: var(--shadow-lg); }
.project-card[aria-selected="true"] { border-color: var(--brand); box-shadow: var(--shadow-lg); }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  /* The sidebar becomes a full-width strip, so the painted column is dropped. */
  .app { flex-direction: column; background: var(--bg); }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; align-items: center; gap: .3rem; overflow-x: auto;
    padding: .7rem .9rem;
  }
  .brand { padding: 0 .8rem 0 .2rem; flex-direction: row; align-items: center; gap: .5rem; }
  .brand .tagline { display: none; }
  .nav { flex-direction: row; gap: .2rem; }
  .nav a span { display: none; }
  .nav a { padding: .55rem; }
  .sidebar .spacer { flex: 1; }
  .sidebar-foot { border-top: none; padding: 0; }
  .sidebar-foot button { width: auto; white-space: nowrap; }
  .content { padding: 1rem; }
  .appbar { padding: .7rem 1rem; }
  .appbar .search { display: none; }
}

@media (max-width: 640px) {
  table { font-size: .82rem; }
  th, td { padding: .5rem .45rem; }
  /* Scroll the table sideways rather than crushing cells to one word per line. */
  .card table { min-width: 560px; }
  /* On the narrow nav strip the sign-out label is dropped, not truncated.
     font-size:0 hides it visually while leaving the accessible name intact. */
  .sidebar-foot button { font-size: 0; padding: .55rem; }
  .sidebar-foot button svg { width: 18px; height: 18px; }
  .hero { padding: 1.1rem; }
  .hero .countdown { margin-left: 0; }
}
