/* Reusable pieces: cards, tiles, badges, list rows, buttons and form controls. */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

.card--pad { padding: var(--s-4); }

.section {
  margin-bottom: var(--s-5);
}

.section__head {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin: 0 2px var(--s-3);
}

/* Wide tracking and small size, so the label frames the block instead of
   competing with the content inside it. */
.section__title {
  font-size: 11px;
  font-weight: 620;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.section__aside {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-2);
  margin-bottom: var(--s-5);
}

@media (min-width: 720px) {
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-3) var(--s-3) var(--s-4);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  min-height: 116px;
  text-align: left;
  width: 100%;
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.tile:hover {
  border-color: var(--border-strong);
}

/* The figure sits at the bottom of the tile, under its label - the reading
   order of a stat card, and what gives the grid its horizon line. */
.tile__value { margin-top: auto; }

.tile__label {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 620;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tile__value {
  font-size: 2.4rem;
  font-weight: 660;
  letter-spacing: -0.045em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.tile__value--sm {
  font-size: 1.5rem;
  letter-spacing: -0.035em;
}

.tile__extra {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tile--overdue .tile__value { color: var(--st-overdue); }
.tile--due .tile__value { color: var(--st-due); }

/* ------------------------------------------------------------------- dots */
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  background: var(--st-cancelled);
  display: inline-block;
}

.dot[data-status="PAID"] { background: var(--st-paid); }
.dot[data-status="UPCOMING"] { background: var(--st-upcoming); }
.dot[data-status="DUE_TODAY"] { background: var(--st-due); }
.dot[data-status="OVERDUE"] { background: var(--st-overdue); }
.dot[data-status="CANCELLED"] { background: var(--st-cancelled); }
.dot[data-status="SKIPPED"] { background: var(--st-skipped); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge[data-status="PAID"], .badge[data-status="SENT"] {
  background: color-mix(in srgb, var(--st-paid) 14%, transparent);
  color: var(--st-paid);
}
.badge[data-status="UPCOMING"], .badge[data-status="PENDING"] {
  background: color-mix(in srgb, var(--st-upcoming) 14%, transparent);
  color: var(--st-upcoming);
}
.badge[data-status="DUE_TODAY"], .badge[data-status="PROCESSING"] {
  background: color-mix(in srgb, var(--st-due) 16%, transparent);
  color: var(--st-due);
}
.badge[data-status="OVERDUE"], .badge[data-status="FAILED"] {
  background: color-mix(in srgb, var(--st-overdue) 14%, transparent);
  color: var(--st-overdue);
}

/* -------------------------------------------------------------- list rows */
.rows {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: 74px;
  padding: var(--s-2) var(--s-4);
  background: none;
  border: 0;
  border-top: 1px solid var(--border);
  text-align: left;
  color: inherit;
  transition: background 0.14s ease;
}

.row:first-child { border-top: 0; }
.row:hover { background: var(--surface-2); }

.row__icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 18px;
  flex: none;
  background: var(--surface-2);
}

.row__body {
  flex: 1 1 auto;
  min-width: 0;
}

.row__title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  white-space: nowrap;
}

.row__side {
  flex: none;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.row__amount {
  font-weight: 640;
  font-size: 15px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.row__days {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.row__days--overdue { color: var(--st-overdue); font-weight: 600; }
.row__days--today { color: var(--st-due); font-weight: 600; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 var(--s-4);
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 590;
  font-size: 14px;
  letter-spacing: -0.005em;
  transition: filter 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}

.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.btn--primary:hover { filter: brightness(1.07); background: var(--accent); }

.btn--danger { color: var(--danger); border-color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }

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

.btn--block { width: 100%; }
.btn--sm { min-height: 34px; padding: 0 var(--s-3); font-size: 13px; }

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  border: 0;
  background: transparent;
  font-size: 17px;
  color: var(--text-2);
}

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

.fab {
  position: fixed;
  right: max(16px, var(--safe-right));
  bottom: calc(78px + var(--safe-bottom));
  z-index: 25;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 27px;
  line-height: 1;
  box-shadow: var(--shadow-2);
  display: grid;
  place-items: center;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-row > .btn { flex: 1 1 auto; }

/* ------------------------------------------------------------------ forms */
.field {
  margin-bottom: var(--s-3);
}

.field__label {
  display: block;
  font-size: 10.5px;
  font-weight: 620;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--s-1);
}

/* "(ixtiyoriy)" is an aside, not part of the label - it drops out of the
   small-caps treatment so it does not read as a second label. */
.field__label .opt {
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 48px;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  appearance: none;
  transition: border-color 0.14s ease, background 0.14s ease;
}

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

.select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 17px center, right 12px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

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

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"] {
  border-color: var(--danger);
}

.field__error {
  margin-top: 4px;
  font-size: 12px;
  color: var(--danger);
}

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

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  min-height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chip[aria-pressed="true"],
.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.switch {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 54px;
  width: 100%;
  padding: var(--s-1) 0;
  background: none;
  border: 0;
  text-align: left;
  color: inherit;
}

.switch__text { flex: 1 1 auto; min-width: 0; }
.switch__title { font-size: 14.5px; font-weight: 570; }
.switch__sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.switch__track {
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-3);
  position: relative;
  transition: background 0.16s ease;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-1);
  transition: transform 0.16s ease;
}

.switch[aria-checked="true"] .switch__track { background: var(--accent); }
.switch[aria-checked="true"] .switch__track::after { transform: translateX(18px); }
.switch:disabled { opacity: 0.55; cursor: not-allowed; }

.collapse__head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap);
  background: none;
  border: 0;
  color: var(--accent);
  font-weight: 570;
  font-size: 13.5px;
  padding: 0;
}


/* attachments (spec section 24) */
.file__icon {
  flex: 0 0 auto;
  font-size: 17px;
  line-height: 1;
}

.file__name {
  display: block;
  min-width: 0;
  text-align: start;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.file__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent);
  font-weight: 540;
}

.file__name:hover .file__label { text-decoration: underline; }
