/* ===== Design tokens ===== */
:root{
  --bg-start: #eef7ff;
  --bg-end:   #f8fbff;
  --ink:      #0f172a;     /* slate-900 */
  --muted:    #475569;     /* slate-600 */
  --line:     #e2e8f0;     /* slate-200 */

  --brand:    #2563eb;     /* indigo-500/blue-600 vibe */
  --brand-700:#1e40af;

  --success:  #16a34a;
  --ring:     rgba(37,99,235,.35);

  --surface:  #ffffff;
  --shadow-1: 0 8px 30px rgba(2,6,23,.06);
  --shadow-2: 0 16px 40px rgba(2,6,23,.10);

  --radius:   14px;
  --radius-sm:10px;

  --container: 960px;
}

/* ===== Base ===== */
*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 600px at 20% -10%, #e9f0ff 0%, transparent 70%),
              radial-gradient(1000px 600px at 120% 10%, #e8fff5 0%, transparent 65%),
              linear-gradient(135deg, var(--bg-start), var(--bg-end));
  color: var(--ink);
  margin: 0;
  padding: clamp(16px, 2.5vw, 28px);
  display: grid;
  gap: clamp(16px, 2vw, 24px);
  justify-items: center;
}

/* Constrain width without touching HTML structure */
.app-header, #table, form, #avatarImage { width: min(100%, var(--container)); }

/* ===== App header ===== */
.app-header{
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 16px;
  padding: clamp(14px, 2vw, 18px) clamp(14px, 2vw, 22px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.app-title{
  margin: 0;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: .2px;
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem);
}
.app-actions{
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ===== Buttons (primary/secondary) ===== */
.btn-primary, button{
  appearance: none;
  border: none;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  letter-spacing: .2px;
  border-radius: var(--radius-sm);
  padding: .9rem 1.15rem;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(37,99,235,.20);
  transition: background .2s ease, transform .15s ease, box-shadow .2s ease;
}
.btn-primary:hover{
  background: var(--brand-700);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(30,64,175,.22);
}
.btn-primary:focus{
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.btn-action{
  background: #0ea5e9; /* cyan for secondary action */
  box-shadow: 0 8px 18px rgba(14,165,233,.18);
}
.btn-action:hover{
  background: #0284c7;
  box-shadow: 0 12px 24px rgba(2,132,199,.22);
}

/* ===== Table-as-cards list ===== */
#table{
  min-height: 120px;
  color: var(--muted);
  position: relative;
}

/* Card list using your existing table/rows */
table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 14px;
  margin: 0;
}
tr{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: transform .18s ease, box-shadow .18s ease, background .2s ease, border-color .2s ease;
}
tr:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: #cbd5e1;
  cursor: pointer;
}
td{
  padding: 1.1rem 1.25rem;
  vertical-align: middle;
  border-bottom: none;
}
td:first-child{
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}
td:last-child{
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

/* subtle accent on hover, no HTML change required */
tr:hover td:first-child{ box-shadow: inset 4px 0 0 var(--brand); }

/* avatar */
.cell-avatar img{
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #e2e8f0;
  box-shadow: 0 0 0 4px #f8fafc;
}

/* names */
h5{
  margin: 0;
  font-size: clamp(1.05rem, .95rem + .4vw, 1.2rem);
  font-weight: 700;
  color: var(--ink);
}

/* empty state */
.empty-state{
  width: 100%;
  text-align: center;
  color: var(--muted);
  padding: 18px 10px;
}

/* ===== Loading skeleton (no markup change) ===== */
#table[data-loading]{
  position: relative;
}
#table[data-loading]::before{
  content: "";
  display: block;
  height: 10px;
}
#table[data-loading]::after{
  content: "";
  position: absolute;
  inset: 12px 0 0 0;
  height: 160px;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, #eef2f7 25%, #f5f7fb 37%, #eef2f7 63%) 0 0 / 800px 100% no-repeat,
    linear-gradient(#eef2f7,#eef2f7) top / 100% 160px no-repeat;
  animation: shimmer 1.1s linear infinite;
  box-shadow: var(--shadow-1);
  border: 1px solid var(--line);
}
@keyframes shimmer{
  0% { background-position: -800px 0, 0 0; }
  100% { background-position: 800px 0, 0 0; }
}

/* ===== Forms (add/edit pages) ===== */
form{
  background: var(--surface);
  padding: clamp(16px, 2vw, 24px);
  margin-top: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
label{
  display: block;
  margin-top: 12px;
  font-weight: 600;
  color: var(--ink);
}
input[type="text"],
input[type="file"]{
  width: 100%;
  padding: 0.9rem 1rem;
  margin-top: .55rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input[type="text"]:focus,
input[type="file"]:focus{
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 5px rgba(37,99,235,.18);
  background: #fff;
}

/* Avatar on edit page */
#avatarImage img{
  display: block;
  margin: 1.25rem auto 0;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 4px solid #e2e8f0;
  box-shadow: var(--shadow-2);
}

/* Accessibility focus */
:focus-visible{
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}

/* Responsive tweaks */
@media (max-width: 640px){
  .app-header{
    grid-template-columns: 1fr;
    align-items: start;
  }
  .app-actions{
    justify-content: stretch;
  }
  .app-actions > *{ flex: 1; }
  td{ padding: 1rem; }
}

/* Optional nicer scrollbar on desktop */
@media (pointer: fine){
  *{ scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
  *::-webkit-scrollbar{ height: 8px; width: 8px; }
  *::-webkit-scrollbar-thumb{ background: #cbd5e1; border-radius: 999px; }
  *::-webkit-scrollbar-track{ background: transparent; }
}