:root {
  --navy: #1e3a5f;
  --navy-dark: #16304f;
  --gold: #c9a227;
  --paper: #f7f6f2;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7683;
  --line: #e3e1da;
  --ok-bg: #e6f4ea; --ok-text: #1e7a3c;
  --err-bg: #fdecea; --err-text: #b3261e;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper); color: var(--text); font-size: 16px; line-height: 1.45;
}
a { color: var(--navy); }
code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; font-size: 0.9em; word-break: break-all; }

/* brand */
.auth-logo { display: block; width: 118px; height: auto; margin: 0 auto 8px; border-radius: 10px; }
.nav-logo { height: 21px; width: auto; border-radius: 4px; background: #fff; padding: 1px; vertical-align: middle; margin-right: 8px; }
.lh-logo { display: block; width: 72px; height: auto; margin: 0 auto 6px; }
.st-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0 14px; }
.st-sigimg { height: 54px; width: auto; display: block; }
.pw-wrap { margin: -6px 0 10px; }
.pw-eye { background: none; border: none; color: #1e3a5f; cursor: pointer; font-size: 12.5px; font-weight: 600; padding: 2px 0; }
.pw-eye:hover { text-decoration: underline; }
.sort-hd { color: inherit; text-decoration: none; }
.sort-hd:hover { text-decoration: underline; }
.sort-hd.on { color: #1e3a5f; text-decoration: underline; }
.chip button.rm { border: 0; background: none; color: inherit; font: inherit; font-weight: 700; cursor: pointer; padding: 0 0 0 2px; }

/* nav */
.topnav {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--navy); color: #fff; padding: 10px 16px;
  position: sticky; top: 0; z-index: 10;
}
.nav-brand { font-weight: 700; letter-spacing: 0.3px; }
.nav-sub { color: var(--gold); font-weight: 500; font-size: 0.85em; }
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav-links a {
  color: #d9e2ec; text-decoration: none; padding: 7px 11px; border-radius: 8px; font-size: 0.95em;
}
.nav-links a.active, .nav-links a:hover { background: var(--navy-dark); color: #fff; }
.nav-logout { margin-left: auto; }

/* layout */
.container { max-width: 1080px; margin: 20px auto; padding: 0 16px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 10px 0 16px; }
.page-head h1 { margin: 0; font-size: 1.5rem; }
h1 { font-size: 1.4rem; margin: 8px 0; }
h2.section-title { margin: 28px 0 12px; font-size: 1.15rem; border-bottom: 2px solid var(--line); padding-bottom: 6px; }
.back-link { display: inline-block; margin: 4px 0 10px; text-decoration: none; color: var(--muted); font-size: 0.92em; }
.back-link:hover { color: var(--navy); }

/* cards & grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; text-decoration: none; color: var(--text); display: block;
  transition: box-shadow .15s ease;
}
a.card:hover { box-shadow: 0 3px 10px rgba(20, 35, 60, 0.12); }
.card-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.card-name { font-weight: 650; }
.card-line { font-size: 0.92em; margin-top: 2px; }

/* avatar */
.avatar { border-radius: 50%; object-fit: cover; display: inline-block; vertical-align: middle; }
.avatar-initials {
  background: var(--navy); color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; letter-spacing: 0.5px; flex: none;
}

/* panels, forms */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 14px 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
label { display: block; font-weight: 600; font-size: 0.9em; margin: 8px 0 2px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 6px 0; }
input, select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; margin-top: 3px;
}
label.check input { width: auto; margin: 0; }
input[type="search"] { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 4px 14px; }
.form-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 140px; }
.form-row button { flex: none; margin-bottom: 4px; }
.privacy-set { border: 1px dashed var(--line); border-radius: 10px; margin: 14px 0; padding: 10px 14px; }
.privacy-set legend { font-weight: 700; font-size: 0.9em; padding: 0 6px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; }
.photo-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.photo-form input[type="file"] { flex: 1; min-width: 180px; margin: 0; }

/* buttons */
.btn {
  display: inline-block; border: 1px solid transparent; border-radius: 9px; cursor: pointer;
  padding: 9px 15px; font: inherit; font-weight: 600; text-decoration: none; font-size: 0.93em;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-secondary { background: #eef1f4; color: var(--text); }
.btn-secondary:hover { background: #e2e7ec; }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-sm { padding: 5px 10px; font-size: 0.85em; }
.btn-block { width: 100%; }

/* filter bar */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 1; max-width: 560px; }
.filter-bar input[type="search"] { flex: 2; min-width: 160px; margin: 0; }
.filter-bar select { flex: 1; min-width: 130px; margin: 0; width: auto; }
label.inline { display: flex; align-items: center; gap: 6px; margin: 0; }
label.inline input { width: 5em; margin: 0; }

/* profile */
.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 8px 0 14px; }
.profile-head h1 { margin: 0; }
.info-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f0efe9; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--muted); font-weight: 600; font-size: 0.9em; }
.prewrap { white-space: pre-wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { background: #eef1f4; border-radius: 999px; padding: 4px 12px; font-size: 0.85em; text-decoration: none; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.chip-x { display: inline; }
.chip-x button { border: none; background: none; cursor: pointer; font-size: 1.1em; color: var(--muted); padding: 0 2px; }
.badge { background: var(--gold); color: #fff; border-radius: 999px; padding: 3px 10px; font-size: 0.78em; font-weight: 700; }

/* tables */
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #f0efe9; font-size: 0.94em; }
.table th { background: #eef1f4; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* alerts, auth */
.alert { border-radius: 10px; padding: 11px 14px; margin: 12px 0; font-size: 0.94em; }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }
.alert-error { background: var(--err-bg); color: var(--err-text); }
.auth-card { max-width: 380px; margin: 7vh auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.auth-title { margin: 0; text-align: center; color: var(--navy); }
.auth-sub { text-align: center; color: var(--muted); margin: 4px 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 0.86em; }
.center { text-align: center; }
.welcome { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.welcome h2 { margin: 0 0 6px; }
.main-footer { text-align: center; color: var(--muted); font-size: 0.8em; margin-top: 40px; }

/* calendar */
.cal-row { display: flex; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.cal-when { min-width: 118px; flex-shrink: 0; }
.cal-day { font-weight: 600; }
.cal-time { color: var(--muted); font-size: 0.85em; }
.cal-title { font-weight: 600; }
.inline-form { display: inline; }

/* responsive */
@media (max-width: 640px) {
  .container { margin-top: 10px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .info-row { grid-template-columns: 100px 1fr; }
  .form-row { flex-direction: column; align-items: stretch; }
}
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } }
