/* EMTA Dashboard — design system
   Palette: deep indigo primary, teal accent, warm neutrals. */
:root {
  /* Aligned with the EMTA bulletin generator: green + navy + Inter. */
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e0e0e0;
  --text: #1c2331;
  --text-soft: #565e6b;
  --text-faint: #6f7785;
  --primary: #0b6e35;
  --primary-600: #0a5f2e;
  --primary-050: #e6f4ec;
  --navy: #1c2331;
  --accent: #0b6e35;
  --accent-050: #e6f4ec;
  --danger: #dc2626;
  --warn: #b45309;
  --ok: #0b6e35;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .10);
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }

/* ---- app shell ---- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(185deg, #232b3d 0%, #1c2331 100%);
  color: #aab2c0; padding: 22px 16px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
/* Full-bleed dark-green header band (matches the logo's own green so the mark blends in). */
.brand {
  position: relative; margin: -22px -16px 10px; padding: 20px 16px; background: #167e40;
  display: flex; justify-content: center; align-items: center;
}
.brand .brand-logo { height: 34px; width: auto; display: block; }
.nav-close {
  display: none; position: absolute; top: 50%; right: 10px; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 8px; border: none; cursor: pointer;
  background: rgba(255, 255, 255, .16); color: #fff; place-items: center;
}
.nav-close:hover { background: rgba(255, 255, 255, .28); }
.nav-close svg { width: 18px; height: 18px; }
.brand-caption {
  font-size: 11px; color: #7e8696; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; padding: 0 8px 16px;
}
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 8px;
  color: #b6bdc9; font-weight: 500; transition: background .12s, color .12s;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; padding: 16px 12px 6px; }
.sidebar .spacer { flex: 1; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 28px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .page-title { font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-toggle {
  display: none; background: transparent; border: none; cursor: pointer; color: var(--text-soft);
  width: 40px; height: 40px; border-radius: 8px; place-items: center; margin-left: -8px; flex: none;
}
.nav-toggle:hover { background: var(--surface-2); color: var(--text); }
.nav-toggle svg { width: 22px; height: 22px; }
.nav-overlay { display: none; }
.user { display: flex; align-items: center; gap: 12px; color: var(--text-soft); font-size: 14px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-050);
  color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.content { padding: 28px; max-width: 1100px; width: 100%; }

/* ---- cards / surfaces ---- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px 24px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.page-head p { color: var(--text-soft); margin: 6px 0 0; }

/* ---- forms ---- */
label { font-size: 13px; font-weight: 600; color: var(--text-soft); display: block; margin-bottom: 6px; }
.input, select, input[type=text], input[type=email], input[type=search], input[type=password] {
  width: 100%; padding: 10px 13px; font-size: 14px; font-family: var(--font);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, select:focus, input:focus {
  outline: none; border-color: var(--primary-600); box-shadow: 0 0 0 3px var(--primary-050);
}
.field { margin-bottom: 16px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 180px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; font-size: 14px;
  font-weight: 600; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  background: var(--primary); color: #fff; transition: background .12s, box-shadow .12s; font-family: var(--font);
}
.btn:hover { background: var(--primary-600); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--primary); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--text-soft); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-sm { padding: 7px 13px; font-size: 13px; }

/* ---- segmented control ---- */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 4px; gap: 4px; }
.seg button {
  border: 0; background: transparent; padding: 8px 16px; border-radius: 7px; font-weight: 600;
  font-size: 14px; color: var(--text-soft); cursor: pointer; font-family: var(--font);
}
.seg button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }

/* ---- badges / pills ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-soft);
}
.badge.org { background: var(--primary-050); color: var(--primary); }
.badge.ind { background: #eef1f4; color: var(--navy); }
.badge.member { background: #e7f5ee; color: var(--ok); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
/* Category tag colors (shared by orgs & individuals) for at-a-glance distinction. */
.badge.cat-active    { background: #e6f4ec; color: #0b6e35; }   /* green  — Active / Members */
.badge.cat-prospect  { background: #fdf1dc; color: #b45309; }   /* amber  — Prospect */
.badge.cat-nonmember { background: #eef1f5; color: #475569; }   /* slate  — Non-Member(s) */
.badge.cat-pending   { background: #fdeede; color: #b45309; }   /* amber  — Pending approval */

/* ---- results list ---- */
.results { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.result {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: border-color .12s, box-shadow .12s; cursor: pointer;
}
.result:hover { border-color: var(--primary-600); box-shadow: var(--shadow-md); text-decoration: none; }
.result .r-main { min-width: 0; flex: 1; }
.result .r-name { font-weight: 650; color: var(--text); }
.result .r-meta { font-size: 13px; color: var(--text-faint); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .r-icon { width: 40px; height: 40px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--surface-2); color: var(--text-soft); }
.result .chev { color: var(--text-faint); flex: none; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }
.pager:empty { display: none; }
.pager-info { font-size: 13px; color: var(--text-soft); font-weight: 600; }

.muted { color: var(--text-faint); }
.empty { text-align: center; color: var(--text-faint); padding: 46px 20px; }
.empty svg { opacity: .4; margin-bottom: 10px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner { padding: 11px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.banner.info { background: var(--primary-050); color: var(--primary); }
.banner.warn { background: #fbf2e3; color: var(--warn); }
.banner.err { background: #fbe9ec; color: var(--danger); }

/* ---- detail view ---- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px 26px; }
.detail-grid .dt { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); font-weight: 600; margin-bottom: 4px; }
.detail-grid .dd { font-size: 15px; color: var(--text); word-break: break-word; }
.detail-section { margin-top: 26px; }
.detail-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* Inline edit: rows that only appear while editing (empty/optional fields), plus field inputs. */
.edit-only { display: none; }
#record-card.editing .edit-only { display: revert; }
.dd-input { width: 100%; font-size: 15px; }
#record-card.editing .dd { margin-top: 2px; }

/* separate section cards on the detail page */
.detail-card { margin-top: 18px; }
.card-title { font-size: 16px; font-weight: 700; color: var(--text); margin: 0 0 16px; display: flex; align-items: center; gap: 10px; }
.card-title .count { font-size: 12.5px; font-weight: 600; color: var(--primary); background: var(--primary-050); border-radius: 999px; padding: 2px 10px; }

/* ---- member / data grid ---- */
.member-grid-wrap { overflow-x: auto; }
.member-grid { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.member-grid th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); font-weight: 700; padding: 9px 14px; border-bottom: 2px solid var(--border); }
.member-grid td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.member-grid td.strong { font-weight: 600; }
.member-grid th.num, .member-grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.member-grid th.col-link, .member-grid td.col-link { text-align: right; white-space: nowrap; }
.member-grid tbody tr[data-href] { cursor: pointer; }
.member-grid tbody tr:hover { background: var(--surface-2); }
.member-grid a { font-weight: 600; }
.member-grid th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.member-grid th.sortable:hover { color: var(--text); }
.member-grid th.sortable .sort-arrow { display: inline-block; width: .8em; margin-left: 4px; opacity: .5; }
.member-grid th.sortable[aria-sort="ascending"] .sort-arrow::after { content: "\2191"; }
.member-grid th.sortable[aria-sort="descending"] .sort-arrow::after { content: "\2193"; }
.member-grid th.sortable[aria-sort="none"]:hover .sort-arrow::after { content: "\2195"; }

/* ---- dashboard tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.tile { padding: 22px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .12s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }
.tile .t-icon { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-050); color: var(--primary); margin-bottom: 14px; }
.tile h3 { font-size: 16px; color: var(--text); }
.tile p { color: var(--text-soft); font-size: 14px; margin: 6px 0 0; }

/* ---- login ---- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e6f4ec 0%, #f3f4f6 55%, #eef0f3 100%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 12px 40px rgba(28, 35, 49, .12); padding: 36px 32px 32px;
  text-align: center; overflow: hidden;
}
/* Full-width dark-green header band (matches the logo's green so the banner blends in). */
.login-brand {
  margin: -36px -32px 0; padding: 26px 32px; background: #167e40;
  display: flex; justify-content: center; align-items: center;
}
.login-logo { width: 100%; max-width: 280px; height: auto; display: block; }
.login-head { margin: 22px 0 26px; }
.login-head h1 { font-size: 20px; font-weight: 700; color: var(--text); }
.login-head p { font-size: 13px; color: var(--text-soft); margin: 6px 0 0; }
.login-btn { width: 100%; justify-content: center; padding: 12px 18px; font-size: 15px; }
.login-btn svg { width: 17px; height: 17px; }
.login-card .banner { text-align: left; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin: 22px 0 18px; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--border); flex: 1; }
.dev-form { text-align: left; }
.dev-form .field { margin-bottom: 12px; }
.login-foot { margin-top: 24px; font-size: 12px; color: var(--text-faint); }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }

  /* Sidebar becomes an off-canvas drawer toggled by the hamburger. */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 264px; height: 100dvh;
    overflow-y: auto; z-index: 60; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: 4px 0 40px rgba(0, 0, 0, .38);
  }
  .sidebar.open { transform: translateX(0); }

  .nav-overlay {
    display: block; position: fixed; inset: 0; background: rgba(15, 20, 30, .5);
    opacity: 0; visibility: hidden; transition: opacity .2s ease; z-index: 55;
  }
  .nav-overlay.show { opacity: 1; visibility: visible; }
  body.nav-open { overflow: hidden; }

  .nav-toggle { display: inline-grid; }
  .nav-close { display: inline-grid; }
  .topbar { padding: 0 14px; }
  .content { padding: 18px 14px; }
  .page-head h1 { font-size: 21px; }
  .user span:not(.avatar) { display: none; }  /* keep the topbar compact on phones */
}

/* ---- dropdown menu (e.g. event Export) ---- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; min-width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 6px; display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a {
  display: block; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 14px;
  font-weight: 500; color: var(--text); white-space: nowrap;
}
.dropdown-menu a:hover { background: var(--surface-2); text-decoration: none; }

/* ---- modal (e.g. org type-change confirmation) ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .45);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md);
  width: 100%; max-width: 560px; max-height: 85vh; overflow: auto; padding: 22px 24px;
}
.modal h3 { font-size: 18px; margin-bottom: 10px; }
.modal .modal-warn {
  background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 13px; margin: 12px 0;
}
.modal .modal-list { max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 12px 0; }
.modal .modal-list table { width: 100%; border-collapse: collapse; font-size: 13px; }
.modal .modal-list th, .modal .modal-list td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.modal .modal-list th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ---- Dashboard: stat widgets + revenue chart ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-grid.mini { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-top: 18px; }
.stat { display: block; padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .12s; }
a.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }
.stat.accent { background: var(--primary-050); border-color: #cfe7d8; }
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: .02em; }
.stat-value { font-size: 30px; font-weight: 800; color: var(--text); margin-top: 6px; line-height: 1.1; }
.stat-value.sm { font-size: 22px; }
.stat.accent .stat-value { color: var(--primary); }
.stat-sub { font-size: 13px; color: var(--text-soft); margin-top: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.trend { font-weight: 700; font-size: 12.5px; }
.trend.up { color: var(--ok); }
.trend.down { color: var(--danger); }

.chart-card { margin-bottom: 4px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.chart-head .card-title { margin: 0; }
.bars { display: flex; align-items: flex-end; gap: 14px; height: 200px; padding-top: 18px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 6px; }
.bar-val { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.bar-track { width: 100%; max-width: 54px; flex: 1; display: flex; align-items: flex-end; }
.bar-fill { width: 100%; min-height: 2px; background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%); border-radius: 6px 6px 0 0; transition: height .3s ease; }
.bar-label { font-size: 12.5px; color: var(--text-soft); font-weight: 600; }

/* Member-capacity utilization widget */
.stat-cap { font-size: 14px; font-weight: 600; color: var(--text-faint); }
.usage-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 8px 0 6px; }
.usage-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary) 0%, var(--primary-600) 100%); transition: width .3s ease; }
