/* ============================================================
   NP642 Companion — Design System
   Implements the implementation board: light theme, white cards,
   primary #0750FE, rounded, warm & human, mobile-first (PE-010 D)
   ============================================================ */

:root {
  --primary:       #0750FE;
  --primary-dark:  #0540CB;
  --primary-soft:  #E8EFFF;
  --bg:            #F5F7FB;
  --card:          #FFFFFF;
  --text:          #1A2340;
  --text-muted:    #6B7590;
  --border:        #E4E8F0;
  --success:       #1EA05A;
  --success-soft:  #E4F6EC;
  --warning:       #E58900;
  --warning-soft:  #FFF3E0;
  --danger:        #E23D3D;
  --danger-soft:   #FDECEC;
  --radius:        14px;
  --radius-sm:     10px;
  --shadow:        0 2px 10px rgba(26, 35, 64, 0.06);
  --shadow-lift:   0 6px 20px rgba(26, 35, 64, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
a { color: var(--primary); text-decoration: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 1rem; font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background .15s, transform .05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #A9BEF9; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-ghost   { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-danger-outline { background:#fff; color: var(--danger); border-color: var(--danger); }
.btn-auto { width: auto; }
.btn-sm { padding: 8px 14px; font-size: .875rem; width: auto; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: .875rem; font-weight: 600;
  margin-bottom: 6px;
}
.field label .req { color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { resize: vertical; min-height: 88px; }
.input-error { border-color: var(--danger) !important; }
.help { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.error-text { font-size: .85rem; color: var(--danger); margin-top: 4px; }

/* password field with eye toggle */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--text-muted);
  padding: 8px; cursor: pointer; font-size: 1.05rem;
}

/* checklist (PE-010 password rules) */
.pw-rules { list-style: none; padding: 0; margin: 10px 0 0; }
.pw-rules li { font-size: .85rem; color: var(--text-muted); padding: 3px 0 3px 26px; position: relative; }
.pw-rules li::before {
  content: "○"; position: absolute; left: 4px; color: var(--border);
}
.pw-rules li.ok { color: var(--success); }
.pw-rules li.ok::before { content: "✓"; color: var(--success); }

/* pill / chip multi-select */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff;
  font-size: .875rem; cursor: pointer; user-select: none;
}
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-soft { background: var(--primary-soft); color: var(--primary); border: 0; padding: 4px 10px; font-size: .75rem; border-radius: 999px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-muted   { background: var(--bg); color: var(--text-muted); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

/* ---------- Auth screens (PE-010) ---------- */
.auth-body {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card { width: 100%; max-width: 400px; padding: 28px 24px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 8px; }
.auth-logo img { width: 140px; height: auto; }
.community-member { text-align: center; margin: 12px 0 20px; }
.community-member img {
  width: 108px; height: 108px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--primary-soft);
}
.community-member .cm-name { font-weight: 700; margin-top: 8px; }
.community-member .cm-title { font-size: .8rem; color: var(--text-muted); }
.auth-footer { text-align: center; font-size: .75rem; color: var(--text-muted); margin-top: 18px; }

.status-icon {
  width: 88px; height: 88px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 8px auto 16px; font-size: 2.2rem;
}
.status-icon.success { background: var(--success-soft); color: var(--success); }
.status-icon.locked  { background: var(--primary-soft);  color: var(--primary); }
.status-icon.reset   { background: var(--primary-soft);  color: var(--primary); }

/* ---------- Admin layout (ADM-008 sidebar) ---------- */
.admin-wrap { display: flex; min-height: 100vh; }
.admin-side {
  width: 240px; flex-shrink: 0;
  background: #0B1D4D; color: #C9D4F5;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.admin-side .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; color: #fff; font-weight: 700;
}
.admin-side .brand img { width: 34px; height: 34px; border-radius: 8px; background: #fff; }
.admin-side nav { flex: 1; overflow-y: auto; padding: 8px; }
.admin-side nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 10px;
  color: #C9D4F5; font-size: .925rem; margin-bottom: 2px;
}
.admin-side nav a:hover { background: rgba(255,255,255,.08); }
.admin-side nav a.active { background: var(--primary); color: #fff; }
.admin-side .side-user {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.12);
  font-size: .85rem; color: #fff;
}
.admin-side .side-user .role { font-size: .75rem; color: #8FA3DD; }

.admin-main { flex: 1; padding: 24px; min-width: 0; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-header h1 { margin: 0; font-size: 1.35rem; }

/* stat cards (ADM-002) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat-card .num { font-size: 1.7rem; font-weight: 800; color: var(--text); }
.stat-card .lbl { font-size: .8rem; color: var(--text-muted); }

/* tables */
.table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .925rem; }
table.list th {
  text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-muted); padding: 14px 16px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.list td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.rowlink { cursor: pointer; }
table.list tr.rowlink:hover { background: #FAFBFF; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; flex-shrink: 0;
  object-fit: cover;
}

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .input { max-width: 320px; }

/* form grid for admin forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }
.section-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--primary); margin: 20px 0 12px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.section-title:first-child { margin-top: 0; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 20px;
  border-radius: 999px; font-size: .9rem; box-shadow: var(--shadow-lift);
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 100;
  max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; }

/* mobile admin */
.admin-menu-btn { display: none; }
@media (max-width: 860px) {
  .admin-side {
    position: fixed; left: 0; top: 0; z-index: 50;
    transform: translateX(-100%); transition: transform .2s;
  }
  .admin-side.open { transform: translateX(0); }
  .admin-menu-btn {
    display: inline-flex; border: 1px solid var(--border); background: #fff;
    border-radius: 10px; padding: 9px 12px; cursor: pointer; font-size: 1.1rem;
  }
  .admin-main { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  #side-overlay.open {
    position: fixed; inset: 0; background: rgba(10,16,40,.45); z-index: 40;
  }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
