:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1c2431;
  --muted: #6b7684;
  --brand: #123a6b;
  --brand-2: #1e5fae;
  --ok-bg: #e3f6ea; --ok-ink: #1a7a3f;
  --off-bg: #fde7e7; --off-ink: #b12727;
  --border: #e2e6ec;
  --err: #b12727;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header holds branding only — navigation lives in the sidebar, not here. */
.topbar {
  display: flex; align-items: center;
  background: var(--brand); color: #fff;
  /* Fluid padding + brand size: scales smoothly across mobile, laptop, desktop. */
  padding: 0 clamp(16px, 4vw, 24px); min-height: 60px;
}
.brand { color: #fff; font-weight: 700; font-size: clamp(16px, 4.2vw, 18px); white-space: nowrap; }
.brand span { font-weight: 400; opacity: .85; }
.inline { display: inline; margin: 0; }

/* ---- App shell: sidebar navigation + content (authenticated pages) ---- */
.layout { display: flex; align-items: stretch; max-width: 1120px; margin: 0 auto; }
.plain { display: block; }

.sidebar {
  flex: 0 0 220px; width: 220px;
  background: var(--card); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column;
  min-height: calc(100vh - 60px - 71px); /* header + footer */
}
.sidenav { display: flex; flex-direction: column; gap: 4px; }
.sidenav a {
  display: block; padding: 10px 12px; border-radius: 8px;
  color: var(--ink); font-weight: 600; font-size: 15px;
}
.sidenav a:hover { background: #eef3f9; text-decoration: none; }
.sidenav a.active { background: var(--brand-2); color: #fff; }
.sidebar-foot {
  margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}
.sidebar-foot .who { color: var(--muted); font-size: 14px; }
.btn-logout { padding: 8px 14px; }
.content { flex: 1 1 auto; min-width: 0; padding: 28px clamp(16px, 4vw, 32px); }

/* Mobile: sidebar becomes a horizontal nav strip beneath the header. */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar {
    flex: none; width: 100%; min-height: 0;
    flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px 6px;
    border-right: none; border-bottom: 1px solid var(--border); padding: 10px 14px;
  }
  .sidenav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .sidebar-foot {
    margin: 0 0 0 auto; padding-top: 0; border-top: none;
    flex-direction: row; align-items: center; gap: 12px;
  }
  .content { padding: 22px clamp(16px, 4vw, 24px); }
}

.container { max-width: 960px; margin: 32px auto; padding: 0 20px; }
h1 { margin: 0 0 4px; font-size: 26px; }
h2 { font-size: 19px; }
.muted { color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 24px; box-shadow: 0 1px 2px rgba(20,30,50,.04);
}
.auth-card { max-width: 380px; margin: 6vh auto; }
.form-card { max-width: 560px; }

label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 14px; }
.inlinelabel { display: inline; margin: 0; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=url],
select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); border-color: var(--brand-2); }
.checkrow { display: flex; align-items: center; gap: 8px; margin: 12px 0; }
.checkrow input { width: auto; }

.btn {
  display: inline-block; padding: 10px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; text-align: center;
}
.btn-primary { background: var(--brand-2); color: #fff; }
.btn-primary:hover { background: var(--brand); text-decoration: none; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-block { width: 100%; margin-top: 18px; }
.linklike { background: none; border: none; color: var(--brand-2); cursor: pointer; padding: 0; font-size: 14px; }

.flashes { margin-bottom: 18px; }
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; }
.flash-error { background: var(--off-bg); color: var(--off-ink); }
.flash-success { background: var(--ok-bg); color: var(--ok-ink); }
.field-error { color: var(--err); font-size: 13px; display: block; margin-top: 4px; }

.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; }
.app-card h2 { margin: 0 0 6px; }
.app-card .btn { margin-top: 14px; }

.admin-section { margin: 28px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
table.data { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
table.data th { background: #f7f9fc; color: var(--muted); font-weight: 600; }
table.data tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: 12px; align-items: center; }

.pill { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill-off { background: var(--off-bg); color: var(--off-ink); }

.add-inline { display: flex; gap: 10px; margin-top: 16px; }
.add-inline input { flex: 1; }

.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 0; }
