/* App UI — layered on Tailwind CDN */

:root {
  --color-primary: rgb(79 70 229);
  --color-primary-hover: rgb(67 56 202);
  --color-surface: rgb(255 255 255);
  --color-border: rgb(226 232 240);
  --color-muted: rgb(100 116 139);
  --radius: 0.625rem;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.07);
}

/* ----- Layout & page chrome ----- */

.page-wrap {
  max-width: 72rem;
  margin-left: auto;
  margin-right: auto;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: rgb(15 23 42);
  line-height: 1.25;
}

.page-subtitle {
  margin-top: 0.35rem;
  font-size: 0.875rem;
  color: var(--color-muted);
  max-width: 42rem;
  line-height: 1.5;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* ----- Navigation ----- */

.nav-link {
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius);
  color: rgb(51 65 85);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background: rgb(241 245 249);
  color: rgb(15 23 42);
}

.nav-link.active {
  background: rgb(238 242 255);
  color: var(--color-primary);
  font-weight: 600;
}

.admin-only {
  display: none;
}

body[data-role="admin"] .admin-only {
  display: inline-flex;
}

.app-brand-sub {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: rgb(148 163 184);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-top: 0.15rem;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgb(241 245 249);
  color: rgb(71 85 105);
}

.role-pill--admin {
  background: rgb(238 242 255);
  color: rgb(67 56 202);
}

/* ----- Buttons ----- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  border: 1px solid transparent;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease,
    color 0.15s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-surface);
  color: rgb(30 41 59);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: rgb(248 250 252);
  border-color: rgb(203 213 225);
}

.btn-danger {
  background: rgb(254 242 242);
  color: rgb(185 28 28);
  border-color: rgb(254 202 202);
}

.btn-danger:hover {
  background: rgb(254 226 226);
  border-color: rgb(252 165 165);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

/* ----- Cards & stats ----- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card h3,
.card .card-heading {
  font-size: 0.9375rem;
  font-weight: 700;
  color: rgb(30 41 59);
  margin-bottom: 0.5rem;
}

.stat-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid rgb(148 163 184);
}

.stat-card__label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgb(100 116 139);
}

.stat-card__value {
  margin-top: 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: rgb(15 23 42);
  font-variant-numeric: tabular-nums;
}

.stat-card__hint {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: rgb(100 116 139);
  line-height: 1.4;
}

.stat-card--deal {
  border-top-color: rgb(99 102 241);
}

.stat-card--received {
  border-top-color: rgb(16 185 129);
}

.stat-card--balance {
  border-top-color: rgb(245 158 11);
}

/* ----- Forms ----- */

.field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgb(51 65 85);
  margin-bottom: 0.35rem;
}

.field-hint {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: rgb(100 116 139);
  line-height: 1.45;
}

.field-input {
  width: 100%;
  border: 1px solid rgb(203 213 225);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  background: white;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-input:hover {
  border-color: rgb(148 163 184);
}

.field-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.field-input:disabled,
.field-input[readonly] {
  background: rgb(248 250 252);
  color: rgb(71 85 105);
  cursor: not-allowed;
}

.form-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgb(100 116 139);
  margin-bottom: 0.75rem;
}

/* ----- Toolbar (agreement actions) ----- */

.action-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1rem;
  background: rgb(248 250 252);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.action-toolbar__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.action-toolbar__label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgb(100 116 139);
  width: 100%;
  margin-bottom: 0.15rem;
}

.action-toolbar__divider {
  width: 1px;
  align-self: stretch;
  min-height: 2.25rem;
  background: rgb(226 232 240);
  margin: 0 0.15rem;
}

.select-compact {
  border: 1px solid rgb(203 213 225);
  border-radius: var(--radius);
  padding: 0.4rem 0.55rem;
  font-size: 0.8125rem;
  background: white;
  min-width: 5.5rem;
}

.select-compact:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

/* ----- Tables ----- */

.table-grid {
  width: 100%;
  border-collapse: collapse;
}

.table-grid th,
.table-grid td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgb(241 245 249);
  text-align: left;
  vertical-align: top;
  font-size: 0.875rem;
}

.table-grid tbody tr:hover td {
  background: rgb(248 250 252);
}

.table-grid th {
  background: rgb(248 250 252);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgb(71 85 105);
  border-bottom: 1px solid rgb(226 232 240);
}

.table-grid td {
  color: rgb(30 41 59);
}

.link-action {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--color-primary);
}

.link-action:hover {
  text-decoration: underline;
  color: var(--color-primary-hover);
}

/* ----- Badges ----- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-paid {
  background: rgb(220 252 231);
  color: rgb(21 128 61);
}

.badge-due {
  background: rgb(254 249 195);
  color: rgb(161 98 7);
}

.badge-role {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgb(71 85 105);
}

/* ----- Empty & misc ----- */

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: rgb(100 116 139);
  font-size: 0.875rem;
}

.login-card {
  width: 100%;
  max-width: 22rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.75rem;
}

.flash-toast {
  background: white;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  max-width: 28rem;
}

.flash-toast.error {
  border-left-color: rgb(220 38 38);
  color: rgb(127 29 29);
}

.flash-toast.success {
  border-left-color: rgb(22 163 74);
  color: rgb(20 83 45);
}

.flash-toast.info {
  border-left-color: rgb(100 116 139);
  color: rgb(51 65 85);
}

/* ----- Inline help (tooltips) ----- */

.has-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  background: rgb(226 232 240);
  color: rgb(71 85 105);
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  vertical-align: 0.1em;
  position: relative;
  outline: none;
}

.has-tip:hover,
.has-tip:focus-visible {
  background: rgb(199 210 254);
  color: rgb(55 48 163);
}

.has-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: min(16rem, 70vw);
  padding: 0.45rem 0.55rem;
  background: rgb(30 41 59);
  color: rgb(248 250 252);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  border-radius: 0.35rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 50;
  text-transform: none;
  letter-spacing: normal;
}

.has-tip:hover::after,
.has-tip:focus-visible::after {
  opacity: 1;
}

.filter-panel .field-label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem;
}
