:root {
  --blue: #0b4f9c;
  --blue2: #1368c4;
  --nav: #1e2d4d;
  --pale: #eef5fc;
  --ink: #17233a;
  --muted: #68758a;
  --line: #dce5ef;
  --danger: #b42318;
  --ok: #147a4b;
  --warning: #b47d0b;
  --shadow: 0 4px 18px #17345b0b;
}

.site-detail-summary { margin: 0 0 12px; padding:12px 0; border-top:1px solid var(--line); border-bottom:1px solid var(--line); }
.summary-head { display:flex; justify-content:space-between; gap:12px; align-items:center; margin-bottom:8px; }
.summary-head h3 { margin:0; }
.summary-text-grid { display:grid; grid-template-columns:2fr 1fr 1fr 1.5fr; gap:6px 18px; font-size:13px; }
.summary-text-grid p,.summary-notes-text p { margin:3px 0; white-space:pre-wrap; }
.summary-notes-text { display:flex; flex-wrap:wrap; gap:4px 20px; margin-top:4px; font-size:13px; }
.summary-files-line { margin-top:7px; padding-top:7px; border-top:1px dashed var(--line); font-size:13px; }
.compact-file { display:inline-block; margin:2px 10px 2px 0; }
.link-button { appearance:none; border:0; padding:0; background:transparent; color:var(--blue); text-decoration:underline; cursor:pointer; font:inherit; }
.danger-text { color:var(--danger); }
.approval-field-list { display:grid; gap:8px; }
@media (max-width:900px) { .summary-text-grid { grid-template-columns:1fr 1fr; } }

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    Inter,
    Segoe UI,
    Arial,
    sans-serif;
  color: var(--ink);
  background: #f4f7fb;
}

button,
input,
select,
textarea {
  font: inherit;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #062f62, #1671d2);
}

.login-card {
  width: min(420px, 92vw);
  background: white;
  border-radius: 22px;
  padding: 34px;
  box-shadow: 0 25px 70px #001b3d55;
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--blue), #38a1ff);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px;
}

.login-card h1 {
  margin: 18px 0 6px;
}

.login-card p {
  color: var(--muted);
  margin: 0 0 24px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin: 12px 0;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(11, 79, 156, 0.1);
}

input:disabled {
  background: #f0f4f8;
  cursor: not-allowed;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 15px;
  cursor: pointer;
  font-weight: 700;
  background: #e8eef6;
  color: var(--ink);
  text-decoration: none;
  transition: all 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: var(--blue);
  color: white;
}

.btn.primary:hover {
  background: #0a4587;
}

.btn.danger {
  background: #fff0ee;
  color: var(--danger);
}

.btn.danger:hover {
  background: #fde8e6;
}

.btn.small {
  padding: 6px 10px;
  font-size: 12px;
}

.login-card .btn {
  width: 100%;
  margin-top: 12px;
}

.error {
  color: var(--danger);
  margin-top: 12px;
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */

.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.25s ease;
}

.app.sidebar-collapsed {
  grid-template-columns: 78px 1fr;
}

.sidebar {
  background: var(--nav);
  color: white;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.side-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
}

.logo {
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: #fff;
  color: var(--nav);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.logo-text,
.nav-label {
  transition: opacity 0.15s ease;
}

.sidebar-toggle {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: #ffffff14;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.sidebar-toggle:hover {
  background: #ffffff28;
}

.sidebar-toggle svg,
.nav-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app.sidebar-collapsed .logo-text,
.app.sidebar-collapsed .nav-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.app.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.app.sidebar-collapsed .side-top {
  justify-content: center;
  flex-direction: column;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.navbtn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: #d9e8f8;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  min-height: 48px;
  transition: background 0.2s;
}

.navbtn.active,
.navbtn:hover {
  background: #ffffff18;
  color: white;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.app.sidebar-collapsed .navbtn {
  justify-content: center;
  padding: 12px;
}

.main {
  min-width: 0;
}

.topbar {
  height: 68px;
  background: white;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.notification-bell { position: relative; display: grid; place-items: center; flex: none; width: 42px; height: 42px; border: 1px solid #d9e5f2; border-radius: 12px; background: #f3f8fe; color: #164d8d; cursor: pointer; }
.notification-bell:hover { background: #e6f1fd; }
.notification-bell:focus-visible { outline: 3px solid #81b6f1; outline-offset: 2px; }
.notification-bell svg { width: 21px; height: 21px; }
.notification-count { position: absolute; top: -7px; right: -7px; min-width: 19px; height: 19px; padding: 0 4px; display: grid; place-items: center; border-radius: 999px; background: #bf2f2a; color: white; font-size: 10px; font-weight: 800; }
.notification-count[hidden] { display: none; }
.approval-notification-list { display: grid; gap: 10px; margin-top: 17px; max-height: 60vh; overflow: auto; }
.approval-notification-item { display: flex; align-items: center; gap: 13px; padding: 13px 15px; border: 1px solid #dbe7f4; border-radius: 12px; background: #fbfdff; }
.approval-notification-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; background: #e7f1fd; color: #16549b; font-size: 19px; font-weight: 700; }
.approval-notification-copy { flex: 1; min-width: 0; }
.approval-notification-copy strong, .approval-notification-copy span, .approval-notification-copy small { display: block; overflow-wrap: anywhere; }
.approval-notification-copy strong { color: #173b67; font-size: 13px; text-transform: capitalize; }
.approval-notification-copy span, .approval-notification-copy small { margin-top: 3px; color: var(--muted); font-size: 12px; }
@media(max-width:560px) { .approval-notification-item { flex-wrap: wrap; } .approval-notification-item .btn { margin-left: 49px; } }

.content {
  padding: 16px 22px 24px;
}
.section-head { margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 3px 0 0; }
.site-filter-bar { display: grid; grid-template-columns: minmax(260px,2fr) minmax(150px,1fr) minmax(130px,1fr) auto; gap: 10px; align-items: end; margin: 0 0 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbff; }
.site-filter-bar label { margin: 0; font-size: 11px; color: #526b85; text-transform: uppercase; letter-spacing: .04em; }
.site-filter-bar label span { display: block; margin-bottom: 5px; }
.site-filter-bar input, .site-filter-bar select { min-height: 38px; padding: 8px 10px; font-size: 13px; text-transform: none; letter-spacing: normal; }
.site-filter-bar .btn { min-height: 38px; padding: 8px 13px; }

/* ============================================
   CARDS & METRICS
   ============================================ */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}

.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 34px;
  color: var(--blue);
  margin-top: 7px;
}

.metric small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.metric-success strong {
  color: var(--ok);
}

.metric-alert strong {
  color: #b42318;
}

.site-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.site-summary-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 17px;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(31, 66, 104, 0.07);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.site-summary-card:hover,
.site-summary-card:focus-visible {
  transform: translateY(-2px);
  border-color: #8db9e8;
  box-shadow: 0 9px 22px rgba(31, 66, 104, 0.14);
  outline: none;
}

.site-card-health {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--ok);
}

.site-summary-card.warning .site-card-health {
  background: #e49b0f;
}

.site-summary-card.critical .site-card-health {
  background: #d92d20;
}

.site-summary-card.empty .site-card-health {
  background: #9aa9b8;
}

.site-summary-card.empty {
  background: #f8fafc;
}

.site-card-title {
  display: block;
  min-height: 42px;
  color: #102f52;
  font-size: 17px;
  font-weight: 800;
}

.site-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 15px;
}

.site-card-metrics > span {
  padding: 9px 6px;
  border-radius: 9px;
  background: #f3f7fb;
  text-align: center;
}

.site-card-metrics strong,
.site-card-metrics small {
  display: block;
}

.site-card-metrics strong {
  color: var(--blue);
  font-size: 20px;
}

.site-card-metrics small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.site-card-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.site-card-footer strong {
  color: var(--blue);
}

/* ============================================
   SECTIONS
   ============================================ */

.section {
  display: none;
}

.section.active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 0 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.notes-fields {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.notes-fields h3,
.field-heading {
  margin: 0 0 10px;
  color: var(--blue);
  font-weight: 700;
}

.floor-count-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(120px, 180px) auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: end;
}

.notes-version-grid {
  margin-top: 12px;
}

.notes-view h3 {
  margin: 18px 0 6px;
  color: var(--blue);
}

.notes-view p {
  white-space: pre-wrap;
}

@media (max-width: 680px) {
  .floor-count-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   TABLES
   ============================================ */

.table-wrap {
  overflow: auto;
  max-height: 68vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

.import-preview {
  max-height: 58vh;
  margin-top: 12px;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #e8eef5;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #eaf3fd;
  color: #174a80;
  z-index: 1;
}

.table-sort {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.table-sort span {
  display: inline-block;
  min-width: 12px;
  margin-left: 4px;
  color: #7188a2;
  font-size: 10px;
}

.table-sort.active span,
.table-sort:hover,
.table-sort:focus-visible {
  color: #075ca8;
}

tr:hover td {
  background: #f8fbff;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e8f6ef;
  color: var(--ok);
  font-size: 11px;
  font-weight: 800;
  display: inline-block;
}

.badge.warning {
  background: #fef7e0;
  color: var(--warning);
}

.badge.danger {
  background: #fff0ee;
  color: var(--danger);
}

/* ============================================
   MODALS
   ============================================ */

.modal {
  position: fixed;
  inset: 0;
  background: #04162c99;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
  backdrop-filter: blur(4px);
}

.modal.open {
  display: flex;
}

.modal-box {
  width: min(1100px, 98vw);
  max-height: 92vh;
  overflow: auto;
  background: white;
  border-radius: 18px;
  padding: 20px;
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.grid label {
  margin: 0;
}

textarea { display: block; min-height: 110px; resize: vertical; line-height: 1.5; }
.professional-form { gap: 18px 16px; padding: 5px 2px 4px; }
.professional-form label { display: flex; flex-direction: column; gap: 7px; min-width: 0; color: #273b56; line-height: 1.4; }
.professional-form input, .professional-form select, .professional-form textarea { min-width: 0; border-color: #cbd9e9; background: #fff; }
.professional-form input, .professional-form select { min-height: 47px; }
.professional-form textarea { width: 100%; min-height: 104px; padding: 12px 14px; }
.professional-form input::placeholder, .professional-form textarea::placeholder { color: #8391a3; font-weight: 400; }
.professional-form .form-intro { margin: 0; padding: 14px 17px; border: 1px solid #d5e4f4; border-radius: 12px; background: #f2f7fe; color: #3e5874; font-size: 13px; font-weight: 500; }
.professional-form .form-section { display: flex; gap: 13px; align-items: center; padding: 13px 0 11px; border-bottom: 1px solid #dfe8f2; }
.professional-form .form-section>span { display: grid; place-items: center; flex: none; width: 35px; height: 35px; border-radius: 10px; background: #e8f2fd; color: #155299; font-size: 12px; font-weight: 800; }
.professional-form .form-section h3 { margin: 0; color: #173b67; font-size: 16px; }
.professional-form .form-section p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.professional-form .floor-editor { padding: 17px; border: 1px solid #dce8f4; border-radius: 12px; background: #f9fbfe; }
.professional-form .floor-editor .field-heading { margin-bottom: 12px; }
.professional-form .floor-count-row { grid-template-columns: minmax(0,2fr) minmax(125px,1fr) auto; gap: 11px; align-items: end; }
.professional-form .floor-count-row label { font-size: 12px; }
.professional-form .floor-count-row .btn { min-height: 47px; }
.professional-form .toolbar { justify-content: flex-end; padding-top: 16px; border-top: 1px solid var(--line); }
.request-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
.request-form textarea { min-height: 100px; }
.request-form .btn.primary { min-height: 48px; }
@media (max-width: 680px) { .professional-form, .request-form { grid-template-columns: 1fr; } .professional-form .floor-count-row { grid-template-columns: 1fr; } }

.users-table-wrap { max-height: 62vh; }
.users-table { table-layout: fixed; min-width: 900px; }
.users-table th, .users-table td { white-space: normal; vertical-align: middle; padding: 10px 12px; }
.users-table th:nth-child(1) { width: 21%; }
.users-table th:nth-child(2) { width: 10%; }
.users-table th:nth-child(3) { width: 12%; }
.users-table th:nth-child(4) { width: 11%; }
.users-table th:nth-child(5), .users-table th:nth-child(6) { width: 16%; }
.users-table th:nth-child(7) { width: 14%; }
.user-email, .access-preview { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.access-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.access-count { font-weight: 700; color: var(--blue); }
.temporary-access { display: block; margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: #fff7e9; color: #825613; font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.role-pill, .user-state { display: inline-block; border-radius: 999px; padding: 4px 9px; background: #edf3fa; color: #234768; font-size: 12px; font-weight: 700; text-transform: capitalize; }
.user-state.is-active { background: #e5f5ed; color: #136843; }
.user-state.is-inactive { background: #fff0ee; color: #a53a32; }
.user-actions { white-space: normal; }
.user-actions .btn { margin: 2px 3px 2px 0; }
.icon-actions { white-space: nowrap; }
.icon-action { display: inline-grid; place-items: center; width: 34px; height: 34px; margin: 2px; border: 1px solid #d7e4f4; border-radius: 10px; background: #edf4ff; color: #16518e; cursor: pointer; vertical-align: middle; transition: background .15s, transform .15s; }
.icon-action:hover { background: #dcecff; transform: translateY(-1px); }
.icon-action:focus-visible { outline: 3px solid #77aef5; outline-offset: 2px; }
.icon-action.danger { background: #fff1f0; color: #ab332b; border-color: #ffdcd8; }
.icon-action.danger:hover { background: #ffe1de; }
.icon-action svg { width: 18px; height: 18px; }
.activity-profile { display: flex; align-items: center; gap: 14px; padding: 5px 0 16px; }
.activity-profile strong, .activity-profile span, .activity-profile small { display: block; }
.activity-profile span, .activity-profile small { margin-top: 3px; color: var(--muted); }
.activity-avatar, .profile-avatar { display: grid; place-items: center; flex: none; width: 54px; height: 54px; border-radius: 16px; background: #174f91; color: white; font-size: 24px; font-weight: 700; }
.activity-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin-bottom: 12px; }
.activity-metrics>div { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f7fbff; }
.activity-metrics strong, .activity-metrics span { display: block; }
.activity-metrics strong { font-size: 23px; color: #16518e; }
.activity-metrics span { font-size: 12px; color: var(--muted); }
.activity-table { max-height: 340px; margin-top: 14px; }
.profile-layout { display: grid; grid-template-columns: minmax(240px,300px) minmax(0,1fr); gap: 18px; max-width: 1180px; margin: 28px auto; align-items: start; }
.profile-identity { padding: 28px; }
.profile-avatar { width: 68px; height: 68px; border-radius: 50%; margin-bottom: 18px; font-size: 30px; }
.profile-identity h2 { margin: 0 0 4px; overflow-wrap: anywhere; }
.profile-identity p { color: var(--muted); text-transform: capitalize; margin: 0 0 22px; }
.profile-detail { padding: 12px 0; border-top: 1px solid var(--line); }
.profile-detail span, .profile-detail strong { display: block; }
.profile-detail span { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.profile-detail strong { overflow-wrap: anywhere; font-size: 13px; }
.profile-main { display: grid; gap: 16px; }
.profile-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.profile-summary .card { padding: 18px; }
.profile-summary strong, .profile-summary span { display: block; }
.profile-summary strong { font-size: 25px; color: #16518e; }
.profile-summary span { font-size: 12px; color: var(--muted); }
.profile-card { padding: 23px; }
.profile-card h3 { margin: 0 0 6px; }
.profile-card p { margin: 0 0 16px; }
.profile-password-form { display: grid; gap: 11px; max-width: 440px; }
.backup-code-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 15px; background: #f5f9fe; border-radius: 12px; }
@media(max-width:850px) { .profile-layout { grid-template-columns: 1fr; } }

.user-form { gap: 14px; }
.password-guidance { padding: 12px 14px; border: 1px solid #cfe0f3; border-radius: 10px; background: #f2f7fe; color: #21466d; font-size: 13px; line-height: 1.55; }
.user-access-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.access-picker { min-width: 0; border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: #f8fbff; }
.access-picker-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 9px; }
.access-picker-head strong { color: var(--blue); }
.access-picker-count { font-size: 12px; font-weight: 700; color: #174a80; background: #e5f0ff; border-radius: 999px; padding: 4px 9px; white-space: nowrap; }
.access-picker-search { width: 100%; margin-bottom: 8px; }
.access-picker-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 9px; }
.access-picker-tools button { border: 0; padding: 2px 0; background: transparent; color: #14539b; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.access-picker-tools button:hover { text-decoration: underline; }
.access-picker-list { height: 210px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: white; }
.access-picker-item { display: flex !important; align-items: flex-start; gap: 10px; padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #edf2f8; font-weight: 500; }
.access-picker-item:last-child { border-bottom: 0; }
.access-picker-item:hover, .access-picker-item:has(input:checked) { background: #ecf5ff; }
.access-picker-item input { width: 17px; height: 17px; flex: none; margin: 1px 0 0; accent-color: #14539b; }
.access-picker-item span { overflow-wrap: anywhere; }
.access-picker-item[hidden] { display: none !important; }
.access-picker-help { display: block; margin-top: 8px; color: var(--muted); }
@media (max-width: 740px) { .user-access-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .site-filter-bar { grid-template-columns: 1fr 1fr; } .site-filter-bar .site-search-field { grid-column: 1/-1; } }

.wide {
  grid-column: 1/-1;
}

.close {
  font-size: 28px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0 8px;
  line-height: 1;
}

.close:hover {
  color: var(--ink);
}

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

/* ============================================
   IMPORT PREVIEW
   ============================================ */

.preview-summary {
  display: flex;
  gap: 12px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.pill {
  background: var(--pale);
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.site-link {
  color: var(--blue);
  font-weight: 800;
  cursor: pointer;
}

.site-link:hover {
  text-decoration: underline;
}

.custom-column-row {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(140px, 1fr) minmax(190px, 2fr) auto auto auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
}
.columns-workspace { padding: 20px; }
.columns-workspace .section-head.compact { align-items: center; margin-bottom: 15px; }
.columns-workspace .section-head.compact h3 { margin: 0; color: #173b67; }
.columns-workspace .section-head.compact p { font-size: 12px; }
.section-kicker { display: block; color: #1c61a4; font-size: 10px; font-weight: 800; letter-spacing: .12em; margin-bottom: 4px; }
.columns-subheading { margin: 20px 0 8px; color: #173b67; font-size: 15px; }

.check-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  cursor: pointer;
}

.check-option input {
  width: 17px;
  height: 17px;
  margin: 0;
}

.select-all-option {
  font-weight: 800;
  color: var(--blue);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.site-check-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px 12px; max-height: 360px; overflow-y: auto; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbff; }
.column-site-filter { display: grid; grid-template-columns: minmax(220px,2fr) minmax(160px,1fr) auto; gap: 10px; align-items: end; margin: 10px 0; }
.column-site-filter label { margin: 0; color: #526b85; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.column-site-filter label span { display: block; margin-bottom: 5px; }
.column-site-filter input, .column-site-filter select { min-height: 38px; padding: 8px 10px; font-size: 13px; text-transform: none; letter-spacing: normal; }
.column-site-filter .btn { min-height: 38px; }
.site-check-grid .site-column-option { display: grid !important; grid-template-columns: 18px minmax(0,1fr); align-items: center; gap: 9px; min-height: 38px; margin: 0; padding: 7px 10px; border: 1px solid #e0e9f2; border-radius: 8px; background: #fff; font-size: 12px; font-weight: 600; }
.site-check-grid .site-column-option:hover { border-color: #99bfe7; background: #f1f7fe; }
.site-check-grid .site-column-option input { width: 17px; height: 17px; min-height: 0; flex: none; accent-color: var(--blue); }
.site-check-grid .site-column-option span { min-width: 0; overflow-wrap: anywhere; }
@media(max-width:650px) { .site-check-grid { grid-template-columns: 1fr; } }
@media(max-width:650px) { .column-site-filter { grid-template-columns: 1fr 1fr; } .column-site-filter label:first-child { grid-column: 1/-1; } }

.checkbox-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #e2e9f1;
  border-radius: 9px;
  background: #f9fbfd;
  cursor: pointer;
  font-weight: 600;
}

.checkbox-card:hover { border-color: #9fc1e8; background:#f1f7fd; }
.checkbox-card input[type="checkbox"] { width:17px; height:17px; min-height:0; margin:0; flex:0 0 auto; }
.checkbox-card span { min-width:0; line-height:1.3; }
.entry-link-sites { grid-template-columns:repeat(3,minmax(0,1fr)); max-height:310px; overflow:auto; }
.entry-link-toolbar { justify-content: space-between; align-items: center; margin: 15px 0; }
.entry-link-list { display: grid; gap: 12px; max-height: 62vh; overflow: auto; padding: 2px 4px 8px 0; }
.entry-link-row { position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px 18px; padding: 16px 18px; border: 1px solid #d9e5f2; border-radius: 14px; background: #fff; box-shadow: 0 3px 11px rgba(21,65,111,.055); }
.entry-link-main { display: flex; gap: 10px; align-items: center; min-width: 0; }
.entry-link-main strong { color: #173b67; overflow-wrap: anywhere; }
.entry-link-details { grid-column: 1; display: grid; grid-template-columns: minmax(120px,1fr) minmax(190px,2fr) repeat(2,minmax(105px,1fr)); gap: 10px 16px; }
.entry-link-details div { min-width: 0; }
.entry-link-details small, .entry-link-details span { display: block; }
.entry-link-details small { margin-bottom: 4px; color: #697d93; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.entry-link-details span { overflow-wrap: anywhere; font-size: 12px; }
.entry-link-actions { grid-column: 2; grid-row: 1 / 3; display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 100px; }
.entry-link-empty { padding: 28px; border: 1px dashed #c7d9ed; border-radius: 12px; color: var(--muted); text-align: center; }
@media(max-width:800px) { .entry-link-details { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media(max-width:560px) { .entry-link-row { grid-template-columns: 1fr; } .entry-link-actions { grid-column: 1; grid-row: auto; justify-content: flex-start; max-width: none; border-top: 1px solid var(--line); padding-top: 8px; } .entry-link-details { grid-template-columns: 1fr; } }
@media (max-width:900px) { .entry-link-sites { grid-template-columns:1fr 1fr; } }
@media (max-width:600px) { .entry-link-sites { grid-template-columns:1fr; } }

@media (max-width: 1100px) {
  .custom-column-row {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

.import-message {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eef5fc;
  color: #174a80;
  font-weight: 700;
}
.import-intro { grid-column: 1/-1; padding: 14px 17px; border: 1px solid #d5e4f4; border-radius: 12px; background: #f2f7fe; }
.import-intro h3 { margin: 2px 0 4px; color: #173b67; }
.import-intro p { margin: 0; color: #536b84; font-size: 13px; line-height: 1.5; }

.import-message.success {
  background: #e8f6ef;
  color: var(--ok);
}

.import-message.error {
  background: #fff0ee;
  color: var(--danger);
}

/* ============================================
   TOAST
   ============================================ */

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #17345b;
  color: white;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 10px 30px #0003;
  opacity: 0;
  transform: translateY(15px);
  pointer-events: none;
  transition: 0.2s;
  z-index: 100;
  max-width: 500px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--ok);
}

/* ============================================
   ROLE-BASED HIDING
   ============================================ */

.role-user .admin-only,
.role-admin .super-only,
.role-user .super-only {
  display: none !important;
}
.room-edit-only { display:none; }
.can-edit-rooms .room-edit-only { display:inline-flex; }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 850px) {
  .app,
  .app.sidebar-collapsed {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
    display: flex;
    overflow: auto;
    padding: 10px;
  }
  .side-top {
    margin: 0 10px 0 0;
  }
  .logo-text,
  .sidebar-toggle {
    display: none;
  }
  .nav-list {
    flex-direction: row;
  }
  .navbtn {
    width: auto;
    white-space: nowrap;
  }
  .cards,
  .grid {
    grid-template-columns: 1fr;
  }
  .content {
    padding: 14px;
  }
  .topbar {
    padding: 0 14px;
    height: 60px;
  }
}

@media (max-width: 1000px) {
  .device-fields {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 650px) {
  .device-fields {
    grid-template-columns: 1fr;
  }
  .modal-box {
    padding: 14px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar {
    flex-wrap: wrap;
  }
  .table-wrap {
    max-height: 50vh;
  }
  .login-card {
    padding: 24px;
  }
}

/* ============================================
   ROOM AND MULTIPLE-TV VIEW
   ============================================ */

.logo-mark {
  width: 44px;
  font-size: 12px;
  letter-spacing: 0.3px;
}

.icon-button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--blue);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-button:hover {
  background: var(--pale);
}

.room-summary-row {
  background: white;
}

.room-summary-row:hover {
  background: #f7fbff;
}

.device-detail-row > td {
  padding: 0;
  background: #f3f7fc;
}

.device-detail-panel {
  padding: 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.device-detail-panel h4 {
  margin: 0 0 12px;
}

.nested-table {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.modal.modal-wide .modal-box {
  width: min(1180px, 96vw);
  max-height: 92vh;
}

.modal-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.modal-section:first-child {
  padding-top: 0;
}

.modal-section h3 {
  margin: 0 0 5px;
}

.section-head.compact {
  margin-bottom: 12px;
}

.device-editor {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  background: #f8fbff;
}

.device-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.device-fields {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.form-help,
.import-rules {
  border: 1px solid #cddff2;
  background: #f2f8ff;
  color: #315270;
  border-radius: 10px;
  padding: 12px;
  line-height: 1.5;
}

.import-rules {
  margin: 12px 0;
}

.import-rules ul {
  margin: 8px 0 0 20px;
  padding: 0;
}

.status-new {
  background: #e8f6ef;
  color: var(--ok);
}

.status-update {
  background: #eef5fc;
  color: var(--blue);
}

.status-reject,
.status-error {
  background: #fff0ee;
  color: var(--danger);
}

.preview-reject,
.preview-error {
  background: #fff7f6;
}

.preview-update {
  background: #f5f9ff;
}

.sticky-save {
  position: sticky;
  bottom: 0;
  margin-top: 14px;
  box-shadow: 0 -8px 20px #ffffffdd;
}

/* ============================================
   NEW: 2FA MODAL STYLES
   ============================================ */

#twoFAModal .modal-box {
  max-width: 420px;
  width: 90%;
  text-align: center;
}

#twoFAModal input[name="code"] {
  text-align: center;
  font-size: 20px;
  letter-spacing: 4px;
  padding: 14px;
}

#twoFAModal input[name="backupCode"] {
  text-align: center;
  font-size: 16px;
  letter-spacing: 2px;
}

#twoFAModal hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

/* ============================================
   NEW: SETUP PASSWORD PAGE
   ============================================ */

#setupPasswordPage,
#twoFASetupPage {
  display: none;
  min-height: 100vh;
  place-items: center;
  background: linear-gradient(135deg, #062f62, #1671d2);
}

#setupPasswordPage .login-card,
#twoFASetupPage .login-card {
  max-width: 500px;
}

#setupPasswordPage input[disabled] {
  background: #f0f4f8;
  cursor: not-allowed;
}

/* ============================================
   NEW: PROFILE SECTION
   ============================================ */

#profile .card {
  max-width: 600px;
  margin: 0 auto;
}

#profile hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

#profile h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
}

#profile .badge {
  font-size: 13px;
  padding: 6px 12px;
}

#changePasswordForm {
  display: grid;
  gap: 10px;
  max-width: 400px;
}

#changePasswordForm label {
  margin: 0;
}

#profile2FAActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ============================================
   NEW: 2FA SETUP MODAL
   ============================================ */

#twoFASetupModal .modal-box {
  max-width: 500px;
  width: 90%;
}

#twoFASetupModal img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

#twoFASetupModal .pill {
  font-family: monospace;
  font-size: 16px;
  padding: 8px 16px;
  margin: 4px;
  display: inline-block;
}

/* ============================================
   NEW: 2FA STATUS INDICATOR IN TOPBAR
   ============================================ */

#twoFAStatus {
  display: none;
  font-size: 12px;
  padding: 4px 10px;
}

/* ============================================
   NEW: DUPLICATE HANDLING SELECT IN IMPORT
   ============================================ */

select[name="duplicate_handling"] {
  appearance: auto;
  cursor: pointer;
}

/* ============================================
   NEW: BACKUP CODES DISPLAY
   ============================================ */

.backup-codes-container {
  background: #f8fbff;
  padding: 20px;
  border-radius: 12px;
  margin: 12px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.backup-codes-container .pill {
  font-family: monospace;
  font-size: 18px;
  padding: 8px 16px;
  background: white;
  border: 1px solid var(--line);
}

/* ============================================
   NEW: TOOLTIP FOR 2FA STATUS
   ============================================ */

[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--nav);
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 10;
}

/* ============================================
   NEW: ANIMATIONS
   ============================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

.slide-down {
  animation: slideDown 0.3s ease;
}

/* ============================================
   NEW: PRINT STYLES
   ============================================ */

@media print {
  .sidebar,
  .topbar,
  .toolbar,
  .actions,
  .btn {
    display: none !important;
  }
  
  .app {
    grid-template-columns: 1fr !important;
  }
  
  .table-wrap {
    max-height: none !important;
    overflow: visible !important;
  }
  
  th {
    background: #eaf3fd !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
