:root {
  --accent: #1f5fbf;
  --accent-dark: #174a94;
  --accent-light: #eaf1fc;
  --accent-ring: rgba(31, 95, 191, .25);

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cfd6e2;

  --text: #121826;
  --text-muted: #6b7384;
  --text-faint: #99a1b3;

  --danger: #c0372b;
  --danger-bg: #fdeeec;
  --success: #15803d;
  --success-bg: #ecfbf1;
  --warning: #b4580f;
  --warning-bg: #fdf1e6;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(18, 24, 38, .05);
  --shadow-md: 0 8px 24px rgba(18, 24, 38, .07), 0 1px 2px rgba(18, 24, 38, .05);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 15px/1.55 -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
h3 { font-size: 15px; font-weight: 700; margin: 24px 0 10px; color: var(--text); }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }

/* layout */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-weight: 700; font-size: 14.5px; }
.brand-sub { font-size: 12px; color: var(--text-muted); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--accent-light);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.user-name { font-size: 13.5px; font-weight: 600; }

.pill-link {
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-light);
  color: var(--accent-dark);
}
.pill-link:hover { background: #ddeaf9; text-decoration: none; }

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* alerts */

.alerts { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; }
.alert {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
}
.alert-success { border-left-color: var(--success); background: var(--success-bg); color: #0f5c2b; }
.alert-error { border-left-color: var(--danger); background: var(--danger-bg); color: #8f281e; }
.alert-warning { border-left-color: var(--warning); background: var(--warning-bg); color: var(--warning); }

/* card */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}
.card-flush { padding: 0; overflow: hidden; }

/* buttons */

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-alt); text-decoration: none; }
.btn-text {
  background: none; border: none; color: var(--accent); padding: 0; font-weight: 600; cursor: pointer;
}
.btn-text:hover { text-decoration: underline; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* forms */

label { font-size: 13px; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 6px; }

input, select, textarea {
  font: inherit;
  font-size: 14.5px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
textarea { resize: vertical; }
input[type="file"] { padding: 7px 10px; cursor: pointer; }

.field { margin-bottom: 18px; }
.field-error { color: var(--danger); font-size: 13px; margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .field-span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 16px; margin-top: 6px; }

/* toolbar / search */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar input[name="q"] { flex: 1 1 240px; }
.toolbar select { flex: 0 1 220px; }
.toolbar .spacer { margin-left: auto; }
.result-count { font-size: 13.5px; color: var(--text-muted); margin: 0 0 12px; }

/* table */

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; vertical-align: middle; }
thead th {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-faint);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }
.row-name { display: flex; align-items: center; gap: 10px; font-weight: 600; }

/* badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }
.badge-group { background: var(--accent-light); color: var(--accent-dark); }

/* profile / detail */

.profile { display: flex; gap: 28px; flex-wrap: wrap; }
.photo-frame {
  width: 180px;
  height: 220px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  overflow: hidden;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-placeholder { color: var(--text-faint); font-size: 13px; text-align: center; padding: 12px; }

.info-list { display: grid; gap: 14px; margin: 18px 0 20px; }
.info-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: baseline; }
.info-row dt { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-faint); margin: 0; }
.info-row dd { margin: 0; font-size: 15px; }

.doc-card { margin-top: 10px; }
.doc-card img { max-width: 100%; border-radius: var(--radius-md); display: block; }

.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; margin-bottom: 16px; color: var(--text-muted); }
.back-link:hover { color: var(--accent); text-decoration: none; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* auth */

.auth-shell {
  min-height: calc(100vh - 61px);
  display: grid;
  place-items: center;
  padding: 40px 20px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
  text-align: center;
}
.auth-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
}
.auth-card h1 { font-size: 19px; }
.auth-card .muted { margin-bottom: 22px; font-size: 13.5px; }
.auth-card form { text-align: left; }

/* current-files summary on edit form */

.current-files {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.current-files .photo-frame { width: 72px; height: 88px; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .info-row { grid-template-columns: 1fr; gap: 2px; }
  .profile { gap: 18px; }
  .toolbar .spacer { margin-left: 0; width: 100%; }
  .toolbar .spacer .btn { width: 100%; justify-content: center; }
}
