/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 36px; padding: 0 16px; border-radius: var(--r-pill);
  border: 1px solid transparent; background: transparent;
  font-weight: 600; font-size: var(--fs-base); white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
  text-decoration: none !important;
}
.btn:disabled, .btn[aria-busy="true"] { opacity: .6; cursor: not-allowed; }
.btn-primary { background: linear-gradient(120deg, #0A1A33, #0C968F); color: #fff; border-color: transparent; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(120deg, #0D2242, #0FA89F); box-shadow: 0 4px 14px rgba(12,150,143,.28); }
.btn-secondary { border-color: var(--primary); color: var(--primary); background: var(--surface); }
.btn-secondary:hover:not(:disabled) { background: var(--primary-soft); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); }
.btn-outline { border-color: var(--border-strong); color: var(--text-2); background: var(--surface); }
.btn-outline:hover:not(:disabled) { background: var(--surface-2); border-color: var(--cx-gray-400); }
.btn-danger { background: var(--cx-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; }
.btn-sm { height: 30px; padding: 0 12px; font-size: var(--fs-sm); }
.btn-lg { height: 44px; padding: 0 22px; font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; border-radius: 50%; }
.btn-icon.btn-sm { width: 30px; }
.btn .spinner { width: 14px; height: 14px; }

.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ===== Cards ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-card); }
.card-pad { padding: var(--s-5); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5) 0; }
.card-body { padding: var(--s-4) var(--s-5) var(--s-5); }
.card-footer { border-top: 1px solid var(--border); padding: var(--s-3) var(--s-5); }
.card-section + .card-section { border-top: 1px solid var(--border); }
.card-link { display: block; padding: var(--s-3) var(--s-5); text-align: center; font-weight: 600; color: var(--text-2); border-top: 1px solid var(--border); border-radius: 0 0 var(--r-md) var(--r-md); }
.card-link:hover { background: var(--surface-2); text-decoration: none; }

/* ===== Avatar ===== */
.avatar {
  --size: 40px;
  width: var(--size); height: var(--size); flex: none; border-radius: 50%;
  background: linear-gradient(120deg, #0A1A33, #0C968F); color: #fff;
  display: inline-grid; place-items: center; overflow: hidden;
  font-weight: 700; font-size: calc(var(--size) * .38); letter-spacing: .02em; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { --size: 24px; }
.avatar-sm { --size: 32px; }
.avatar-md { --size: 48px; }
.avatar-lg { --size: 72px; }
.avatar-xl { --size: 152px; border: 4px solid var(--surface); }
.avatar.is-company { border-radius: var(--r-sm); background: var(--surface-2); color: var(--brand); border: 1px solid var(--border); }
.avatar-ring { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }

/* ===== Badges & pills ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; background: var(--surface-hover); color: var(--text-2); white-space: nowrap; }
.badge-blue { background: var(--primary-soft-2); color: var(--cx-blue-700); }
.badge-teal { background: var(--cx-teal-100); color: var(--cx-teal-600); }
.badge-green { background: var(--cx-success-bg); color: var(--cx-success); }
.badge-amber { background: var(--cx-warning-bg); color: var(--cx-warning); }
.badge-red { background: var(--cx-danger-bg); color: var(--cx-danger); }
.verified { display: inline-flex; color: var(--primary); vertical-align: -3px; }
.verified .icon { width: 16px; height: 16px; fill: var(--primary); stroke: #fff; stroke-width: 2; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); }
.chip button { border: 0; background: none; padding: 0; color: var(--text-faint); display: inline-flex; }
.chip button:hover { color: var(--cx-danger); }
.chip-list { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field .hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field .error { font-size: var(--fs-xs); color: var(--cx-danger); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font-size: var(--fs-base);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-inline-end: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235B6B82' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
[dir="rtl"] .select { background-position: left 12px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--cx-gray-400); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--cx-danger); }
.input-group { position: relative; }
.input-group .icon { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.input-group .input { padding-inline-start: 38px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.form-grid .span-2 { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: var(--fs-base); color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--primary); flex: none; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--cx-gray-300); position: relative; margin: 0; transition: background .15s; cursor: pointer; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { inset-inline-start: 19px; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--s-2); }
.form-error { padding: 10px 12px; border-radius: var(--r-sm); background: var(--cx-danger-bg); color: var(--cx-danger); font-size: var(--fs-sm); font-weight: 500; }
.form-success { padding: 10px 12px; border-radius: var(--r-sm); background: var(--cx-success-bg); color: var(--cx-success); font-size: var(--fs-sm); font-weight: 500; }

/* Segmented choice (onboarding account type) */
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.choice { position: relative; display: flex; flex-direction: column; gap: 6px; padding: var(--s-5); border: 1.5px solid var(--border); border-radius: var(--r-md); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; text-align: start; }
.choice:hover { border-color: var(--cx-gray-400); }
.choice[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.choice .icon { width: 28px; height: 28px; color: var(--primary); margin-bottom: 4px; }

/* ===== Tabs ===== */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 12px 14px; border: 0; background: none; color: var(--text-muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== Modal ===== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(6, 18, 38, .52); display: grid; place-items: center; padding: var(--s-4); z-index: 100; animation: fade .12s ease-out; }
.modal { width: min(600px, 100%); max-height: min(88vh, 900px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); animation: pop .14s ease-out; }
.modal-sm { width: min(440px, 100%); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
.modal-body { padding: var(--s-5); overflow-y: auto; }
.modal-footer { display: flex; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); }
.modal-footer .end { display: flex; gap: var(--s-2); margin-inline-start: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }

/* ===== Dropdown ===== */
.dropdown { position: relative; }
.menu { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: var(--s-2); z-index: 60; }
.menu a, .menu button { display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: var(--r-sm); color: var(--text-2); font-weight: 500; text-align: start; text-decoration: none !important; }
.menu a:hover, .menu button:hover { background: var(--surface-hover); color: var(--text); }
.menu hr { margin: var(--s-2) 0; }
.menu-head { display: flex; gap: var(--s-3); padding: var(--s-2) var(--s-2) var(--s-3); }

/* ===== Toasts ===== */
.toasts { position: fixed; inset-block-end: 20px; inset-inline-start: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--s-2); z-index: 200; width: min(420px, calc(100% - 32px)); }
[dir="rtl"] .toasts { transform: translateX(50%); }
.toast { display: flex; align-items: center; gap: var(--s-3); padding: 12px 14px; background: var(--cx-navy-800); color: #fff; border-radius: var(--r-md); box-shadow: var(--shadow-pop); font-weight: 500; animation: pop .16s ease-out; }
.toast .icon { color: var(--cx-teal-500); }
.toast.is-error .icon { color: #FCA5A5; }
.toast button { margin-inline-start: auto; border: 0; background: none; color: #cbd5e1; padding: 0; display: inline-flex; }

/* ===== States ===== */
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--primary-soft-2); border-top-color: var(--primary); animation: spin .7s linear infinite; }
.btn-primary .spinner, .btn-danger .spinner { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-loading { display: grid; place-items: center; min-height: 40vh; }
.skeleton { background: linear-gradient(90deg, var(--cx-gray-100) 0%, var(--cx-gray-50) 50%, var(--cx-gray-100) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-2); padding: var(--s-10) var(--s-5); color: var(--text-muted); }
.empty .empty-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: var(--s-2); }
.empty h3 { color: var(--text); font-size: var(--fs-md); }
.empty p { max-width: 380px; font-size: var(--fs-sm); }
.empty .btn { margin-top: var(--s-3); }
.banner { display: flex; align-items: center; gap: var(--s-3); padding: 12px var(--s-4); border-radius: var(--r-md); background: var(--cx-warning-bg); color: var(--cx-warning); font-weight: 500; font-size: var(--fs-sm); }
.banner .btn { margin-inline-start: auto; }
.banner.is-info { background: var(--primary-soft); color: var(--cx-blue-700); }

/* ===== Lists ===== */
.list-item { display: flex; gap: var(--s-3); align-items: center; padding: var(--s-3) 0; }
.list-item + .list-item { border-top: 1px solid var(--border); }
.list-item .meta { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; color: var(--text); }
.list-item .title:hover { color: var(--primary); }
.list-item .sub { font-size: var(--fs-sm); color: var(--text-muted); }

/* ===== Progress ===== */
.meter { height: 8px; border-radius: 999px; background: var(--cx-gray-100); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .4s; }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--s-2); padding: var(--s-4) 0; }

/* ===== Tables (admin) ===== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: start; font-weight: 600; color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--surface-2); }

/* Profile picture viewer (openImageViewer) */
.avatar:not(.is-company) > img { cursor: zoom-in; }
a .avatar > img, button .avatar > img { cursor: pointer; }
.image-viewer { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: var(--s-6); background: rgba(6, 18, 38, .82); cursor: zoom-out; animation: fade .15s ease-out; }
.image-viewer img { max-width: min(94vw, 1280px); max-height: 82vh; width: auto; height: auto; border-radius: var(--r-lg); box-shadow: 0 20px 60px rgba(0, 0, 0, .45); background: var(--surface); animation: pop .18s ease-out; }
.image-viewer-close { position: absolute; top: var(--s-4); inset-inline-end: var(--s-4); display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer; }
.image-viewer-close:hover { background: rgba(255, 255, 255, .26); }
[data-view-image] { cursor: zoom-in; }
[data-view-image] button { cursor: pointer; }
