:root {
  --bg: #f4f7fa;
  --surface: #ffffff;
  --text: #1a2b3c;
  --muted: #5c6b7a;
  --primary: #0f3d5e;
  --primary-hover: #14527d;
  --accent: #e87722;
  --border: #d8e0e8;
  --success: #1a7f4b;
  --error: #b42318;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(15, 61, 94, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --page-pad: max(1rem, var(--safe-left), var(--safe-right));
  --touch-min: 2.75rem;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  width: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  min-height: 100dvh;
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
}

body {
  padding-top: var(--safe-top);
}

.header {
  background: linear-gradient(135deg, var(--primary), #1a5a85);
  color: #fff;
  padding: 0.65rem var(--page-pad) 0.75rem;
}

/* Admin header matches zoomed footer / page density (header sits outside zoom: 0.8). */
.admin-page .header {
  padding: 0.32rem var(--page-pad) 0.36rem;
}

.admin-page .header-inner {
  gap: 0.45rem;
  align-items: center;
}

.admin-page .header .eyebrow {
  margin: 0;
  font-size: 0.55rem;
  letter-spacing: 0.05em;
  line-height: 1.1;
}

.admin-page .header h1 {
  font-size: 1.02rem;
  line-height: 1.15;
}

.admin-page .header-actions {
  gap: 0.28rem;
  align-items: center;
}

.admin-page .header .badge {
  font-size: 0.65rem;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
}

.admin-page .header .badge.user {
  max-width: 7.5rem;
}

.admin-page .header .btn-text {
  font-size: 0.7rem;
}

.admin-page .connection-dot {
  width: 1.35rem;
  height: 1.35rem;
}

.admin-page .connection-dot-mark {
  width: 0.45rem;
  height: 0.45rem;
}

.admin-page .issues-trigger {
  padding: 0.18rem 0.5rem;
  font-size: 0.68rem;
  gap: 0.25rem;
}

.admin-page .issues-badge {
  min-width: 0.95rem;
  height: 0.95rem;
  font-size: 0.58rem;
  padding: 0 0.22rem;
}

.admin-page .issues-trigger-label {
  line-height: 1;
}

.header-inner {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 0.1rem;
  font-size: 0.68rem;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

h1 {
  margin: 0;
  font-size: clamp(1.1rem, 4vw + 0.5rem, 1.75rem);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0.75rem var(--page-pad) calc(4.5rem + var(--safe-bottom));
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.form-card {
  display: grid;
  gap: 1rem;
}

.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.optional {
  font-weight: 400;
  color: var(--muted);
}

select,
textarea {
  width: 100%;
  font: inherit;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.wir-date-input {
  width: 100%;
  min-height: 46px;
  font: inherit;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.date-input-wrap {
  position: relative;
  display: flex;
  width: 100%;
}

.date-input-wrap .wir-date-input,
.edit-form .date-input-wrap input[type='text'] {
  padding-right: 3.25rem;
}

.date-picker-btn {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 3rem;
  min-height: 44px;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0 9px 9px 0;
  background: #f8fafc;
  color: var(--primary);
  font-size: 1.15rem;
  cursor: pointer;
}

.date-picker-btn:hover,
.date-picker-btn:focus {
  background: #eef6fc;
}

.date-picker-native {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.edit-form input[type='text'],
.edit-form input[type='date'] {
  width: 100%;
  min-height: 46px;
  font: inherit;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.edit-form input[type='text']:focus,
.edit-form input[type='date']:focus {
  outline: 2px solid rgba(15, 61, 94, 0.25);
  border-color: var(--primary);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%235c6b7a'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

/* Adaptive dropdown — wraps long text (stage, element, etc.) */
.adaptive-select {
  position: relative;
  width: 100%;
}

.adaptive-select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.adaptive-select-trigger {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  line-height: 1.45;
  padding: 0.85rem 2.25rem 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%235c6b7a'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 0.75rem top 1rem;
  color: var(--text);
  cursor: pointer;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-height: var(--touch-min);
  touch-action: manipulation;
}

.adaptive-select-trigger.placeholder {
  color: var(--muted);
}

.adaptive-select-trigger:focus {
  outline: 2px solid rgba(15, 61, 94, 0.25);
  border-color: var(--primary);
}

.adaptive-select-panel {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: min(60vh, 360px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 61, 94, 0.18);
}

/* Author display:flex overrides UA [hidden] — must force hide */
.adaptive-select-panel[hidden] {
  display: none !important;
}

.adaptive-select-panel.is-overlay {
  position: fixed;
  right: auto;
  margin: 0;
  z-index: 10000;
}

.adaptive-select-mark {
  background: #ffe08a;
  color: inherit;
  font-weight: 700;
  border-radius: 2px;
  padding: 0 0.05em;
}

.adaptive-select-search-wrap {
  flex-shrink: 0;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.adaptive-select-search {
  width: 100%;
  margin: 0;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 2.4rem;
}

.adaptive-select-search:focus {
  outline: 2px solid rgba(15, 61, 94, 0.25);
  border-color: var(--primary);
}

.adaptive-select-options {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.adaptive-select-empty {
  margin: 0;
  padding: 0.85rem 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.adaptive-select-option {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  line-height: 1.45;
  padding: 0.75rem 0.9rem;
  border: none;
  border-bottom: 1px solid #eef3f7;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: normal;
  word-break: break-word;
}

.adaptive-select-option:last-child {
  border-bottom: none;
}

.adaptive-select-option:hover,
.adaptive-select-option[aria-selected='true'] {
  background: #eef6fc;
}

.adaptive-select-option.is-active,
.adaptive-select-option:focus {
  background: #d9ebf8;
  outline: 2px solid rgba(15, 61, 94, 0.35);
  outline-offset: -2px;
}

.adaptive-select-option.placeholder-option {
  color: var(--muted);
  font-style: italic;
}

.adaptive-select-option.not-required-option {
  color: var(--primary);
  font-weight: 500;
}

.adaptive-select-measurer {
  position: absolute;
  visibility: hidden;
  pointer-events: none;
  width: 100%;
  font: inherit;
  line-height: 1.45;
  padding: 0.85rem 2.25rem 0.85rem 0.9rem;
  white-space: normal;
  word-break: break-word;
}

.adaptive-select.open .adaptive-select-trigger {
  border-color: var(--primary);
}

.adaptive-select.is-disabled .adaptive-select-trigger {
  opacity: 0.65;
  cursor: not-allowed;
  background-color: #f8fafc;
}

.adaptive-select-compact {
  min-width: 0;
}

.adaptive-select-compact .adaptive-select-trigger {
  padding: 0.25rem 1.5rem 0.25rem 0.35rem;
  font-size: inherit;
  min-height: 1.85rem;
  border-radius: 6px;
  background-position: right 0.35rem center;
}

.adaptive-select-compact .adaptive-select-panel {
  min-width: 10rem;
  max-height: min(50vh, 260px);
}

.adaptive-select-compact .adaptive-select-search {
  font-size: 0.78rem;
  padding: 0.35rem 0.45rem;
  min-height: 1.75rem;
}

.adaptive-select-compact .adaptive-select-option {
  font-size: 0.78rem;
  padding: 0.45rem 0.55rem;
}

.records-table .adaptive-select {
  width: 100%;
}

.records-table .adaptive-select-panel {
  z-index: 40;
}

.modal .adaptive-select-panel {
  z-index: 120;
}

textarea {
  resize: vertical;
  min-height: 4rem;
}

select:focus,
textarea:focus,
button:focus {
  outline: 2px solid rgba(15, 61, 94, 0.25);
  border-color: var(--primary);
}

.preview {
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.preview h2 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.preview-text {
  margin: 0;
  line-height: 1.5;
  font-size: 0.95rem;
  white-space: normal;
  word-break: break-word;
}

.preview-text.empty {
  color: var(--muted);
  font-style: italic;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.95rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  touch-action: manipulation;
  min-height: var(--touch-min);
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.secondary {
  background: #eef3f7;
  color: var(--primary);
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge.storage {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  white-space: nowrap;
}

.badge.user {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.connection-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  cursor: default;
  flex-shrink: 0;
}

.connection-dot.is-offline {
  cursor: pointer;
}

.connection-dot-mark {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.connection-dot.is-online .connection-dot-mark {
  background: #34d399;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.28);
}

.connection-dot.is-offline .connection-dot-mark {
  background: #f87171;
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.3);
}

.connection-dot.is-syncing .connection-dot-mark {
  background: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.32);
  animation: connection-dot-pulse 1.1s ease-in-out infinite;
}

@keyframes connection-dot-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.85);
  }
}

.btn-text {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.9);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--page-pad);
}

.login-container {
  width: 100%;
  max-width: 420px;
}

.login-card h1 {
  margin: 0 0 0.35rem;
  color: var(--text);
}

.login-brand {
  color: var(--primary);
  opacity: 1;
}

.login-sub {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 1rem;
}

.login-form[hidden] {
  display: none !important;
}

.login-btn {
  width: 100%;
}

.login-note {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.login-error {
  background: #fef3f2;
  color: var(--error);
  border: 1px solid #fecdca;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.login-success {
  background: #ecfdf3;
  color: var(--success);
  border: 1px solid #abefc6;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  line-height: 1.45;
}

.login-help-link {
  justify-self: center;
  color: var(--primary);
  font-weight: 600;
}

.login-section-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  color: var(--text);
}

.login-note a {
  color: var(--primary);
  font-weight: 600;
}

input[type='email'],
input[type='password'] {
  width: 100%;
  font: inherit;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

input:focus {
  outline: 2px solid rgba(15, 61, 94, 0.25);
  border-color: var(--primary);
}

.toolbar-hint {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 280px;
  line-height: 1.4;
}

.status-select {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-width: 100%;
}

.status-cell-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.35rem;
  align-items: center;
}

.result-badge {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  padding: 0.12rem 0.35rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}

.result-badge.result-approved {
  background: #dcfae6;
  color: #087a48;
}

.result-badge.result-rejected {
  background: #fee4e2;
  color: #b42318;
}

.result-badge.result-hold {
  background: #fef0c7;
  color: #b54708;
}

.result-badge.result-not-ready,
.result-badge.result-neutral {
  background: #eef2f6;
  color: #475467;
}

.records-table tbody tr td.result-cell.result-approved {
  background: #f3fbf6;
}

.records-table tbody tr td.result-cell.result-rejected {
  background: #fff6f5;
}

.records-table tbody tr td.result-cell.result-hold {
  background: #fffbeb;
}

.records-table tbody tr td.result-cell.result-not-ready,
.records-table tbody tr td.result-cell.result-neutral {
  background: #fafbfc;
}

.serial-input {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 6.5rem;
  min-width: 5rem;
}

.serial-input:focus {
  outline: 2px solid rgba(15, 61, 94, 0.25);
  border-color: var(--primary);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  z-index: 10;
}

.nav-item {
  flex: 1;
  text-align: center;
  padding: 0.9rem 0.5rem;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: clamp(0.82rem, 2.5vw, 0.9rem);
  touch-action: manipulation;
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item.active {
  color: var(--primary);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.bottom-nav-admin .nav-export {
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
  color: var(--primary);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.bottom-nav-admin .nav-export:hover {
  color: var(--accent);
}

.admin-container {
  width: 100%;
  max-width: 100%;
  padding-left: var(--page-pad);
  padding-right: var(--page-pad);
  /* Browser 100% should feel like the prior comfortable ~80% zoom. */
  zoom: 0.8;
}

.bottom-nav-admin .nav-export[hidden] {
  display: none !important;
}

.admin-container .toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.admin-container .toolbar-compact {
  margin-bottom: 0.35rem;
}

.toolbar-left {
  min-width: 0;
}

#record-count {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.toolbar-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.15rem 0 0;
}

.toolbar-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.status-dashboard {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1 1 auto;
  min-width: 0;
}

.status-dashboard-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
  align-items: stretch;
}

.status-stat {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  min-width: 0;
  width: 100%;
  padding: 0.28rem 0.35rem 0.25rem;
  text-align: center;
  cursor: pointer;
  box-shadow: none;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.status-stat:hover {
  transform: none;
  box-shadow: 0 4px 12px rgba(15, 61, 94, 0.1);
}

.status-stat:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.status-stat.active {
  border-color: currentColor;
  box-shadow: 0 0 0 1px currentColor;
}

.status-stat-label {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
}

.status-stat-value {
  display: block;
  margin-top: 0.05rem;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.status-stat.all {
  color: #334155;
  background: linear-gradient(160deg, #f8fafc 0%, #e2e8f0 100%);
}

.status-stat.required {
  color: #9a3412;
  background: linear-gradient(160deg, #fff7ed 0%, #ffedd5 100%);
}

.status-stat.created {
  color: #1d4ed8;
  background: linear-gradient(160deg, #eff6ff 0%, #dbeafe 100%);
}

.status-stat.closed {
  color: #166534;
  background: linear-gradient(160deg, #f0fdf4 0%, #dcfce7 100%);
}

.status-stat.result-approved {
  color: #047857;
  background: linear-gradient(160deg, #ecfdf5 0%, #d1fae5 100%);
}

.status-stat.result-rejected {
  color: #b91c1c;
  background: linear-gradient(160deg, #fef2f2 0%, #fee2e2 100%);
}

.status-stat.result-hold {
  color: #b45309;
  background: linear-gradient(160deg, #fffbeb 0%, #fef3c7 100%);
}

.status-stat.result-not-ready {
  color: #475569;
  background: linear-gradient(160deg, #f8fafc 0%, #e2e8f0 100%);
}

@media (max-width: 900px) {
  .admin-container .toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .toolbar-actions .btn {
    flex: 1 1 auto;
  }

  .status-dashboard {
    width: 100%;
  }

  .status-dashboard-row {
    gap: 0.28rem;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(4.5rem + var(--safe-bottom));
  transform: translateX(-50%) translateY(120%);
  background: var(--text);
  color: #fff;
  padding: 0.85rem 1.1rem;
  border-radius: 10px;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 20;
  max-width: calc(100vw - 2rem);
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

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

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

.login-page .toast {
  bottom: calc(1.5rem + var(--safe-bottom));
  z-index: 40;
}

.records-filters {
  margin-bottom: 0.5rem;
  padding: 0.65rem 0.85rem;
  display: grid;
  gap: 0.6rem;
}

.filter-search-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.records-search {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.records-search:focus {
  outline: 2px solid rgba(15, 61, 94, 0.25);
  border-color: var(--primary);
}

.filter-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.filter-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 3.5rem;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-chip {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.filter-chip:hover {
  border-color: var(--primary);
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.records-view-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.55rem 0.85rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.view-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin-left: auto;
}

.page-size-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.page-size-select {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-info {
  font-size: 0.82rem;
  color: var(--muted);
  min-width: 6.5rem;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.table-wrap {
  overflow: auto;
  padding: 0;
  max-height: calc(100dvh - 185px - var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

.table-wrap.card {
  padding: 0;
}

.records-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

.records-table th,
.records-table td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.records-table th:first-child,
.records-table td:first-child {
  border-left: 1px solid var(--border);
}

.records-table thead th {
  border-top: 1px solid var(--border);
}

/* Admin records: sized so browser 100% ≈ previous comfortable 80% zoom. */
.admin-container .records-fit-view {
  width: 100%;
  overflow-x: auto;
  max-height: calc(100dvh - 155px - var(--safe-bottom));
}

.admin-container .records-fit-view .records-table {
  width: 100%;
  min-width: 100%;
  table-layout: fixed;
  font-size: 0.82rem;
}

.admin-container .records-fit-view .records-table col.col-ser { width: 3.2%; }
.admin-container .records-fit-view .records-table col.col-date { width: 6.2%; }
.admin-container .records-fit-view .records-table col.col-village { width: 8%; }
.admin-container .records-fit-view .records-table col.col-trade { width: 5.5%; }
.admin-container .records-fit-view .records-table col.col-desc { width: 44%; }
.admin-container .records-fit-view .records-table col.col-serial { width: 7.5%; }
.admin-container .records-fit-view .records-table col.col-status { width: 13.5%; }
.admin-container .records-fit-view .records-table col.col-actions { width: 12%; }

.admin-container .records-fit-view .records-table th,
.admin-container .records-fit-view .records-table td {
  padding: 0.22rem 0.32rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.admin-container .records-fit-view .records-table thead th {
  font-size: 0.7rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  padding: 0.28rem 0.32rem;
}

.admin-container .records-fit-view .desc-cell,
.admin-container .records-fit-view .records-table tbody td.desc-cell:nth-child(5),
.admin-container .records-fit-view .records-table td.col-desc,
.admin-container .records-fit-view .records-table tbody tr td:nth-child(5) {
  max-width: none;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.28;
  vertical-align: middle;
  font-size: 0.84rem;
  font-weight: 500;
  color: #1e293b;
  /* Soft banded description fill — darker than page, easy on the eyes */
  background: #d8e3ef;
}

.admin-container .records-fit-view .records-table tbody tr:nth-child(even) td.desc-cell:nth-child(5),
.admin-container .records-fit-view .records-table tbody tr:nth-child(even) td:nth-child(5) {
  background: #c5d5e6;
}

.admin-container .records-fit-view .records-table tbody tr:hover td.desc-cell:nth-child(5),
.admin-container .records-fit-view .records-table tbody tr:hover td:nth-child(5) {
  background: #b7cbdf;
}

.admin-container .records-fit-view .desc-copy-wrap {
  align-items: flex-start;
  min-width: 0;
  width: 100%;
  gap: 0.3rem;
}

.admin-container .records-fit-view .desc-copy-text {
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.28;
}

.admin-container .records-fit-view .desc-copy-btn {
  margin-top: 0;
  padding: 0.2rem;
  font-size: 0.7rem;
  min-height: 1.55rem;
  min-width: 1.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.admin-container .records-fit-view .desc-copy-icon {
  display: block;
}

.admin-container .records-fit-view .records-table .col-ser,
.admin-container .records-fit-view .records-table td:first-child {
  text-align: center;
}

.admin-container .records-fit-view .records-table .col-trade {
  text-transform: uppercase;
  font-size: 0.72rem;
}

.admin-container .records-fit-view .status-select,
.admin-container .records-fit-view .serial-input {
  font-size: 0.78rem;
  padding: 0.14rem 0.3rem;
  min-height: 1.55rem;
  line-height: 1.2;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

/* Native arrow must not sit on the status label */
.admin-container .records-fit-view .status-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 1.45rem;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%230f3d5e' d='M1.1 1.2 6 6.1l4.9-4.9 1.1 1.1L6 8.3.0 2.3z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.35rem center;
  background-size: 0.65rem auto;
  text-overflow: ellipsis;
}

.admin-container .records-fit-view .status-cell-stack {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.2rem;
  min-width: 0;
}

.admin-container .records-fit-view .status-cell-stack .status-select {
  flex: 0 0 auto;
  width: 100%;
}

.admin-container .records-fit-view .result-badge {
  flex: 0 0 auto;
  align-self: flex-start;
  padding: 0.12rem 0.4rem;
  font-size: 0.68rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-container .records-fit-view .records-table td.result-cell,
.admin-container .records-fit-view .records-table td.col-actions {
  white-space: nowrap;
  overflow: hidden;
}

.admin-container .records-fit-view .btn-sm {
  padding: 0.16rem 0.32rem;
  font-size: 0.7rem;
  min-height: 1.5rem;
}

.admin-container .records-fit-view .action-buttons {
  gap: 0.28rem;
  flex-wrap: nowrap;
}

.admin-container .records-fit-view .records-table thead th.col-desc,
.admin-container .records-fit-view .records-table thead th:nth-child(5) {
  color: var(--primary);
  font-weight: 700;
}

.admin-container .records-fit-view .records-table tbody td:nth-child(3),
.admin-container .records-fit-view .records-table tbody td:nth-child(4) {
  color: var(--muted);
  font-size: 0.92em;
}

.admin-container .records-fit-view .records-table .col-ser,
.admin-container .records-fit-view .records-table .col-date,
.admin-container .records-fit-view .records-table .col-village,
.admin-container .records-fit-view .records-table .col-trade,
.admin-container .records-fit-view .records-table .col-serial,
.admin-container .records-fit-view .records-table .col-status,
.admin-container .records-fit-view .records-table .col-actions,
.admin-container .records-fit-view .records-table .col-desc {
  min-width: 0;
}

.records-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  box-shadow: none;
}

.records-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}

.records-table thead th.sortable:hover {
  color: var(--primary);
}

.records-table thead th.sorted {
  color: var(--primary);
}

.records-table th:first-child,
.records-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: none;
}

.records-table thead th:first-child {
  z-index: 3;
  background: #f8fafc;
}

.records-table .col-ser {
  min-width: 3.5rem;
}

.records-table .col-date {
  min-width: 5.5rem;
}

.records-table .col-village,
.records-table .col-trade,
.records-table .col-building {
  min-width: 6.5rem;
}

.records-table .col-stage {
  min-width: 10rem;
}

.records-table .col-status {
  min-width: 7.5rem;
}

.records-table .col-serial {
  min-width: 7rem;
}

.records-table .col-desc {
  min-width: 22rem;
}

.desc-cell {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.28;
}

.search-hit {
  font-weight: 700;
  color: #0f3d5e;
  background: rgba(251, 191, 36, 0.45);
  border-radius: 0.15rem;
  padding: 0 0.1em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.records-table .desc-cell {
  max-width: none;
}

.desc-copy-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  width: 100%;
}

.desc-copy-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.desc-copy-btn {
  flex: 0 0 auto;
  padding: 0.2rem;
  font-size: 0.68rem;
  line-height: 1;
  white-space: nowrap;
  margin-top: 0;
  min-width: 1.55rem;
  min-height: 1.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.desc-copy-icon {
  display: block;
}

.desc-copy-btn.is-copied {
  border-color: #087a48;
  color: #087a48;
  background: #f3fbf6;
}

/* Soft zebra + row hover — easier scanning; description stays a touch stronger */
.records-table tbody tr:nth-child(even) td {
  background: #f8fafc;
}

.records-table tbody tr:nth-child(even) td:first-child {
  background: #f8fafc;
}

.records-table tbody tr:hover td {
  background: #eef6fc;
}

.records-table tbody tr:hover td:first-child {
  background: #eef6fc;
}

.records-table tbody tr td:nth-child(5) {
  background: #d8e3ef;
}

.records-table tbody tr:nth-child(even) td:nth-child(5) {
  background: #c5d5e6;
}

.records-table tbody tr:hover td:nth-child(5) {
  background: #b7cbdf;
}

.records-table .col-user {
  min-width: 9rem;
}

.records-table .col-actions {
  min-width: 8.5rem;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.btn.danger {
  background: var(--error);
  color: #fff;
  border: 1px solid var(--error);
}

.btn.danger:hover {
  filter: brightness(0.92);
}

.btn.danger:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.badge.locked {
  background: #f1f5f9;
  color: #64748b;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.status-select,
.serial-input {
  width: 100%;
  min-width: 6rem;
  font-size: 0.8rem;
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100dvh - 2rem - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  margin: 0;
  z-index: 1;
  -webkit-overflow-scrolling: touch;
}

#edit-modal .modal-panel {
  overflow: visible;
  display: flex;
  flex-direction: column;
}

#edit-modal .edit-form {
  overflow: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

#edit-modal .adaptive-select {
  z-index: 2;
}

#edit-modal .adaptive-select.open {
  z-index: 50;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-meta {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.modal-locked {
  margin: 0 0 1rem;
  padding: 0.75rem;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.85rem;
}

.edit-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

.field-full {
  grid-column: 1 / -1;
}

.edit-form textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  resize: vertical;
}

.preview-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.preview-block h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.description-preview {
  margin: 0;
  padding: 0.85rem;
  border-radius: 10px;
  background: #f8fafc;
  font-size: 0.88rem;
  line-height: 1.45;
}

.description-preview.empty {
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.duplicate-help {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

#serial-duplicate-modal .modal-actions,
#duplicate-modal .modal-actions {
  justify-content: stretch;
}

#serial-duplicate-modal .modal-actions .btn,
#duplicate-modal .modal-actions .btn {
  flex: 1 1 12rem;
}

@media (min-width: 640px) {
  .modal {
    align-items: center;
  }

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

.table-scroll-hint {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

.mobile-only-hint {
  display: none;
}

@media (max-width: 900px) {
  .desktop-only-hint {
    display: none;
  }

  .mobile-only-hint {
    display: block;
  }
}

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.wir-count-input {
  max-width: 8rem;
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  font: inherit;
  background: #fff;
}

.bulk-wir-fields {
  display: grid;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
}

.bulk-wir-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  background: #f8fafc;
}

.bulk-wir-title {
  margin: 0;
  font-size: 1rem;
  color: var(--ink);
}

.bulk-wir-card .preview-block h4 {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.btn:disabled,
.btn.primary:disabled {
  opacity: 0.72;
  cursor: wait;
  filter: grayscale(0.15);
}

@media (min-width: 640px) {
  .container {
    padding-top: 1.5rem;
  }
}

@media (max-width: 640px) {
  .table-wrap {
    max-height: calc(100dvh - 200px - var(--safe-bottom));
  }

  .toolbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .toolbar-actions .btn {
    flex: 1 1 auto;
  }

  .filter-chip {
    min-height: var(--touch-min);
    display: inline-flex;
    align-items: center;
  }

  .modal {
    padding: 0.5rem;
    padding-bottom: calc(0.5rem + var(--safe-bottom));
  }

  /* WIR status indicators + refresh/pagination: compact best-fit stack */
  .records-view-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .status-dashboard {
    width: 100%;
    gap: 0.28rem;
  }

  .status-stat {
    padding: 0.32rem 0.2rem 0.28rem;
  }

  .status-stat-label {
    font-size: 0.5rem;
    letter-spacing: 0.04em;
  }

  .status-stat-value {
    font-size: 0.95rem;
  }

  .view-controls {
    margin-left: 0;
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.3rem;
  }

  .view-controls .page-size-label {
    gap: 0.25rem;
    font-size: 0.75rem;
    flex: 0 1 auto;
    min-width: 0;
  }

  .view-controls .page-size-prefix {
    display: none;
  }

  .view-controls .page-size-suffix {
    display: none;
  }

  .view-controls .page-size-select {
    padding: 0.35rem 0.35rem;
    font-size: 0.82rem;
    min-width: 3.25rem;
  }

  .view-controls #refresh-btn {
    flex: 0 0 auto;
    padding-inline: 0.55rem;
  }

  .view-controls .pagination {
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 0.25rem;
    min-width: 0;
  }

  .view-controls .pagination .btn-sm {
    flex: 0 0 auto;
    padding-inline: 0.45rem;
  }

  .view-controls .page-info {
    min-width: 0;
    flex: 0 1 auto;
    font-size: 0.72rem;
    white-space: nowrap;
  }
}

/* Touch devices (Android / phones): readable inputs, no focus-zoom jump */
@media (pointer: coarse) {
  select,
  textarea,
  input[type='text'],
  input[type='email'],
  input[type='password'],
  input[type='search'],
  input[type='number'],
  .adaptive-select-trigger,
  .records-search,
  .page-size-select,
  .status-select,
  .serial-input,
  .wir-count-input {
    font-size: max(1rem, 16px);
  }

  .btn-text,
  .btn-sm,
  .status-select,
  .serial-input,
  .records-fit-view .btn-sm,
  .records-fit-view .status-select,
  .records-fit-view .serial-input {
    min-height: var(--touch-min);
  }

  .btn-text {
    display: inline-flex;
    align-items: center;
  }

  .records-fit-view .btn-sm {
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
  }

  .records-fit-view .status-select,
  .records-fit-view .serial-input {
    font-size: max(1rem, 16px);
    padding: 0.45rem 0.4rem;
  }
}

/* Narrow phones: title on its own row; keep actions on one tidy row */
@media (max-width: 480px) {
  .header {
    padding: 0.55rem var(--page-pad) 0.6rem;
  }

  .header-inner {
    gap: 0.45rem;
  }

  .header-inner > div:first-child {
    flex: 1 1 100%;
  }

  .header-actions {
    flex: 1 1 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
  }

  /* Storage mode is clear from connectivity; drop it to free space */
  .badge.storage {
    display: none;
  }

  .badge.user {
    max-width: min(7.25rem, 34vw);
    font-size: 0.72rem;
    padding: 0.18rem 0.45rem;
  }

  .issues-trigger {
    padding: 0.22rem 0.55rem;
    font-size: 0.72rem;
    gap: 0.25rem;
    flex-shrink: 0;
  }

  .connection-dot {
    width: 1.5rem;
    height: 1.5rem;
  }

  .header-actions > .btn-text {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 0.75rem;
  }

  .admin-page .header-actions > .btn-text {
    font-size: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

th,
td {
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem !important;
}

.empty.error {
  color: var(--error);
}

.pwa-install-banner {
  position: fixed;
  left: max(0.75rem, var(--safe-left));
  right: max(0.75rem, var(--safe-right));
  bottom: calc(4.5rem + var(--safe-bottom));
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  background: linear-gradient(135deg, #0f3d5e 0%, #1a5f8a 100%);
  color: #fff;
  box-shadow: 0 16px 40px rgba(15, 61, 94, 0.35);
}

.connectivity-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem 0.75rem;
  padding: 0.4rem 0.85rem;
  border-bottom: 1px solid transparent;
  font-size: 0.86rem;
}

.connectivity-banner .connectivity-title {
  display: none;
}

.connectivity-status {
  font-size: 0.84rem;
  line-height: 1.3;
}

.connectivity-copy {
  display: block;
  min-width: 0;
  flex: 1 1 12rem;
}

.connectivity-banner[hidden] {
  display: none !important;
}

.connectivity-banner.is-offline {
  background: #fff7ed;
  border-bottom-color: #fdba74;
  color: #9a3412;
}

.connectivity-banner.is-pending,
.connectivity-banner.is-syncing {
  background: #eff6ff;
  border-bottom-color: #93c5fd;
  color: #1e3a8a;
}

.connectivity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

/* Issues & notifications center */
.issues-center {
  position: relative;
  display: flex;
  align-items: center;
}

.issues-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.issues-trigger.has-failed {
  border-color: #fecaca;
  background: rgba(185, 28, 28, 0.35);
}

.issues-trigger.has-items:not(.has-failed) {
  border-color: #93c5fd;
  background: rgba(37, 99, 235, 0.28);
}

.issues-badge {
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #fff;
  color: #0f3d5e;
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.issues-badge.is-alert {
  background: #fee2e2;
  color: #b91c1c;
}

.issues-panel {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  width: min(26rem, calc(100vw - 1.5rem));
  max-height: min(70vh, 32rem);
  display: flex;
  flex-direction: column;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(15, 61, 94, 0.22);
  z-index: 60;
  overflow: hidden;
}

.issues-panel[hidden] {
  display: none !important;
}

.issues-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 0.95rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.issues-panel-head strong {
  display: block;
  font-size: 0.95rem;
}

.issues-panel-sub {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.issues-panel-head .btn-text {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.issues-panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.issues-online-pill {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
}

.issues-online-pill.is-on {
  background: #dcfae6;
  color: #087a48;
}

.issues-online-pill.is-off {
  background: #ffedd5;
  color: #9a3412;
}

.issues-counts {
  font-size: 0.78rem;
  color: var(--muted);
  flex: 1 1 auto;
}

.issues-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.issues-panel-body {
  overflow: auto;
  padding: 0.55rem 0.75rem 0.75rem;
  display: grid;
  gap: 0.55rem;
}

.issues-section-title {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.issues-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  align-items: start;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

.issues-card.is-error {
  border-color: #fecaca;
  background: #fff7f7;
}

.issues-card.is-pending {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.issues-card.is-success {
  border-color: #bbf7d0;
  background: #f3fbf6;
}

.issues-card.is-info {
  border-color: #e2e8f0;
  background: #f8fafc;
}

.issues-card-main {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}

.issues-card-main strong {
  font-size: 0.86rem;
  line-height: 1.35;
}

.issues-card-main p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.issues-card-main time {
  font-size: 0.7rem;
  color: #94a3b8;
}

.issues-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.issues-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
}

.issues-tag.quiet {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #64748b;
}

.issues-card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: stretch;
}

.issues-empty {
  text-align: center;
  padding: 1.4rem 0.75rem;
  color: var(--muted);
}

.issues-empty strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.issues-empty p {
  margin: 0;
  font-size: 0.82rem;
}

.issues-quiet-box {
  padding: 0.45rem 0.85rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
  display: grid;
  gap: 0.3rem;
}

.conflict-apply-all {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0.35rem 0 0.65rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text);
  cursor: pointer;
}

.issues-quiet-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.issues-quiet-help {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

.issues-card.is-openable {
  cursor: pointer;
}

.issues-card.is-openable:hover {
  border-color: #93c5fd;
}

.issues-history-card {
  opacity: 0.92;
}

.conflict-panel {
  max-width: min(40rem, calc(100vw - 1.5rem));
}

.conflict-table-wrap {
  overflow: auto;
  max-height: min(50vh, 22rem);
  margin: 0.5rem 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.conflict-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.conflict-table th,
.conflict-table td {
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.conflict-table th {
  background: #f8fafc;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  position: sticky;
  top: 0;
}

.conflict-local {
  background: #f0f9ff;
}

.conflict-server {
  background: #fff7ed;
}

.conflict-actions {
  flex-wrap: wrap;
}

.issues-panel-foot {
  border-top: 1px solid var(--border);
  padding: 0.65rem 0.85rem 0.8rem;
  background: #f8fafc;
}

.issues-panel-foot p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

@media (max-width: 640px) {
  .issues-panel {
    position: fixed;
    left: max(0.75rem, var(--safe-left));
    right: max(0.75rem, var(--safe-right));
    top: calc(4.25rem + var(--safe-top));
    width: auto;
    max-height: min(75vh, 34rem);
  }

  .issues-card {
    grid-template-columns: 1fr;
  }

  .issues-card-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.pwa-install-copy {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.pwa-install-copy strong {
  font-size: 0.95rem;
}

.pwa-install-copy span {
  font-size: 0.8rem;
  opacity: 0.9;
}

.pwa-install-actions {
  display: flex;
  gap: 0.45rem;
}

.pwa-install-banner .btn.secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.pwa-install-banner .btn.primary {
  background: #f97316;
  border-color: #f97316;
}

