:root {
  --brand-ink: #0f172a;
  --brand-panel: #ffffff;
  --brand-muted: #64748b;
  --brand-accent: #0ea5e9;
  --brand-accent-2: #16a34a;
  --brand-danger: #dc2626;
  --brand-warning: #d97706;
  --brand-border: #e2e8f0;
  --brand-bg: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(
    circle at top right,
    #ecfeff 0%,
    #f8fafc 45%,
    #ffffff 100%
  );
  color: var(--brand-ink);
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

a {
  color: #0369a1;
}

/* Reusable components */
.ui-card,
.card {
  background: var(--brand-panel);
  border: 1px solid var(--brand-border);
  border-radius: 0.9rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.ui-card-body,
.card-body {
  padding: 1.25rem;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--brand-border);
}

.ui-input,
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 0.65rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.95rem;
  background: #fff;
}

.ui-input:focus,
.form-control:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.ui-btn,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.65rem;
  border: 1px solid transparent;
  padding: 0.55rem 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ui-btn-primary,
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
}

.ui-btn-primary:hover,
.btn-primary:hover {
  filter: brightness(1.05);
}

.ui-btn-danger,
.btn-danger {
  color: #fff;
  background: #dc2626;
}

.ui-btn-success,
.btn-success {
  color: #fff;
  background: #16a34a;
}

.btn-dark {
  color: #fff;
  background: #334155;
}

.btn-light {
  color: #0f172a;
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-block {
  width: 100%;
}

.alert {
  border-radius: 0.65rem;
  padding: 0.8rem 1rem;
  border: 1px solid transparent;
}

.alert-success {
  background: #ecfdf5;
  color: #166534;
  border-color: #86efac;
}

.alert-danger {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fca5a5;
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border-color: #fcd34d;
}

.alert-info {
  background: #f0f9ff;
  color: #0c4a6e;
  border-color: #7dd3fc;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table th,
.table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 0.7rem;
  text-align: left;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}

.badge-success {
  color: #fff;
  background: #16a34a;
}

.badge-danger {
  color: #fff;
  background: #dc2626;
}

/* Basic grid compatibility used by legacy view markup */
.row {
  display: flex;
  flex-wrap: wrap;
  margin: -0.5rem;
}

.row > [class*="col-"] {
  padding: 0.5rem;
  width: 100%;
}

.col-12,
.col-md-12,
.col-lg-12 {
  width: 100%;
}

@media (min-width: 768px) {
  .col-md-6 {
    width: 50%;
  }
  .col-md-4 {
    width: 33.333%;
  }
  .col-md-3 {
    width: 25%;
  }
  .col-md-9 {
    width: 75%;
  }
}

@media (min-width: 1024px) {
  .col-lg-4 {
    width: 33.333%;
  }
  .col-lg-6 {
    width: 50%;
  }
}

.main-content {
  padding: 1rem;
}

@media (min-width: 1024px) {
  .main-content {
    padding: 1.5rem;
  }
}

.loader {
  display: none;
}

/* Admin mobile utilities */
.mobile-nav {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--brand-border);
  background: #fff;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-nav-link {
  white-space: nowrap;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  text-decoration: none;
  color: #334155;
  background: #fff;
}

.mobile-nav-link.is-active {
  border-color: #38bdf8;
  background: #e0f2fe;
  color: #0c4a6e;
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tx-actions {
  min-width: 220px;
}

.tx-action-form {
  display: inline-block;
  margin: 0 6px 6px 0;
}

.transactions-page {
  max-width: 100%;
  overflow-x: clip;
}

.transactions-page .tx-table td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.task-card {
  border: 1px solid var(--brand-border);
  border-radius: 0.9rem;
  background: #fff;
  margin-bottom: 1rem;
}

.task-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.9rem 1rem;
  font-weight: 700;
  border-bottom: 1px solid transparent;
}

.task-card > summary::-webkit-details-marker {
  display: none;
}

.task-card[open] > summary {
  border-bottom-color: var(--brand-border);
}

.task-card-body {
  padding: 1rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.pagination-summary {
  font-size: 0.9rem;
  color: var(--brand-muted);
}

.pagination-links {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.7rem;
  background: #fff;
  color: #0f172a;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.pagination-link.is-active {
  border-color: #0284c7;
  background: #e0f2fe;
  color: #0c4a6e;
}

.pagination-link.is-disabled {
  color: #94a3b8;
  background: #f8fafc;
}

@media (max-width: 767px) {
  .card-body {
    padding: 1rem;
  }

  .ui-btn,
  .btn {
    width: 100%;
    margin-top: 0.35rem;
  }

  .table th,
  .table td {
    white-space: nowrap;
  }

  .pagination {
    align-items: stretch;
  }

  .pagination-summary {
    width: 100%;
  }

  .pagination-links {
    width: 100%;
  }

  .pagination-link {
    flex: 1 1 auto;
  }

  .tx-table thead {
    display: none;
  }

  .tx-table,
  .tx-table tbody,
  .tx-table tr,
  .tx-table td {
    display: block;
    width: 100%;
  }

  .tx-table tr {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.65rem;
    margin-bottom: 0.75rem;
    background: #fff;
  }

  .tx-table td {
    border-bottom: 1px dashed #e2e8f0;
    white-space: normal;
    padding: 0.5rem 0;
    text-align: left;
  }

  .tx-table td:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .tx-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.2rem;
    color: #475569;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }

  .tx-actions {
    min-width: 0;
  }

  .tx-action-form {
    display: block !important;
    margin: 0 0 0.45rem;
  }

  .tx-actions .ui-btn,
  .tx-actions .btn {
    width: 100%;
    margin-top: 0;
  }

  .transactions-page .row {
    margin-left: 0;
    margin-right: 0;
  }

  .transactions-page .row > [class*="col-"] {
    padding-left: 0;
    padding-right: 0;
  }

  .transactions-page .table-wrap {
    overflow-x: hidden;
  }
}
