/* Shared behavior and responsive contract: docs/INTERACTION_AND_RESPONSIVE.md. */
:root { --control-height: 40px; --control-radius: 6px; }
[data-theme="light"] { --quiet: #687480; }
button { touch-action: manipulation; }
button:disabled { opacity: .55; cursor: not-allowed; }
:is(.btn-primary,.btn-secondary,.btn-theme,.btn-logout,.filter-btn,.btn-drawer-toggle,.btn-quick-quota) { min-height: var(--control-height); border-radius: var(--control-radius); line-height: 1.4; white-space: normal; }
.btn-primary { width: auto; }
.auth-body .btn-primary { width: 100%; }
:is(.form-input,.select-input,.search-input,.drawer-input-control) { min-width: 0; max-width: 100%; min-height: var(--control-height); border-radius: var(--control-radius); font-size: 14px; }
button:not(.nav-item) { flex-shrink: 0; }
.auth-box,.modal-box { border-radius: 12px; }
.auth-overlay { overflow-y: auto; background: var(--bg); }
.auth-box { margin: auto; max-height: calc(100dvh - 40px); overflow: auto; }
.auth-box::before { display: none; }
.auth-tab { display: flex; justify-content: center; align-items: center; min-height: 44px; border-left: 0; border-top: 0; border-right: 0; }
body:not(.is-authenticated) :is(.top-header,.app-shell) { visibility: hidden; }
.top-header { gap: 12px; }
.brand-group { min-width: 0; }
.brand-main { white-space: nowrap; }
.header-right { min-width: 0; }
.admin-profile { min-height: 36px; cursor: pointer; color: var(--text); }
.admin-profile-wrap { flex-shrink: 0; }
.dropdown-item { width: 100%; background: transparent; border: 0; text-align: left; min-height: 40px; color: var(--text); }
.sidebar-toggle,.sidebar-backdrop { display: none; }
.sidebar .nav-item { width: 100%; text-align: left; background: transparent; border-top: 0; border-right: 0; font: inherit; min-height: 48px; }
.sidebar .nav-item.active { background: var(--surface-2); }
.workspace { min-width: 0; padding: 24px; }
.page-container,.view-pane,.panel,.panel-body { min-width: 0; }
.page-title-group,.panel-head { flex-wrap: wrap; gap: 12px; }
.page-title-group > div { min-width: 0; }
.page-title { overflow-wrap: anywhere; }
.page-desc { max-width: 68ch; }
.metrics-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
.metric-card { min-width: 0; }
.metric-val { font-size: clamp(22px,2.3vw,28px); line-height: 1.3; overflow-wrap: anywhere; }
.metric-label { line-height: 1.5; }
.filter-bar { padding: 14px 16px; }
.filter-tabs { flex-wrap: wrap; }
.search-input { flex: 1 1 220px; }
.table-scroll { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; }
.data-table { min-width: 760px; table-layout: auto; }
.data-table th { white-space: nowrap; }
.data-table td { max-width: 300px; overflow-wrap: anywhere; line-height: 1.6; }
.data-table td button { white-space: nowrap; }
#userDetailHost { padding: 20px; border-top: 1px solid var(--line); scroll-margin-top: 16px; }
.user-detail-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.user-detail-heading h2 { margin: 0; font-size: 17px; }
.user-drawer-panel { min-width: 0; grid-template-columns: minmax(0,1fr) minmax(0,1.5fr); padding: 0; }
.user-drawer-panel > * { min-width: 0; }
.drawer-meta-val { overflow-wrap: anywhere; min-width: 0; }
.drawer-actions-bar,.drawer-actions-bar > div { flex-wrap: wrap; }
.drawer-card-box { min-width: 0; }
.drawer-actions-bar { gap: 12px !important; }
.ui-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.modal-overlay { padding: 20px; overflow-y: auto; }
.modal-box { width: min(100%,760px) !important; max-height: calc(100dvh - 40px); display: flex; flex-direction: column; overflow: hidden; }
.modal-header,.modal-footer { flex-shrink: 0; flex-wrap: wrap; gap: 12px; }
.modal-body { overflow-y: auto; min-height: 0; }
.modal-box .form-group { min-width: 0; }
.btn-modal-close { min-width: 36px; min-height: 36px; }
#fbModalContent,#fbModalEnv { overflow-wrap: anywhere; }
#fbAttachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.system-details { display: grid; grid-template-columns: 140px minmax(0,1fr); gap: 0; margin: 0; }
.system-details dt,.system-details dd { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.system-details dt { color: var(--muted); }
.ui-dialog { width: min(480px,calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 16px 60px #0005; }
.ui-dialog::backdrop { background: #0008; }
.ui-dialog h2 { font-size: 18px; margin: 0 0 12px; }
.ui-dialog p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; color: var(--muted); }
.ui-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.recovery-code { height: 100px; width: 100%; padding: 12px; resize: vertical; }
#uiNotifications { position: fixed; z-index: 1500; bottom: 24px; right: 24px; display: grid; gap: 10px; max-width: min(480px,calc(100vw - 32px)); }
.ui-notification { display: flex; align-items: center; gap: 12px; padding: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--accent-line); border-radius: 10px; box-shadow: 0 8px 32px #0003; }
.ui-notification span { overflow-wrap: anywhere; min-width: 0; white-space: pre-wrap; }
@media (max-width: 1100px) {
 .system-clock,.header-center { display: none; }
 .sidebar { width: 180px; }
 .sidebar .nav-name,.sidebar-header { display: block; }
 .sidebar .nav-item { justify-content: flex-start; padding: 12px 16px; }
 .user-drawer-panel { grid-template-columns: minmax(0,1fr); }
 .workspace { padding: 20px; }
}
@media (max-width: 900px) {
 .sidebar-toggle { display: inline-flex; padding: 8px 12px; }
 .top-header { padding-inline: 16px; }
 .top-header .brand-group { flex: 1; }
 .sidebar { display: none; position: fixed; left: 0; top: var(--header-height); bottom: 0; height: calc(100dvh - var(--header-height)); width: 240px; z-index: 220; }
 .navigation-open .sidebar { display: flex; }
 .navigation-open .sidebar-backdrop { display: block; position: fixed; inset: var(--header-height) 0 0; border: 0; padding: 0; background: #0008; z-index: 210; }
 .sidebar-header,.sidebar-footer { display: block; }
 .metrics-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
 .metric-card { border-bottom: 1px solid var(--line); }
 .workspace { padding: 20px 16px; }
 .form-grid { grid-template-columns: minmax(0,1fr) !important; }
}
@media (max-width: 600px) {
 :root { --header-height: 64px; --control-height: 44px; }
 .brand-main { font-size: 13px; white-space: normal; }
 .brand-icon,.admin-avatar-tag,.admin-role-badge { display: none; }
 .header-right { gap: 6px; }
 .btn-theme { max-width: 84px; height: 40px; padding: 4px 8px; font-size: 11px; }
 .admin-profile { padding: 6px 8px; }
 .metric-card { padding: 16px; }
 .metric-val { font-size: 24px; }
 .filter-tabs { width: 100%; }
 .filter-btn { flex: 1 1 auto; }
 .search-input { width: 100%; }
 .panel-head,.panel-body { padding: 16px; }
 #userDetailHost { padding: 16px; }
 .modal-overlay { padding: 12px; }
 .modal-box { max-height: calc(100dvh - 24px); }
 .modal-header,.modal-body,.modal-footer { padding: 16px; }
 .modal-footer > button { flex: 1; }
 .form-label { gap: 8px; flex-wrap: wrap; }
 :is(.form-input,.select-input,.search-input,.drawer-input-control) { font-size: 16px; }
 .system-details { grid-template-columns: 100px minmax(0,1fr); }
 .ui-dialog { padding: 20px; }
}

:root { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
.user-open-link { background:transparent; border:0; padding:0; min-height:36px; color:var(--accent); text-align:left; overflow-wrap:anywhere; font-weight:600; }
.data-table td .user-open-link { white-space:normal; }
@media (max-width:600px) {
 .user-drawer-panel > :first-child { order:2; }
 .drawer-meta-item { display:grid; grid-template-columns:minmax(0,1fr); gap:4px; }
 .drawer-meta-label { white-space:nowrap; }
 .drawer-meta-val { text-align:left; }
}
