/* Console-specific classes on top of the Organic system (adapted from the
   AppConsole template of the design project). */

.shell { display: flex; gap: 16px; padding: 16px; min-height: 100vh; }

/* Layout grids live here rather than inline so media queries can restack them. */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.split-grid {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 16px; align-items: start;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.project-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.project-stats { margin-left: auto; display: flex; gap: 22px; text-align: right; }
.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(22px, 2.2vw, 34px); }
.page-crumb {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--color-accent-700);
}
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar { display: none; }
.scrim { display: none; }
.sidebar-toggle { display: none; }

.sidebar {
  width: 220px; flex: none; display: flex; flex-direction: column; gap: 16px;
  padding: 16px 14px; border-radius: 30px; background: var(--color-surface);
  align-self: flex-start; position: sticky; top: 16px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.sidebar-mark {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  background: var(--color-accent); color: var(--color-bg);
  display: grid; place-items: center; font-family: var(--font-heading); font-size: 16px;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px; padding: 12px 6px 0;
  border-top: 1px solid var(--color-divider); font-size: 12px; line-height: 1.3;
}

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

.ac-nav {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 999px; font-size: 14px; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: var(--color-text);
  font-family: var(--font-body); text-align: left; width: 100%; text-decoration: none;
}
.ac-nav:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); color: var(--color-text); }
.ac-nav[aria-current="page"] { background: var(--color-accent); color: var(--color-bg); }

.ac-ico {
  background: var(--color-accent-200); color: var(--color-accent-800);
  display: grid; place-items: center; font-family: var(--font-heading); overflow: hidden;
}
.ac-ico img { width: 100%; height: 100%; object-fit: cover; }

.ac-sw {
  width: 52px; height: 30px; flex: none; border: 1px solid var(--color-divider);
  border-radius: 999px; cursor: pointer; padding: 3px; display: flex;
  justify-content: flex-start; background: var(--color-neutral-200);
}
.ac-sw > span {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--color-neutral-400); box-shadow: var(--shadow-sm);
}
.ac-sw.on { justify-content: flex-end; background: var(--color-accent); }
.ac-sw.on > span { background: var(--color-bg); }
.ac-sw:disabled { cursor: not-allowed; opacity: 0.55; }

/* .table th sets text-align:left and outranks a bare .ac-num, so numeric
   headers need the same specificity to line up with their values. */
.ac-num, .table th.ac-num { font-variant-numeric: tabular-nums; text-align: right; }
/* Uppercase labels carry a trailing letter-space; pull it back so their right
   edge matches the number underneath. */
.ac-stat-label { margin-right: -.08em; }
.ac-grp td { background: var(--color-neutral-200); font-family: var(--font-heading); font-size: 14px; }
.ac-row-name { display: flex; align-items: center; gap: 10px; }
.ac-scroll { min-width: 0; max-width: 100%; overflow-x: auto; }
.ac-scroll > table { min-width: 700px; }

.ac-tab {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--color-divider);
  background: transparent; font-family: var(--font-body); font-size: 13px;
  color: var(--color-text); cursor: pointer;
}
.ac-tab:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.ac-tab.on { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-bg); }

.ac-yes { color: var(--color-accent-2-700); font-family: var(--font-heading); }
.ac-no { opacity: 0.35; }

.ac-av {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  background: var(--color-accent-2-200); color: var(--color-accent-2-800);
  display: grid; place-items: center; font-family: var(--font-heading); font-size: 13px;
}

/* auth pages */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(400px, 100%); padding: 32px 28px; gap: 14px; }

/* misc */
.form-error {
  font-size: 13px; color: var(--color-accent-700);
  background: var(--color-accent-100); padding: 8px 14px; border-radius: 999px;
}
.saved-note { font-size: 12px; color: var(--color-accent-2-700); }
#dialog-root:empty { display: none; }
.htmx-request.ac-sw { opacity: 0.6; pointer-events: none; }

/* ── Responsive ─────────────────────────────────────────────────────────
   Below 900px the two-column layouts stack; below 860px the sidebar leaves
   the flow and becomes a drawer that slides in from the left. */

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .split-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  /* The colour legend just repeats the Role column; drop it on phones. */
  .period-legend { display: none; }
}

@media (max-width: 860px) {
  .topbar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 30;
    padding: 8px 12px; background: var(--color-surface);
    border-bottom: 1px solid var(--color-divider);
  }
  .sidebar-toggle {
    display: grid; place-items: center;
    width: 36px; height: 36px; flex: none; padding: 0; cursor: pointer;
    border: 1px solid var(--color-divider); border-radius: 999px;
    background: transparent; color: var(--color-text);
  }
  .sidebar-toggle:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
  .sidebar-toggle span,
  .sidebar-toggle span::before,
  .sidebar-toggle span::after {
    display: block; width: 16px; height: 2px; border-radius: 2px;
    background: currentColor; content: "";
  }
  .sidebar-toggle span { position: relative; }
  .sidebar-toggle span::before { position: absolute; top: -5px; }
  .sidebar-toggle span::after { position: absolute; top: 5px; }

  .shell { flex-direction: column; gap: 10px; padding: 10px; }
  .sidebar {
    position: fixed; top: 0; left: 0; width: 250px; z-index: 50;
    /* height, not top+bottom: dvh follows the mobile URL bar as it hides. */
    height: 100vh; height: 100dvh;
    border-radius: 0 26px 26px 0; padding: 18px 14px;
    overflow-y: auto; overscroll-behavior: contain;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .sidebar.open { transform: none; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: color-mix(in srgb, var(--color-neutral-900) 45%, transparent);
    opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .scrim.on { opacity: 1; pointer-events: auto; }
  body.menu-open { overflow: hidden; }

  .main { gap: 10px; }
  .page-head { align-items: flex-start; gap: 10px; }
  .page-actions { width: 100%; }
  .page-actions .input { flex: 1; min-width: 140px; width: auto; }
  .ac-scroll > table { min-width: 600px; }
  .table th, .table td { padding: 7px var(--space-2); }
  .card, section.card { padding: 14px 14px !important; gap: 10px !important; }
  .project-stats { margin-left: 0; gap: 16px; text-align: left; width: 100%; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  /* Compact stat tiles: the kicker and the number carry the meaning,
     the caption underneath is what made them twice as tall. */
  .stat-grid .card { padding: 10px 12px !important; gap: 2px !important; }
  .stat-grid .card > div:nth-child(2) { font-size: 22px !important; }
  .stat-grid .card .text-muted { display: none; }
  .page-actions .input { flex: 1 0 100%; }
  .page-actions .btn { flex: 1; white-space: nowrap; }
  .auth-card { padding: 24px 20px; }
}
