/* ==========================================================================
   Estilos de la aplicación — AI Social Media Manager (prototipo)
   ========================================================================== */

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
p,
figure {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

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

.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -60px;
  z-index: 100;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: var(--focus-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: top var(--motion-fast) var(--ease);
}

.skip-link:focus {
  top: var(--sp-4);
}

/* -------------------------------------------------------------- shell --- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-3);
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-4);
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--brand-600);
  color: #fff;
  font-weight: 700;
  font-size: var(--text-sm);
}

.brand__name {
  font-weight: 600;
  font-size: var(--text-base);
  line-height: var(--leading-tight);
}

.brand__sub {
  font-size: var(--text-xs);
  color: var(--subtle);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: var(--sp-2);
}

.nav-group__label {
  padding: var(--sp-2) var(--sp-3) var(--sp-1);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--subtle);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: var(--text-base);
  text-decoration: none;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
}

.nav-item[aria-current="page"] {
  background: var(--brand-50);
  color: var(--brand-900);
  font-weight: 600;
}

.nav-item__icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
}

.nav-item__count {
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--brand-600);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.nav-item--muted {
  color: var(--subtle);
}

.sidebar__footer {
  margin-top: auto;
  padding: var(--sp-3);
  border-top: 1px solid var(--line);
  font-size: var(--text-xs);
  color: var(--subtle);
}

/* ------------------------------------------------------------- topbar --- */
.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--topbar-h);
  padding: 0 var(--sp-6);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar__menu {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: var(--sp-1) var(--sp-2);
}

.brand-picker {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: var(--text-sm);
  font-weight: 500;
}

.brand-picker__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-500);
}

.topbar__spacer {
  flex: 1;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--muted);
}

.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-100);
  color: var(--brand-900);
  font-size: var(--text-xs);
  font-weight: 700;
}

/* ---------------------------------------------------------- demo bar --- */
.demo-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-6);
  background: var(--data-demo-bg);
  border-bottom: 1px solid #f2d98a;
  color: var(--data-demo);
  font-size: var(--text-xs);
  font-weight: 500;
}

.demo-bar strong {
  font-weight: 700;
}

.demo-bar__states {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  margin-left: auto;
}

.chip {
  border: 1px solid rgba(146, 64, 14, 0.35);
  background: transparent;
  color: var(--data-demo);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
}

.chip[aria-pressed="true"] {
  background: var(--data-demo);
  border-color: var(--data-demo);
  color: #fff;
}

/* ------------------------------------------------------------- content --- */
.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-6);
  padding-bottom: var(--sp-16);
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}

.page-head__text {
  flex: 1 1 320px;
  min-width: 0;
}

.page-head h1 {
  font-size: var(--text-xl);
  line-height: var(--leading-tight);
  font-weight: 600;
}

.page-head p {
  margin-top: var(--sp-1);
  color: var(--muted);
  font-size: var(--text-base);
  max-width: 72ch;
}

.page-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.section {
  margin-bottom: var(--sp-8);
}

.section__head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.section__head h2 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.section__head p {
  color: var(--subtle);
  font-size: var(--text-sm);
}

/* -------------------------------------------------------------- grids --- */
.grid {
  display: grid;
  gap: var(--sp-4);
}

.grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid--sidebar {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  align-items: start;
}

/* -------------------------------------------------------------- cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
}

.card--flat {
  box-shadow: none;
}

.card__head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.card__title {
  font-size: var(--text-base);
  font-weight: 600;
}

.card__sub {
  font-size: var(--text-xs);
  color: var(--subtle);
}

.card__actions {
  margin-left: auto;
  display: flex;
  gap: var(--sp-1);
}

.card--interactive:hover {
  border-color: var(--brand-500);
  box-shadow: var(--shadow-sm);
}

/* métrica */
.metric__label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--subtle);
}

.metric__value {
  margin-top: var(--sp-2);
  font-size: var(--text-3xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.metric__value--md {
  font-size: var(--text-2xl);
}

.metric__delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--sp-1);
  font-size: var(--text-sm);
  font-weight: 500;
}

.metric__delta--up {
  color: var(--success-700);
}

.metric__delta--down {
  color: var(--danger-700);
}

.metric__foot {
  margin-top: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--subtle);
}

/* ------------------------------------------------------------ buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.4;
  transition: background var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn--primary {
  background: var(--brand-600);
  color: #fff;
}

.btn--primary:hover {
  background: var(--brand-700);
}

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

.btn--secondary:hover {
  background: var(--surface-2);
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
}

.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn--danger {
  background: var(--danger-700);
  color: #fff;
}

.btn--danger:hover {
  background: #8f1c13;
}

.btn--sm {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-sm);
}

.btn--block {
  width: 100%;
}

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

.btn__spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------- badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.badge--neutral {
  background: var(--surface-2);
  color: var(--muted);
}

.badge--success {
  background: var(--success-50);
  color: var(--success-700);
}

.badge--warning {
  background: var(--warning-50);
  color: var(--warning-700);
}

.badge--danger {
  background: var(--danger-50);
  color: var(--danger-700);
}

.badge--info {
  background: var(--info-50);
  color: var(--info-700);
}

.badge--brand {
  background: var(--brand-50);
  color: var(--brand-900);
}

.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Procedencia del dato */
.prov {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.prov--real {
  background: var(--surface-2);
  color: var(--data-real);
}

.prov--demo {
  background: var(--data-demo-bg);
  color: var(--data-demo);
}

.prov--est {
  background: var(--data-est-bg);
  color: var(--data-est);
}

.prov--na {
  background: var(--data-na-bg);
  color: var(--data-na);
}

/* -------------------------------------------------------------- tables --- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

th,
td {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

th {
  background: var(--surface-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--subtle);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #fbfcfe;
}

.table__title {
  font-weight: 600;
  color: var(--ink);
}

.table__sub {
  font-size: var(--text-xs);
  color: var(--subtle);
}

.table__actions {
  display: flex;
  gap: var(--sp-1);
  justify-content: flex-end;
}

.numeric {
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- forms --- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
}

.field__label {
  font-size: var(--text-sm);
  font-weight: 600;
}

.field__help {
  font-size: var(--text-xs);
  color: var(--subtle);
}

.field__error {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--danger-700);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--ink);
  transition: border-color var(--motion-fast) var(--ease);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--subtle);
}

.input[aria-invalid="true"] {
  border-color: var(--danger-700);
  background: #fffafa;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
}

.search {
  position: relative;
  max-width: 340px;
  width: 100%;
}

.search .input {
  padding-left: var(--sp-8);
}

.search__icon {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--subtle);
  pointer-events: none;
}

/* ---------------------------------------------------------------- tabs --- */
.tabs {
  display: flex;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--sp-4);
}

.tab {
  padding: var(--sp-2) var(--sp-3);
  border: none;
  background: none;
  color: var(--muted);
  font-size: var(--text-base);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab[aria-selected="true"] {
  color: var(--brand-900);
  border-bottom-color: var(--brand-600);
  font-weight: 600;
}

.tab__count {
  margin-left: 6px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
}

/* -------------------------------------------------------------- alerts --- */
.alert {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  margin-bottom: var(--sp-4);
}

.alert__icon {
  flex: none;
  font-weight: 700;
}

.alert__body {
  flex: 1;
  min-width: 0;
}

.alert__title {
  font-weight: 600;
  margin-bottom: 2px;
}

.alert--info {
  background: var(--info-50);
  border-color: #b8e2ec;
  color: #0b4f60;
}

.alert--warning {
  background: var(--warning-50);
  border-color: #f2d98a;
  color: #78350f;
}

.alert--danger {
  background: var(--danger-50);
  border-color: #f4b8b3;
  color: #7f1d1d;
}

.alert--success {
  background: var(--success-50);
  border-color: #a7dcc1;
  color: #0b4f3a;
}

/* --------------------------------------------------------------- empty --- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.empty__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: var(--text-lg);
}

.empty__title {
  font-size: var(--text-md);
  font-weight: 600;
}

.empty__text {
  max-width: 46ch;
  color: var(--muted);
  font-size: var(--text-sm);
}

.empty--error {
  border-style: solid;
  border-color: #f4b8b3;
  background: #fffafa;
}

/* ------------------------------------------------------------ skeleton --- */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, #e9eef6 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

.skeleton--line {
  height: 12px;
  margin-bottom: var(--sp-2);
}

.skeleton--title {
  height: 20px;
  width: 40%;
  margin-bottom: var(--sp-3);
}

.skeleton--block {
  height: 88px;
}

@keyframes shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* ------------------------------------------------------------- timeline --- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding-left: var(--sp-4);
  border-left: 2px solid var(--line);
}

.timeline__item {
  position: relative;
  padding-left: var(--sp-2);
}

.timeline__item::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--sp-4) - 5px);
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-600);
  border: 2px solid var(--surface);
}

.timeline__time {
  font-size: var(--text-xs);
  color: var(--subtle);
}

.timeline__text {
  font-size: var(--text-sm);
}

/* --------------------------------------------------------------- steps --- */
.steps {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}

.step {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: var(--text-sm);
  color: var(--muted);
}

.step--current {
  border-color: var(--brand-600);
  background: var(--brand-50);
  color: var(--brand-900);
  font-weight: 600;
}

.step__num {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
}

.step--current .step__num {
  background: var(--brand-600);
  color: #fff;
}

/* --------------------------------------------------------------- panel --- */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
}

.drawer[open],
.drawer.is-open {
  display: block;
}

.drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
}

.drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(520px, 100%);
  height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slide-in var(--motion-base) var(--ease);
}

@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.drawer__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--line);
}

.drawer__title {
  font-size: var(--text-md);
  font-weight: 600;
}

.drawer__body {
  padding: var(--sp-4);
  overflow-y: auto;
  flex: 1;
}

.drawer__foot {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  padding: var(--sp-4);
  border-top: 1px solid var(--line);
}

/* --------------------------------------------------------------- modal --- */
#modal-host[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal__panel {
  position: relative;
  width: min(460px, 100%);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6);
  animation: toast-in var(--motion-base) var(--ease);
}

.modal__title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}

.modal__text {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--sp-6);
}

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
}

.field__req {
  color: var(--danger-700);
  font-weight: 700;
}

.btn--link {
  padding: 0;
  background: none;
  color: var(--brand-600);
  text-decoration: underline;
  font-weight: 500;
}

.calendar__event--programmed {
  background: var(--info-50);
  color: var(--info-700);
}

/* --------------------------------------------------------------- toast --- */
.toasts {
  position: fixed;
  right: var(--sp-4);
  bottom: var(--sp-4);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: 380px;
}

.toast {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  animation: toast-in var(--motion-base) var(--ease);
}

.toast--success {
  background: #0b4f3a;
}

.toast--danger {
  background: #7f1d1d;
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* -------------------------------------------------------------- charts --- */
.bars {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  height: 140px;
  padding-top: var(--sp-3);
}

.bars__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  height: 100%;
}

.bars__bar {
  background: var(--brand-500);
  border-radius: 3px 3px 0 0;
  min-height: 4px;
}

.bars__bar--muted {
  background: var(--brand-100);
}

.bars__label {
  font-size: 10px;
  color: var(--subtle);
  text-align: center;
}

.legend {
  display: flex;
  gap: var(--sp-4);
  margin-top: var(--sp-3);
  font-size: var(--text-xs);
  color: var(--muted);
  flex-wrap: wrap;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--brand-500);
}

.legend__swatch--muted {
  background: var(--brand-100);
}

/* ----------------------------------------------------------- calendar --- */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.calendar__head {
  padding: var(--sp-2);
  background: var(--surface-2);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--subtle);
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.calendar__cell {
  min-height: 96px;
  padding: var(--sp-2);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: var(--text-xs);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar__cell:nth-child(7n) {
  border-right: none;
}

.calendar__day {
  font-weight: 600;
  color: var(--subtle);
}

.calendar__event {
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar__event--approved {
  background: var(--success-50);
  color: var(--success-700);
}

.calendar__event--pending {
  background: var(--warning-50);
  color: var(--warning-700);
}

.calendar__event--blocked {
  background: var(--data-na-bg);
  color: var(--data-na);
}

/* --------------------------------------------------------- responsive --- */
@media (max-width: 1180px) {
  .grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid--sidebar {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    z-index: 70;
    transform: translateX(-100%);
    transition: transform var(--motion-base) var(--ease);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .topbar__menu {
    display: inline-flex;
  }

  .content {
    padding: var(--sp-4);
    padding-bottom: var(--sp-16);
  }

  .grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 639px) {
  .grid--4,
  .grid--3,
  .grid--2 {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .content {
    padding: var(--sp-3);
  }

  .page-head h1 {
    font-size: var(--text-lg);
  }

  .metric__value {
    font-size: var(--text-2xl);
  }

  .calendar__cell {
    min-height: 64px;
    padding: 6px;
  }

  .calendar__event {
    font-size: 9px;
  }

  .toasts {
    left: var(--sp-3);
    right: var(--sp-3);
    bottom: var(--sp-3);
    max-width: none;
  }

  .table-scroll {
    margin: 0 calc(-1 * var(--sp-3));
  }
}

/* --------------------------------------------------------- bottom nav --- */
.bottom-nav {
  display: none;
}

@media (max-width: 639px) {
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--sp-2) 0;
    font-size: 10px;
    font-weight: 600;
    color: var(--subtle);
    text-decoration: none;
  }

  .bottom-nav__item[aria-current="page"] {
    color: var(--brand-700);
  }

  .bottom-nav__icon {
    font-size: 16px;
  }
}

/* -------------------------------------------------------------- utils --- */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.row--between {
  justify-content: space-between;
}

.row--end {
  justify-content: flex-end;
}

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

.subtle {
  color: var(--subtle);
}

.small {
  font-size: var(--text-sm);
}

.tiny {
  font-size: var(--text-xs);
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.strong {
  font-weight: 600;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mt-2 {
  margin-top: var(--sp-2);
}

.mt-4 {
  margin-top: var(--sp-4);
}

.mt-6 {
  margin-top: var(--sp-6);
}

.mb-0 {
  margin-bottom: 0;
}

.mb-4 {
  margin-bottom: var(--sp-4);
}

.w-full {
  width: 100%;
}

.text-right {
  text-align: right;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: var(--sp-4) 0;
}

.kv {
  display: grid;
  grid-template-columns: minmax(120px, 32%) 1fr;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
}

.kv dt {
  color: var(--subtle);
}

.kv dd {
  margin: 0;
  color: var(--ink);
}

.progress {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--brand-500);
}

.progress__bar--warning {
  background: var(--warning-700);
}

.progress__bar--danger {
  background: var(--danger-700);
}

.note {
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--text-xs);
  color: var(--muted);
}

.note--brand {
  background: var(--brand-50);
  color: var(--brand-900);
}
