
html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* Ensure SPA uses full viewport height and consistent padding */
html, body { height: 100%; }
body { margin: 0; }
/* Layout sizing vars */
:root { --appbar-h: 64px; --app-bottom-gap: 8px; --app-vh: 1vh; }
@media (max-width: 600px) { :root { --appbar-h: 56px; } }

/* Use JS-computed --app-vh to avoid browser UI bars issues */
.mud-layout { min-height: calc(var(--app-vh, 1vh) * 100); }
.mud-main-content {
  min-height: calc((var(--app-vh, 1vh) * 100) - var(--appbar-h, 64px) - var(--app-bottom-gap, 8px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Brand header (logo in drawer) with breathing room */
.brand-header {
  height: 56px;
  padding: 12px 16px;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: left center !important;
  background-origin: content-box;
}

@media (min-width: 600px) { .brand-header { height: 64px; } }
@media (min-width: 960px) { .brand-header { height: 72px; } }

/* Drawer logo image scales to fit header */
.drawer-logo { max-height: 100%; max-width: 100%; width: auto; object-fit: contain; display: block; }

/* App content responsive padding */
.app-content {
  padding: 6px 6px var(--app-bottom-gap, 8px) 6px;
  flex: 1 1 auto;
  min-height: 0;
  height: calc((var(--app-vh, 1vh) * 100) - var(--appbar-h, 64px) - var(--app-bottom-gap, 8px));
  box-sizing: border-box;
  overflow: auto;
}
@media (max-width: 600px) {
  .app-content {
    height: calc((var(--app-vh, 1vh) * 100) - var(--appbar-h, 56px) - var(--app-bottom-gap, 8px));
  }
}
@media (min-width: 600px) { .app-content { padding: 8px 8px var(--app-bottom-gap, 8px) 8px; } }
@media (min-width: 960px) { .app-content { padding: 12px 12px var(--app-bottom-gap, 8px) 12px; } }

/* Override old scroll-container height to be 5px shorter globally */
/* Generic scroll container height: viewport minus appbar and a toolbar band (~56px) and bottom gap */
body .scroll-container { height: calc((var(--app-vh, 1vh) * 100) - var(--appbar-h, 64px) - 56px - var(--app-bottom-gap, 8px)) !important; overflow-y: auto; }

/* Brand image on auth/login */
.brand-img { max-height: 48px; width: auto; object-fit: contain; }
@media (min-width: 600px) { .brand-img { max-height: 56px; } }

/* Auth (Identity UI) layout to match old login design */
.auth-body {
  background: radial-gradient(1200px 900px at 20% 0%, #e8f1ff 0%, #f5f7fb 45%, #f8fafc 100%);
}
.auth-body .mud-main-content { min-height: 100vh; padding: 0; margin: 0; }
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 420px;
  max-width: 92vw;
  border-radius: 8px;
  box-sizing: border-box;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  border: 1px solid rgba(15, 23, 42, 0.06);
  padding: 28px 28px 22px;
}
.auth-single { display: flex; flex-direction: column; gap: 10px; }
.auth-logo { display: flex; align-items: center; justify-content: center; height: 56px; margin-bottom: 4px; }
.auth-logo-img { max-height: 40px; width: auto; object-fit: contain; }
.auth-logo-fallback { width: 32px; height: 32px; color: #0078d4; }
.auth-title { margin: 0; text-align: center; font-size: 20px; font-weight: 600; color: #111827; }
.auth-subtitle { margin: 0 0 6px; text-align: center; font-size: 13px; color: #475569; }
.auth-form { width: 100%; text-align: left; }
.auth-field { margin-bottom: 12px; }
.auth-label { display: block; font-size: 12.5px; color: #1f2937; margin-bottom: 6px; }
.auth-input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13.5px;
  background: #fff;
  color: #111827;
  outline: none;
  box-sizing: border-box;
}
.auth-input:focus { border-color: #0078d4; box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.2); }
.auth-input-row { display: flex; align-items: center; gap: 6px; }
.auth-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  cursor: pointer;
}
.auth-icon-btn:hover { background: #eef2f7; }
.auth-error { min-height: 14px; font-size: 11.5px; color: #b91c1c; margin-top: 4px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; }
.auth-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #1f2937; }
.auth-btn {
  width: 100%;
  padding: 9px 10px;
  border-radius: 4px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13.5px;
}
.auth-btn-primary { background: #0078d4; color: #fff; }
.auth-btn-primary:hover { background: #0063b1; }
.auth-btn-outline {
  margin-top: 8px;
  background: #fff;
  border-color: #cbd5e1;
  color: #111827;
}
.auth-btn-outline[data-provider] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.auth-btn-outline[data-provider]::before {
  content: "";
  width: 18px;
  height: 18px;
  display: inline-block;
  background-repeat: no-repeat;
  background-size: contain;
}
.auth-btn-outline[data-provider="Google"]::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23EA4335' d='M12 10.2v3.9h5.4c-.6 2.4-2.6 3.9-5.4 3.9-3.2 0-5.8-2.6-5.8-5.8S8.8 6.4 12 6.4c1.6 0 2.9.6 3.9 1.6l2.7-2.7C16.9 3.6 14.7 2.6 12 2.6 6.9 2.6 2.8 6.7 2.8 11.8S6.9 21 12 21c5 0 8.3-3.5 8.3-8.4 0-.6-.1-1.2-.2-1.7H12z'/></svg>");
}
.auth-btn-outline[data-provider="Microsoft"]::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><rect x='2' y='2' width='9' height='9' fill='%23F35325'/><rect x='13' y='2' width='9' height='9' fill='%2381BC06'/><rect x='2' y='13' width='9' height='9' fill='%2305A6F0'/><rect x='13' y='13' width='9' height='9' fill='%23FFBA08'/></svg>");
}
.auth-divider {
  text-align: center;
  margin: 12px 0 4px;
  font-size: 12px;
  color: #6b7280;
}
.auth-divider span { background: #fff; padding: 0 8px; }
.auth-external form { display: flex; flex-direction: column; }
.auth-links {
  margin-top: 10px;
  text-align: center;
  font-size: 12.5px;
  color: #475569;
}
.auth-link { color: #0078d4; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.auth-footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  background: transparent;
}

/* Panels that should share equal heights and allow inner scrolling */
.app-grid-full { height: 100%; min-height: 0; }
.app-panel { height: 100%; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.app-panel-footer { flex: 0 0 auto; padding-top: 6px; }
.stats-panel { min-height: 0; }
.stats-grid { height: 100%; min-height: 0; }
.stats-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 14px; height: 100%; min-height: 0; }
@media (max-width: 1200px) { .stats-charts { grid-template-columns: 1fr; } }
.stats-kpi { border: 1px solid #e6edf3; border-radius: 12px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06); }
.stats-tile { display: flex; flex-direction: column; min-height: 0; height: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid #e6edf3; background: #ffffff; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06); }
.stats-title { font-weight: 600; color: #1f2a37; }
.stats-donut { position: relative; flex: 1 1 auto; min-height: 0; }
.stats-donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; color: #1f2a37; }
.stats-chart-fixed { height: 260px; }
.stats-tile .mud-table-container { max-height: 100%; overflow: auto; }
.settings-shell { min-height: 0; overflow: hidden; }
.settings-tabs { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.settings-tabs .mud-tabs-panels { flex: 1 1 auto; min-height: 0; }
.settings-tabs .mud-tab-panel { height: 100%; }
.settings-tab { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.settings-tab > form { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.settings-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.settings-footer { flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 8px; }
.settings-footer-info { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.settings-card { display: flex; flex-direction: column; min-height: 0; }
.settings-card .mud-card-content { flex: 1 1 auto; min-height: 0; }
.upload-shell { min-height: 0; display: flex; flex-direction: column; height: 100%; }
.upload-top { flex: 0 0 auto; }
.upload-table { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.upload-footer { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding-top: 8px; }
.app-column { height: 100%; display: flex; flex-direction: column; gap: 8px; }
.app-column > .app-panel { flex: 1 1 0; min-height: 0; }

/* Index info tables: prevent right clipping, allow wrapping */
.info-table table { table-layout: fixed; width: 100%; }
.info-table .mud-table-cell { white-space: normal; overflow-wrap: anywhere; }
.info-table .info-actions { white-space: nowrap; }
.info-stack { display: flex; flex-direction: column; gap: 8px; align-content: flex-start; }
.info-doc-card { display: flex; flex-direction: column; gap: 6px; }
.info-doc-title { font-weight: 600; }
.info-doc-subtitle { color: var(--mud-palette-text-secondary); }
.info-doc-topic { color: var(--mud-palette-text-primary); }
.info-doc-actions { display: flex; gap: 6px; justify-content: flex-end; }
.info-doc-section { margin-bottom: 6px; }
.line-clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.panel-2-3 { flex: 2 1 0 !important; }
.panel-1-3 { flex: 1 1 0 !important; }
.card-media-fill { height: 100%; object-fit: cover; }

/* Make MudTable body scroll and keep footer visible */
.table-fill { display: flex; flex-direction: column; height: 100%; }
.table-fill .mud-table-container { flex: 1 1 auto; min-height: 0; overflow: auto; }
.table-fill .mud-table-pagination { flex: 0 0 auto; }

/* Utility */
.h-100 { height: 100%; }

a, .btn-link {
    color: #0366d6;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }
