/* PayKid Admin — palette & typography from DESIGN.md */

@font-face {
  font-family: 'Outfit';
  src: url('fonts/outfit-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --primary: #5B5BD6;
  --primary-dark: #4746B8;
  --primary-soft: #EEEEFB;
  --navy: #1E1B39;
  --text: #111827;
  --text-2: #6B7280;
  --bg: #F7F7FC;
  --surface: #FFFFFF;
  --border: #ECECF4;
  --success: #22C55E;
  --success-soft: #E9F9EF;
  --danger: #EF4444;
  --danger-soft: #FDECEC;
  --warning: #B45309;
  --warning-soft: #FEF3E2;
  --info: #3B82F6;
  --info-soft: #EAF2FE;
  --neutral: #6B7280;
  --neutral-soft: #F3F4F6;
  --shadow: 0 4px 12px rgba(30, 27, 57, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: 'Outfit', 'Inter', sans-serif; color: var(--navy); margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Shell ---- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-tile {
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center;
  font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 19px;
}
.brand-name { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 17px; }
.brand-pay { color: var(--navy); }
.brand-kid { color: var(--primary); }
.brand-admin { color: var(--text-2); font-weight: 500; font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--text-2); font-weight: 500;
}
.nav-item:hover { background: var(--bg); text-decoration: none; }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 16px; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.admin-chip { display: flex; align-items: center; gap: 8px; padding: 0 8px; }
.admin-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-family: 'Outfit', sans-serif;
}
.admin-name { font-weight: 600; font-size: 13px; }

.main { flex: 1; padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 23px; font-weight: 700; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { font-size: 17px; font-weight: 600; margin-bottom: 12px; }

/* ---- Stat cards ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); padding: 14px 16px;
}
.stat-icon {
  width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center;
  font-size: 16px; margin-bottom: 8px; background: var(--primary-soft);
}
.stat-icon.green { background: var(--success-soft); }
.stat-icon.amber { background: var(--warning-soft); }
.stat-icon.blue { background: var(--info-soft); }
.stat-icon.red { background: var(--danger-soft); }
.stat-value { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 22px; color: var(--navy); }
.stat-label { color: var(--text-2); font-size: 12px; }
.stat-sub { color: var(--text-2); font-size: 12px; margin-top: 2px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2);
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { color: var(--text-2); font-size: 12px; }
.muted { color: var(--text-2); }
.empty { color: var(--text-2); text-align: center; padding: 28px 10px; }

/* ---- Chips ---- */
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.chip-green { background: var(--success-soft); color: #15803D; }
.chip-red { background: var(--danger-soft); color: #B91C1C; }
.chip-amber { background: var(--warning-soft); color: var(--warning); }
.chip-blue { background: var(--info-soft); color: #1D4ED8; }
.chip-indigo { background: var(--primary-soft); color: var(--primary-dark); }
.chip-gray { background: var(--neutral-soft); color: var(--neutral); }

/* ---- Icon tiles ---- */
.tile {
  width: 38px; height: 38px; border-radius: 12px; background: var(--primary-soft);
  display: inline-grid; place-items: center; font-size: 17px; flex: 0 0 auto;
}
.row-id { display: flex; align-items: center; gap: 10px; }

/* ---- Buttons & forms ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: 'Inter', sans-serif; font-weight: 600; font-size: 14px;
  border-radius: 14px; border: none; cursor: pointer;
  padding: 10px 18px; background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-outline { background: var(--surface); color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-danger { background: var(--surface); color: var(--danger); border: 1.5px solid var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; color: var(--text-2); padding: 6px 10px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; }

label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="number"], input[type="url"],
input[type="search"], input[type="datetime-local"], input[type="date"], select, textarea {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-family: 'Inter', sans-serif; font-size: 14px;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
select { appearance: auto; }
.field { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }

/* ---- Filter bar ---- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters input, .filters select { width: auto; min-width: 160px; height: 40px; }
.filters .btn { padding: 9px 16px; }

/* ---- Pagination ---- */
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.pager .muted { font-size: 12px; }

/* ---- Progress bars ---- */
.bar { height: 8px; border-radius: 999px; background: #E9E9F5; overflow: hidden; display: flex; min-width: 90px; }
.bar-fill { background: var(--primary); }
.bar-fill.green { background: var(--success); }
.bar-fill.amber { background: #F59E0B; }
.bar-fill.gray { background: #9CA3AF; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--text-2); margin-top: 6px; flex-wrap: wrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.dot.green { background: var(--success); }
.dot.amber { background: #F59E0B; }
.dot.gray { background: #9CA3AF; }

/* ---- Detail layout ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.back-link { font-size: 13px; font-weight: 500; }

/* ---- Alerts ---- */
.alert { border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-weight: 500; }
.alert-error { background: var(--danger-soft); color: #B91C1C; }
.alert-ok { background: var(--success-soft); color: #15803D; }

/* ---- Login ---- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  padding: 32px 28px;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; }
.login-brand .brand-tile { width: 56px; height: 56px; border-radius: 16px; font-size: 30px; }
.login-title { font-size: 21px; font-weight: 700; }
.login-sub { color: var(--text-2); font-size: 13px; text-align: center; }
.login-card .btn { width: 100%; height: 50px; margin-top: 6px; }

/* ---- Database browser ---- */
.db-table td { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.db-cell { cursor: cell; }
.db-cell:hover { outline: 1px dashed var(--primary); outline-offset: -1px; }
.db-null { color: var(--text-2); font-style: italic; font-size: 11px; }
.db-edit { width: 100%; min-width: 140px; height: 32px; padding: 2px 6px; border-radius: 8px; font-size: 13px; }
textarea.db-edit { height: auto; white-space: pre; }
.db-saved { background: var(--success-soft) !important; transition: background 0.3s; }
code { background: var(--neutral-soft); border-radius: 6px; padding: 1px 5px; font-size: 12px; }

/* ---- Danger zone ---- */
.danger-zone { border: 1px solid var(--danger-soft); }
.danger-zone h2 { color: #B91C1C; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px;
    border-right: none; border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .brand { padding: 0 8px 0 0; }
  .brand-name { display: none; }
  .nav { flex-direction: row; }
  .nav-item { padding: 8px 10px; white-space: nowrap; }
  .sidebar-foot { border-top: none; padding-top: 0; flex-direction: row; align-items: center; margin-left: auto; }
  .admin-name { display: none; }
  .main { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 120px 1fr; }
}
