:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --sidebar: #101827;
  --sidebar-soft: #1c2637;
  --sidebar-text: #e5e7eb;
  --sidebar-muted: #8f9bad;
  --text: #172033;
  --muted: #6b7280;
  --border: #e3e8ef;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --shadow: 0 12px 35px rgba(15, 23, 42, 0.08);
  --sidebar-width: 270px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(245, 158, 11, 0.16), transparent 34%),
    linear-gradient(135deg, #0f172a 0%, #182235 58%, #111827 100%);
}

.login-card {
  width: min(100%, 430px);
  padding: 38px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--accent);
  color: #111827;
  font-size: 27px;
  font-weight: 900;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 20px;
}

.login-heading {
  margin: 28px 0;
}

.eyebrow,
.topbar-eyebrow,
.nav-label {
  display: block;
  font-size: 11px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow,
.topbar-eyebrow {
  color: var(--accent-dark);
}

.login-heading h1 {
  margin: 8px 0 8px;
  font-size: 30px;
}

.login-heading p,
.page-heading p,
.placeholder-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

label {
  display: block;
  margin: 16px 0 7px;
  font-size: 13px;
  font-weight: 700;
  color: #374151;
}

input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid #d6dce5;
  border-radius: 10px;
  outline: none;
  background: white;
  color: var(--text);
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.14);
}

.button {
  min-height: 42px;
  padding: 0 17px;
  border: 0;
  border-radius: 10px;
  font-weight: 750;
}

.button.primary {
  background: var(--accent);
  color: #111827;
}

.button.primary:hover {
  background: #fbbf24;
}

.button.secondary {
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
}

.button.full {
  width: 100%;
  margin-top: 22px;
}

.form-message {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-text);
}

.sidebar-brand {
  min-height: 78px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand strong {
  font-size: 17px;
}

.sidebar-brand span {
  margin-top: 3px;
  color: var(--sidebar-muted);
  font-size: 12px;
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 24px;
}

.nav-section + .nav-section {
  margin-top: 22px;
}

.nav-label {
  padding: 0 10px 8px;
  color: #69778c;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #bac4d2;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.nav-item.active {
  background: var(--sidebar-soft);
  color: white;
}

.nav-item.active .nav-icon {
  color: var(--accent);
}

.nav-icon {
  width: 18px;
  color: #7d8aa0;
  text-align: center;
}

.sidebar-user {
  min-height: 76px;
  padding: 14px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #111827;
  font-weight: 900;
}

.sidebar-user-details {
  min-width: 0;
  flex: 1;
}

.sidebar-user-details strong,
.sidebar-user-details span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-details strong {
  font-size: 13px;
}

.sidebar-user-details span {
  margin-top: 3px;
  color: var(--sidebar-muted);
  font-size: 11px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-text);
}

.workspace {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  min-height: 78px;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.topbar h2 {
  margin: 5px 0 0;
  font-size: 20px;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

.topbar-user {
  text-align: right;
}

.topbar-user strong,
.topbar-user span {
  display: block;
}

.topbar-user strong {
  font-size: 13px;
}

.topbar-user span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.status-pill.neutral {
  background: #eef2f7;
  color: #64748b;
}

.status-pill.ok {
  background: #dcfce7;
  color: #166534;
}

.status-pill.error {
  background: #fee2e2;
  color: #991b1b;
}

.mobile-menu-button {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: white;
}

.content {
  padding: 28px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-heading {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.page-heading h1 {
  margin: 0 0 6px;
  font-size: 27px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card,
.panel,
.placeholder-card {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 20px;
  border-radius: 14px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.stat-card strong {
  display: block;
  margin: 10px 0 5px;
  font-size: 30px;
}

.stat-meta {
  color: #8490a1;
  font-size: 12px;
}

.dashboard-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  min-height: 260px;
  padding: 20px;
  border-radius: 14px;
}

.panel-heading {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.panel-heading h3 {
  margin: 6px 0 0;
  font-size: 18px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-weight: 750;
}

.list-state {
  color: var(--muted);
  font-size: 14px;
}

.preview-row {
  padding: 12px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
}

.preview-row:first-child {
  border-top: 0;
}

.preview-main {
  min-width: 0;
  flex: 1;
}

.preview-main strong,
.preview-main span {
  display: block;
}

.preview-main strong {
  color: var(--text);
  font-size: 13px;
}

.preview-main span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.mini-status {
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #64748b;
  font-size: 11px;
  font-weight: 750;
}

.mini-status.active,
.mini-status.ok,
.mini-status.healthy {
  background: #dcfce7;
  color: #166534;
}

.mini-status.suspended,
.mini-status.warning {
  background: #fef3c7;
  color: #92400e;
}

.mini-status.archived,
.mini-status.error {
  background: #fee2e2;
  color: #991b1b;
}

.inline-message {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 13px;
}

.placeholder-card {
  min-height: 420px;
  padding: 48px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 16px;
  text-align: center;
}

.placeholder-card h1 {
  margin: 10px 0;
  font-size: 30px;
}

.placeholder-card p {
  max-width: 600px;
}

.coming-soon {
  margin-top: 20px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 12px;
  font-weight: 800;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 850px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(15, 23, 42, 0.55);
  }

  .sidebar-backdrop.visible {
    display: block;
  }

  .workspace {
    margin-left: 0;
  }

  .mobile-menu-button {
    display: block;
  }

  .topbar-user {
    display: none;
  }
}

@media (max-width: 680px) {
  .content {
    padding: 18px;
  }

  .topbar {
    padding: 12px 18px;
  }

  .status-pill {
    display: none;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .stat-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 28px 22px;
  }

  .placeholder-card {
    min-height: 340px;
    padding: 28px 20px;
  }
}

/* ===== Organizations Management ===== */

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.management-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.management-toolbar {
  padding: 18px 20px;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}

.management-toolbar label {
  margin-top: 0;
}

.search-control {
  width: min(100%, 420px);
}

.filter-control {
  width: 190px;
}

.management-toolbar input,
.management-toolbar select,
.modal-card input,
.modal-card select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #d6dce5;
  border-radius: 9px;
  outline: none;
  background: white;
  color: var(--text);
}

.management-toolbar input:focus,
.management-toolbar select:focus,
.modal-card input:focus,
.modal-card select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.14);
}

.table-scroll {
  overflow-x: auto;
}

.management-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.management-table th {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.management-table td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  vertical-align: middle;
}

.management-table tbody tr:last-child td {
  border-bottom: 0;
}

.management-table tbody tr:hover {
  background: #fbfcfe;
}

.table-primary {
  display: block;
  font-weight: 750;
}

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

.table-state {
  padding: 38px !important;
  color: var(--muted) !important;
  text-align: center;
}

.allocation {
  min-width: 105px;
}

.allocation strong {
  display: block;
  font-size: 13px;
}

.allocation-track {
  width: 100px;
  height: 6px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf3;
}

.allocation-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.allocation-full .allocation-fill {
  background: #ef4444;
}

.management-footer {
  min-height: 48px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  background: #fbfcfe;
  color: var(--muted);
  font-size: 12px;
}

.actions-column {
  width: 90px;
  text-align: right !important;
}

.table-action {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.table-action:hover {
  border-color: #c4ccd7;
  background: #f8fafc;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 24px;
  display: grid;
  place-items: center;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.64);
}

.modal-card {
  width: min(100%, 560px);
  padding: 26px;
  border-radius: 16px;
  background: white;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.modal-heading h2 {
  margin: 6px 0 0;
  font-size: 23px;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: white;
  color: #64748b;
  font-size: 23px;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-help {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.allocation-note {
  margin-top: 18px;
  padding: 11px 12px;
  border-radius: 9px;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
}

.modal-actions {
  margin-top: 22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.inline-message.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

@media (max-width: 680px) {
  .page-actions,
  .management-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .page-actions .button,
  .search-control,
  .filter-control {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 14px;
  }

  .modal-card {
    padding: 22px 18px;
  }
}

/* Stations management */

.stream-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.stream-state.available {
  color: #166534;
}

.stream-state.missing {
  color: #64748b;
}

.station-org-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.station-org-meta strong {
  color: #172033;
}

.station-org-meta span {
  color: #64748b;
  font-size: 12px;
}

.station-detail {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.station-detail strong {
  color: #172033;
}

.station-detail span {
  color: #64748b;
  font-size: 12px;
}

/* Users */

.checkbox-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 24px;
  cursor: pointer;
}

.checkbox-control input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
  cursor: pointer;
}

.checkbox-control span {
  font-weight: 600;
  line-height: 1.3;
}

.super-admin-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: #fff4dc;
  border: 1px solid #f4d28d;
  color: #8a5700;
  font-weight: 700;
  white-space: nowrap;
}

/* Users table actions */

#usersTableBody .actions-column {
  white-space: nowrap;
}

#usersTableBody .actions-column .button {
  display: inline-flex;
  margin: 0 0 0 6px;
}

#usersTableBody .actions-column .button:first-child {
  margin-left: 0;
}

/* Mobile Apps */

#mobileAppsTableBody .actions-column {
  white-space: nowrap;
}

#mobileAppsTableBody .actions-column .button {
  display: inline-flex;
}

.mobile-app-station-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-top: 26px;
  margin-bottom: 12px;
}

.mobile-app-station-heading strong {
  display: block;
  color: #172033;
  font-size: 14px;
}

.mobile-app-station-heading .field-help {
  margin-top: 4px;
  margin-bottom: 0;
}

.mobile-app-station-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mobile-app-station-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.mobile-app-station-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

#mobileAppStationManager {
  margin-top: 4px;
}

#mobileAppStationModal .modal-card {
  max-width: 560px;
}

@media (max-width: 680px) {
  .mobile-app-station-heading,
  .mobile-app-station-row {
    align-items: stretch;
    flex-direction: column;
  }

  .mobile-app-station-actions {
    width: 100%;
  }

  .mobile-app-station-actions .button {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* Mobile App Release Policies */

#mobileAppModal .modal-card {
  max-width: 980px;
}

#mobileAppReleasePolicyManager {
  margin-top: 28px;
}

.mobile-app-release-heading {
  margin-bottom: 14px;
}

.mobile-app-release-heading strong {
  display: block;
  color: #172033;
  font-size: 14px;
}

.mobile-app-release-policy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.mobile-app-release-policy-card {
  padding: 18px;
  border: 1px solid #dbe4ee;
  border-radius: 12px;
  background: #f8fafc;
}

.mobile-app-release-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.mobile-app-release-card-heading h3 {
  margin: 3px 0 0;
  color: #172033;
  font-size: 17px;
}

.mobile-app-release-policy-card .form-grid {
  margin-bottom: 4px;
}

.mobile-app-release-policy-card textarea {
  width: 100%;
  resize: vertical;
}

.mobile-app-release-effective {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
}

.mobile-app-release-effective.recommended {
  background: #fef3c7;
  color: #92400e;
}

.mobile-app-release-effective.required {
  background: #fee2e2;
  color: #991b1b;
}

.mobile-app-release-policy-card .button {
  width: 100%;
  justify-content: center;
}

@media (max-width: 820px) {
  .mobile-app-release-policy-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .mobile-app-release-card-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .mobile-app-release-effective {
    align-self: flex-start;
  }
}
