/* SwapLoop Admin (SSR) — low-fidelity wireframe stylesheet */
:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --muted: #555555;
  --line: #222222;
  --line-soft: #999999;
  --fill: #e8e8e8;
  --fill-strong: #d0d0d0;
  --focus: #000000;
  --shell-max: 1180px;
  --side: 14rem;
  --font: "Segoe UI", Arial, Helvetica, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

a {
  color: var(--ink);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Application shell ---------- */
.app-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.app-header__inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
}

.brand {
  font-size: 1.125rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.brand span {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.8125rem;
  margin-left: 0.3rem;
}

.user-chip {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line-soft);
  padding: 0.25rem 0.5rem;
}

.avatar {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--fill);
  flex: none;
}

.user-chip__text {
  display: grid;
  line-height: 1.2;
}

.user-chip__text strong {
  font-size: 0.875rem;
  font-weight: 700;
}

.user-chip__role {
  font-size: 0.6875rem;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.app-body {
  max-width: var(--shell-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--side) 1fr;
  align-items: start;
  background: var(--surface);
}

.app-sidebar {
  border-right: 1px solid var(--line);
  padding: 1rem 0.75rem 1.5rem;
  min-height: 32rem;
}

.side-nav {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.15rem;
}

.side-nav a {
  display: block;
  padding: 0.4rem 0.5rem;
  font-size: 0.875rem;
  text-decoration: none;
  border: 1px solid transparent;
}

.side-nav a:hover {
  border-color: var(--line-soft);
}

.side-nav a[aria-current="page"] {
  border-color: var(--line);
  background: var(--fill);
  font-weight: 700;
}

.side-note {
  margin: 0;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line-soft);
  font-size: 0.75rem;
  color: var(--muted);
}

.side-note strong {
  display: block;
  color: var(--ink);
  font-weight: 600;
}

.app-main {
  padding: 1.25rem 1.25rem 2.5rem;
  min-width: 0;
}

.app-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.app-footer__inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0.7rem 1rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

@media (max-width: 860px) {
  .app-body {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    min-height: 0;
  }

  .side-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }
}

/* ---------- Auth layout ---------- */
.auth-layout {
  max-width: 30rem;
  margin: 2.5rem auto;
  padding: 0 1rem 3rem;
}

.auth-layout .brand-block {
  margin-bottom: 1.5rem;
  text-align: center;
}

.auth-layout .brand-block .brand {
  display: block;
  font-size: 1.625rem;
  margin-bottom: 0.2rem;
}

.auth-layout .brand-block p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ---------- Typography ---------- */
h1 {
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
  font-weight: 700;
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
}

h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9375rem;
  font-weight: 700;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.page-header {
  margin-bottom: 1.1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.breadcrumbs {
  margin: 0 0 0.6rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.breadcrumbs a {
  text-decoration: underline;
}

.meta-line {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.region-label {
  display: block;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

/* ---------- Panels ---------- */
.panel {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 1rem;
  margin-bottom: 1rem;
}

.panel--flush {
  padding: 0;
  overflow-x: auto;
}

.panel--dashed {
  border-style: dashed;
  border-color: var(--line-soft);
  background: #fafafa;
}

.stack-gap {
  display: grid;
  gap: 1rem;
}

.two-col {
  display: grid;
  gap: 1rem;
}

@media (min-width: 900px) {
  .two-col--aside {
    grid-template-columns: 1fr 17rem;
    align-items: start;
  }
}

.wf-note {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px dashed var(--line-soft);
  background: #fafafa;
  font-size: 0.8125rem;
  color: var(--muted);
}

.wf-note strong {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Dashboard tiles ---------- */
.kpi-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  margin-bottom: 1rem;
}

.kpi {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0.75rem;
}

.kpi__value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
}

.kpi__label {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
}

.kpi__sub {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px dashed var(--line-soft);
  padding-top: 0.3rem;
}

.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.link-list a {
  display: block;
  border: 1px solid var(--line-soft);
  padding: 0.45rem 0.6rem;
  font-size: 0.875rem;
  text-decoration: none;
}

.link-list a:hover {
  border-color: var(--line);
  background: var(--fill);
}

.link-list span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---------- Forms ---------- */
.form-stack {
  display: grid;
  gap: 0.85rem;
}

.form-row {
  display: grid;
  gap: 0.85rem;
}

@media (min-width: 640px) {
  .form-row--2 {
    grid-template-columns: 1fr 1fr;
  }

  .form-row--3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.fieldset {
  border: 1px solid var(--line-soft);
  padding: 0.85rem;
  margin: 0;
  display: grid;
  gap: 0.85rem;
}

.fieldset legend {
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 0 0.35rem;
}

.field {
  display: grid;
  gap: 0.25rem;
}

.field label {
  font-size: 0.875rem;
  font-weight: 600;
}

.field .hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.field .error {
  font-size: 0.75rem;
  font-weight: 600;
  border-left: 3px solid var(--ink);
  padding-left: 0.4rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--line);
  background: var(--surface);
  font: inherit;
  font-size: 0.875rem;
  border-radius: 0;
}

.field textarea {
  min-height: 4.5rem;
  resize: vertical;
}

.field input[aria-invalid="true"],
.field select[aria-invalid="true"],
.field textarea[aria-invalid="true"] {
  border-width: 2px;
  background: var(--fill);
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  background: var(--fill);
  color: var(--muted);
}

.check-list {
  display: grid;
  gap: 0.3rem;
  border: 1px solid var(--line);
  padding: 0.5rem;
  max-height: 9rem;
  overflow-y: auto;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.4rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line-soft);
}

.required-mark {
  font-weight: 400;
  color: var(--muted);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border-radius: 0;
}

.btn--primary {
  background: var(--ink);
  color: var(--surface);
}

.btn--small {
  padding: 0.25rem 0.55rem;
  font-size: 0.8125rem;
}

.btn--ghost {
  border-style: dashed;
  color: var(--muted);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.link-muted {
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---------- Status / feedback ---------- */
.alert {
  border: 1px solid var(--line);
  padding: 0.65rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  background: var(--surface);
}

.alert--error {
  border-width: 2px;
}

.alert--success {
  background: var(--fill);
}

.alert--warning {
  border-style: dashed;
}

.alert h2 {
  font-size: 0.9375rem;
  margin-bottom: 0.3rem;
}

.alert ul {
  margin: 0.3rem 0 0;
  padding-left: 1.1rem;
}

.status-badge {
  display: inline-block;
  border: 1px solid var(--line);
  padding: 0.05rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--surface);
  white-space: nowrap;
}

.status-badge--muted {
  background: var(--fill);
}

.status-badge--end {
  background: var(--fill-strong);
  border-style: dashed;
}

.status-badge--planned {
  border-style: dashed;
}

.role-tag {
  display: inline-block;
  border: 1px solid var(--line-soft);
  padding: 0.05rem 0.35rem;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ---------- Toolbar / filters ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.toolbar .field {
  min-width: 9rem;
  flex: 1 1 9rem;
}

.toolbar .toolbar__actions {
  display: flex;
  gap: 0.5rem;
}

.filter-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.filter-chip {
  border: 1px solid var(--line-soft);
  padding: 0.05rem 0.4rem;
  color: var(--ink);
}

/* ---------- Tables ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--surface);
}

.data-table th,
.data-table td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.55rem;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: var(--fill);
  font-weight: 700;
  white-space: nowrap;
}

.data-table tfoot td,
.data-table tfoot th {
  background: var(--fill);
  font-weight: 700;
}

.data-table .num {
  text-align: right;
  white-space: nowrap;
}

.data-table a {
  font-weight: 600;
}

.row-actions {
  white-space: nowrap;
  font-size: 0.8125rem;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

.pagination .page-info {
  color: var(--muted);
  margin-right: auto;
}

.empty-state {
  border: 1px dashed var(--line);
  padding: 2.25rem 1rem;
  text-align: center;
  background: var(--surface);
}

.empty-state h2 {
  margin-bottom: 0.4rem;
}

.empty-state p {
  margin: 0 auto 1rem;
  max-width: 30rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ---------- Definition / summary lists ---------- */
.summary-list {
  margin: 0;
  padding: 0;
}

.summary-list div {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.875rem;
}

.summary-list dt {
  color: var(--muted);
  font-weight: 600;
  margin: 0;
}

.summary-list dd {
  margin: 0;
}

.detail-grid {
  display: grid;
  gap: 0.75rem 1.25rem;
  margin: 0;
}

@media (min-width: 640px) {
  .detail-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.detail-grid dt {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}

.detail-grid dd {
  margin: 0.1rem 0 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.total-box {
  border: 2px solid var(--line);
  padding: 0.75rem 1rem;
  background: var(--fill);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.total-box .total-label {
  font-size: 0.875rem;
  font-weight: 600;
}

.total-box .total-value {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ---------- Bar chart (drawn without a chart library) ---------- */
.bar-chart {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  column-gap: 0.5rem;
}

.bar-chart__y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 14rem;
  text-align: right;
  font-size: 0.6875rem;
  color: var(--muted);
}

.bar-chart__plot {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 1rem;
  align-items: end;
  height: 14rem;
  padding: 0 1rem;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.bar-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
}

.bar-col__value {
  font-size: 0.6875rem;
  margin-bottom: 0.2rem;
  white-space: nowrap;
}

.bar-col__fill {
  width: 100%;
  max-width: 4rem;
  height: var(--h);
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--fill-strong);
}

.bar-chart__x {
  grid-column: 2;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 1rem;
  margin: 0.35rem 0 0;
  padding: 0 1rem;
  list-style: none;
  font-size: 0.75rem;
  text-align: center;
}

.chart-caption {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---------- Media placeholder ---------- */
.media-placeholder {
  border: 1px solid var(--line);
  background:
    linear-gradient(to top right, transparent calc(50% - 0.5px), var(--line-soft) calc(50% - 0.5px), var(--line-soft) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    linear-gradient(to top left, transparent calc(50% - 0.5px), var(--line-soft) calc(50% - 0.5px), var(--line-soft) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    var(--fill);
  display: grid;
  place-items: center;
  min-height: 7rem;
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: center;
  padding: 0.5rem;
}

.icon-box {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border: 1px solid var(--line);
  vertical-align: -0.05rem;
  margin-right: 0.3rem;
}
