/* ===== Tokens */
:root{
  --bg: #f6f7f8;
  --bg-elev: #ffffff;
  --bg-elev-weak: #f9fafb;
  --text: #1f2937;
  --text-weak: #6b7280;
  --text-inv: #fff;

  --primary: #137fec;
  --border: #e5e7eb;
  --card-border:#e5e7eb;

  --green:#16a34a; --amber:#f59e0b; --red:#ef4444;

  --radius:12px; --radius-sm:10px;
  --shadow-1: 0 10px 24px -14px rgba(0,0,0,.18);

  --sidebar-w:256px; --sidebar-w-col:80px;
}
.dark{
  --bg:#101922;
  --bg-elev:#0f1720;
  --bg-elev-weak:#111b25;
  --text:#e5e7eb; --text-weak:#9ca3af;
  --border:#223041; --card-border:#213142;
}

/* ===== Base */
*{box-sizing:border-box}
html{color-scheme:light dark}
body.page{
  margin:0; min-height:100vh;
  background:var(--bg); color:var(--text);
  font-family:Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
}
.material-symbols-outlined{ font-variation-settings:'OPSZ' 24; }
.sr-only{ position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0,0,0,0); border:0; }
.skiplink{
  position: fixed; inset: 12px auto auto 12px; z-index: 100;
  background: var(--bg-elev); color: var(--text); border:1px solid var(--border);
  padding:.5rem .75rem; border-radius:10px; box-shadow: var(--shadow-1);
  transform: translateY(-150%); transition: transform .2s ease;
}
.skiplink:focus{ transform: translateY(0); outline:2px solid var(--primary); outline-offset:2px; }

/* ===== Layout */
.app{ position:relative; display:flex; min-height:100vh; width:100%;}
.overlay{ position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:40; }

/* Sidebar */
.sidebar{
  position:fixed; inset:0 auto 0 0; z-index:50;
  width:var(--sidebar-w); height:100%; transform: translateX(-100%);
  background:var(--bg-elev); border-right:1px solid var(--border);
  transition: transform .3s ease, width .3s ease;
}
.sidebar.is-open{ transform: translateX(0); }
@media (min-width:1024px){ .sidebar{ transform:none; } }

.sidebar__inner{ display:flex; flex-direction:column; height:100%; }
.brand{ display:flex; align-items:center; gap:12px; padding:16px 24px; border-bottom:1px solid var(--border); }
.brand__icon{ width:32px; height:32px; color:var(--primary); }
.brand__icon svg{ width:100%; height:100%; display:block; }
.brand__name{ font-size:20px; font-weight:800; letter-spacing:-.01em; }

.nav{ padding:16px; overflow-y:auto; }
.nav--footer{ margin-top:auto; border-top:1px solid var(--border); }
.nav__item{
  display:flex; align-items:center; gap:12px; padding:10px 12px; border-radius:10px;
  color:inherit; text-decoration:none;
}
.nav__item:hover{ background: color-mix(in oklab, var(--primary) 8%, transparent); }
.nav__item--active{ background: color-mix(in oklab, var(--primary) 14%, transparent); color:var(--primary); font-weight:600; }
.nav__text{ white-space:nowrap; }
.sidebar-collapsed .sidebar{ width:var(--sidebar-w-col); }
.sidebar-collapsed .brand__name, .sidebar-collapsed .nav__text{ opacity:0; visibility:hidden; }
.sidebar-collapsed .brand{ justify-content:center; }

/* Content / header */
.content{ display:flex; flex-direction:column; width:100%; min-height:100vh; transition: padding-left .3s ease; }
@media (min-width:1024px){
  .content--expanded{ padding-left:var(--sidebar-w); }
  .content--collapsed{ padding-left:var(--sidebar-w-col); }
}

.header{
  position:sticky; top:0; z-index:30; display:flex; align-items:center; justify-content:space-between;
  background:var(--bg-elev); border-bottom:1px solid var(--border);
  padding:10px 16px; box-shadow:0 1px 0 rgba(0,0,0,.06);
}
.header__left{ display:flex; align-items:center; gap:8px; }
.header__right{ display:flex; align-items:center; gap:10px; margin-left:auto; }

.icon-btn{
  width:40px; height:40px; display:inline-flex; align-items:center; justify-content:center;
  border-radius:10px; border:1px solid var(--border);
  background: var(--bg-elev-weak); color:#374151; cursor:pointer;
}
.dark .icon-btn{ background:#111b25; color:#cbd5e1; }
.icon-btn:hover{ background: color-mix(in oklab, var(--primary) 10%, transparent); }
.icon-btn.ghost{ border-color:transparent; background:transparent; }

.icon-btn .xs{ font-size:18px; line-height:1; }
.icon-btn .sm{ font-size:20px; line-height:1; }

.search{ display:flex; align-items:center; height:40px; min-width:220px; max-width:320px; background: var(--bg-elev-weak); border:1px solid var(--border); border-radius:10px; }
.search__icon{ padding-left:10px; color:var(--text-weak); }
.search__input{ flex:1; height:100%; border:none; background:transparent; color:var(--text); padding:0 12px; outline:none; }

.avatar{ width:40px; height:40px; border-radius:50%; background-image:var(--avatar); background-size:cover; background-position:center; }

/* Main + page head */
.main{ padding: 20px 16px 28px; }
.container{ margin:0 auto; max-width:1280px; }
.page-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.page-title{ margin:0; font-size: clamp(24px, 1.6vw + 18px, 34px); font-weight:900; letter-spacing:-.015em; }

.actions{ display:flex; align-items:center; gap:8px; }

/* Buttons */
.btn{
  height:40px; padding:0 14px; border-radius:10px; border:1px solid var(--border);
  background:var(--bg-elev-weak); color:var(--text); font-weight:700; display:inline-flex; align-items:center; gap:8px; cursor:pointer;
}
.btn:hover{ background: color-mix(in oklab, var(--primary) 10%, transparent); }
.btn--primary{ background:var(--primary); color:#fff; border-color:transparent; }
.btn--primary:hover{ filter:brightness(.97); }
.btn--ghost{ background:transparent; }

/* Panel + form controls */
.panel{
  background: color-mix(in oklab, var(--bg-elev) 94%, transparent);
  border:1px solid var(--card-border); border-radius:var(--radius); padding:16px; box-shadow: var(--shadow-1); margin-top: 15px; 
  margin-bottom: 20px;
}
.filters{ display:grid; grid-template-columns:1fr; gap:12px; }
@media (min-width:768px){ .filters{ grid-template-columns: repeat(4, 1fr); } }

.field{ display:block; }
.field__label{ display:block; font-size:12px; font-weight:600; margin-bottom:6px; color:var(--text); }
.input, .select{
  width:100%; height:40px; border-radius:10px; border:1px solid var(--border);
  background:var(--bg-elev-weak); color:var(--text); padding:0 12px; outline:none;
}
.input::placeholder{ color:var(--text-weak); }

/* Cards / table shell */
.card{
  background: color-mix(in oklab, var(--bg-elev) 94%, transparent);
  border:1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.card.overflow{ overflow:hidden; }

/* Table */
.table-wrap{ overflow-x:auto; }
.table{ width:100%; border-collapse:separate; border-spacing:0; font-size:14px; }
.table thead th{
  text-align:left; font-weight:700; padding:12px 16px; background: color-mix(in oklab, var(--bg) 92%, transparent);
  border-bottom:1px solid var(--border);
}
.table tbody td{
  padding:14px 16px; border-top:1px solid color-mix(in oklab, var(--border) 90%, transparent);
}
.text-right{ text-align:right; }
.inline-actions{ display:inline-flex; gap:6px; }

/* Client cell */
.client{ display:flex; align-items:center; gap:12px; }
.client__avatar{
  width:36px; height:36px; border-radius:50%; background:#e5e7eb center/cover no-repeat;
}
.client__avatar.lg{ width:40px; height:40px; }
.client__name{ margin:0; font-weight:600; }

/* Badges */
.badge{
  display:inline-flex; align-items:center; gap:6px; border-radius:9999px;
  font-size:12px; padding:.25rem .5rem; font-weight:600;
}
.badge--green{ background:#dcfce7; color:#166534; }
.dark .badge--green{ background:rgba(22,163,74,.2); color:#86efac; }

.badge--amber{ background:#fef3c7; color:#92400e; }
.dark .badge--amber{ background:rgba(245,158,11,.2); color:#fde68a; }

.badge--slate{ background:#e2e8f0; color:#334155; }
.dark .badge--slate{ background:#1f2937; color:#cbd5e1; }

/* Mobile cards */
.cards-mobile{ display:grid; }
.card-mobile{ padding:14px; border-top:1px solid color-mix(in oklab, var(--border) 90%, transparent); }
.card-mobile__head{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.kv{ margin-top:10px; font-size:12px; display:grid; gap:6px; }
.kv .muted{ color:var(--text-weak); }
.card-mobile__actions{ margin-top:12px; display:flex; gap:8px; }
.grow{ flex:1; }
.muted{ color:var(--text-weak); } .xs{ font-size:12px; }

/* Responsive helpers */
.hide-sm{ display:none; }
@media (min-width:640px){ .hide-sm{ display:flex; } }
.hide-md-down{ display:none; }
@media (min-width:768px){ .hide-md-down{ display:block; } .hide-md-up{ display:none; } }







/* ---------- Modal (scrim + sheet) ---------- */

.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* Theme tokens (fallbacks if your file doesn’t already define them) */
:root {
  --modal-surface: #ffffff;
  --modal-text: #0f172a;      /* slate-900 */
  --modal-muted: #6b7280;     /* gray-500 */
  --modal-border: #e5e7eb;    /* gray-200 */
  --modal-shadow: 0 20px 60px rgba(2, 6, 23, .18);
  --rose: #e11d48;            /* rose-600 */
  --emerald: #059669;         /* emerald-600 */
}

.dark :root,
.dark {
  --modal-surface: #0b1220;   /* near your background-dark */
  --modal-text: #e5e7eb;      /* gray-200 */
  --modal-muted: #9ca3af;     /* gray-400 */
  --modal-border: #374151;    /* gray-700 */
  --modal-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}

.modal {
  width: 100%;
  max-width: 560px;
  background: var(--modal-surface);
  color: var(--modal-text);
  border: 1px solid var(--modal-border);
  border-radius: 12px;
  box-shadow: var(--modal-shadow);
  overflow: hidden;
  transform: translateY(4px) scale(.98);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease, box-shadow .18s ease;
}

/* Alpine x-show will toggle display; when visible, animate in */
.modal-scrim[x-cloak],
[x-cloak] { display: none !important; }

.modal-scrim[style*="display: none"] .modal { opacity: 0; }
.modal-scrim:not([style*="display: none"]) .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .modal { transition: none; }
}

/* ---------- Sections ---------- */

.modal__head,
.modal__foot {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 14px 16px;
  background: transparent;
}

.modal__head {
  justify-content: space-between;
  border-bottom: 1px solid var(--modal-border);
}

.modal__title {
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0;
}

.modal__body {
  padding: 16px;
  color: var(--modal-text);
}

.modal__foot {
  justify-content: flex-end;
  border-top: 1px solid var(--modal-border);
}

/* Row helper (used in loading state) */
.row { display: flex; align-items: center; gap: .75rem; }

/* ---------- Utilities used inside modal ---------- */

.text-sm { font-size: .875rem; line-height: 1.3; }
.text-rose { color: var(--rose); }
.text-emerald { color: var(--emerald); }

/* Spinn*



/* ===== Modal loader (spinner) ===== */

/* Size utilities (used by your SVG) */
.size-6 { width: 24px; height: 24px; }

/* Spin animation */
.spin { animation: ts-spin 0.9s linear infinite; display: inline-block; }

/* Spinner strokes (inherit color so it adapts to light/dark automatically) */
.spin .dim  { opacity: 0.25; }
.spin .bold { opacity: 0.85; }

/* If you want a specific accent color for the spinner, uncomment:
.modal .spin { color: var(--color-primary, #137fec); }
*/

/* Align spinner + text when shown in "row" body */
.modal__body.row {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.2;
}

/* Keyframes */
@keyframes ts-spin {
  to { transform: rotate(360deg); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
}
