/* Organization admin dashboard (server/orgadmin/). Its own copy of the
   look the other TrityMed dashboards use — nothing here is shared with
   server/admin/, which belongs to Yaebe's own dashboard. */

:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --border: #e4e6ef;
  --text: #14142b;
  --muted: #6e7191;
  --primary: #4d3edb;
  --primary-dark: #372aa8;
  --primary-soft: #eceefb;
  --primary-soft-hover: #dde0f7;
  --danger: #b42318;
  --danger-bg: #fee4e2;
  --pending: #b54708;
  --pending-bg: #fef0c7;
  --approved: #067647;
  --approved-bg: #d1fadf;
  --declined: #b42318;
  --declined-bg: #fee4e2;
  --focus: 0 0 0 3px rgba(77, 62, 219, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

a { color: var(--primary); }

/* --- Buttons and inputs ------------------------------------------------- */

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  padding: 8px 18px;
  border: none;
  cursor: pointer;
}
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--primary-soft); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--primary-soft-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #912018; }
.btn-small { padding: 6px 14px; font-size: 13px; }
.btn-link { background: transparent; color: var(--danger); padding: 6px 10px; font-size: 13px; }
.btn-link:hover:not(:disabled) { background: var(--danger-bg); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field label, .label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea, .input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: inherit;
  background: #fff;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--primary); }
.field .hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.hint.good { color: var(--approved); }
.password-row { display: flex; gap: 8px; }
.password-row input { flex: 1; min-width: 0; }
.password-row button { flex: none; }

.error-text { color: var(--danger); font-size: 13px; margin: 10px 0 0; }
.error-text:empty { display: none; }
.notice { border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin: 0 0 16px; }
.notice.ok { background: var(--approved-bg); color: var(--approved); }
.notice.bad { background: var(--declined-bg); color: var(--declined); }
.notice:empty { display: none; }

/* --- Sign-in ------------------------------------------------------------ */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  width: 100%;
  max-width: 400px;
}
.login-card h1 { font-size: 22px; margin: 14px 0 4px; }
.login-card .subtitle { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.login-card .footnote { color: var(--muted); font-size: 12px; margin: 16px 0 0; }
.logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
}
.own-dashboard {
  background: var(--pending-bg); color: var(--pending);
  border-radius: 10px; padding: 12px 14px; font-size: 13.5px; margin: 0 0 16px;
}
.own-dashboard strong { display: block; margin-bottom: 2px; }

/* --- Shell -------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-text { min-width: 0; }
.brand-name { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { color: var(--muted); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.who { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }

.nav { display: flex; gap: 4px; padding: 0 32px; background: var(--card); border-bottom: 1px solid var(--border); overflow-x: auto; }
.nav a {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 12px 12px 10px; border-bottom: 2px solid transparent; white-space: nowrap;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }
.nav .count {
  display: inline-block; min-width: 20px; padding: 1px 6px; margin-left: 6px;
  border-radius: 999px; background: var(--pending-bg); color: var(--pending);
  font-size: 11px; text-align: center;
}

.container { max-width: 1100px; margin: 0 auto; padding: 28px 32px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { font-size: 26px; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0; font-size: 14px; }

.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filters button { background: var(--primary-soft); color: var(--text); padding: 6px 14px; font-size: 13px; }
.filters button[aria-pressed="true"] { background: var(--primary); color: #fff; }

/* --- Tables ------------------------------------------------------------- */

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 12px; letter-spacing: 0.04em; color: var(--muted);
  text-transform: uppercase; padding: 14px 20px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
td .sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
td.break { word-break: break-word; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
td.nowrap { white-space: nowrap; }
/* Narrow screens scroll the table inside its card rather than crushing the
   columns; the page itself never scrolls sideways. */
.table-wrap table { min-width: 760px; }
.empty-state { padding: 48px 20px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.pending { color: var(--pending); background: var(--pending-bg); }
.badge.approved { color: var(--approved); background: var(--approved-bg); }
.badge.declined, .badge.auto_declined { color: var(--declined); background: var(--declined-bg); }
.badge.role { color: var(--primary); background: var(--primary-soft); }

.role-edit { display: flex; gap: 6px; align-items: center; }
.role-edit select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 13px; background: #fff; }

/* --- Forms in pages ----------------------------------------------------- */

.panel { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 24px; max-width: 480px; }

/* --- Dialogs ------------------------------------------------------------ */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 20, 43, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 480px; padding: 28px;
  max-height: calc(100vh - 32px); overflow-y: auto;
}
.modal h2 { margin: 0 0 8px; font-size: 20px; }
.modal > p, .modal form > p.lead { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.modal dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 18px; font-size: 14px; }
.modal dt { color: var(--muted); }
.modal dd { margin: 0; word-break: break-word; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.modal .secret {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 18px; font-weight: 600;
  background: var(--bg); border-radius: 10px; padding: 12px 14px; word-break: break-all; margin: 0 0 12px;
}

@media (max-width: 720px) {
  .topbar { padding: 12px 16px; }
  .nav { padding: 0 8px; }
  .container { padding: 20px 16px 48px; }
  .login-card { padding: 28px 22px; }
  thead th, tbody td { padding: 12px 14px; }
  .who { display: none; }
}
