@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --secondary: #10B981;
  --bg-color: #0f172a;
  --surface: #1e293b;
  --surface-border: #334155;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --danger: #ef4444;
  --radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  background-image: radial-gradient(circle at top right, #312e81 0%, transparent 40%),
                    radial-gradient(circle at bottom left, #064e3b 0%, transparent 40%);
  background-attachment: fixed;
}

header {
  text-align: center;
  margin-bottom: 2rem;
  animation: fadeInDown 0.8s ease-out;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(to right, #818cf8, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

header p {
  color: var(--text-muted);
  font-size: 1.1rem;
}


.file-input {
  display: none;
}

.upload-btn {
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 1rem;
  display: inline-block;
}

.upload-btn:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 0 15px rgba(79, 70, 229, 0.5);
}

.dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  animation: fadeIn 0.5s ease-in;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.stat-card {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.2);
}

.stat-title {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-main);
}

.table-container {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.table-controls {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--surface-border);
  background: rgba(15, 23, 42, 0.5);
}

.search-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-family: inherit;
  width: 300px;
  transition: var(--transition);
}

.search-box:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.table-wrapper {
  overflow-x: auto;
  max-height: 600px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  white-space: nowrap;
}

th {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-muted);
  font-weight: 600;
  padding: 1rem 1.5rem;
  font-size: 0.875rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--surface-border);
  font-size: 0.9rem;
}

tbody tr {
  transition: var(--transition);
}

tbody tr:hover {
  background: rgba(51, 65, 85, 0.5);
}

tbody tr:last-child td {
  border-bottom: none;
}

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

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5); 
}
::-webkit-scrollbar-thumb {
  background: var(--surface-border); 
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary); 
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  justify-content: space-between;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toolbar-left .upload-btn {
  margin-top: 0;
}

.upload-btn-delay {
  background-color: #f59e0b !important;
}
.upload-btn-delay:hover {
  background-color: #d97706 !important;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.5) !important;
}

.file-name-display {
  margin-left: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.room-mgmt-btn {
  background-color: var(--secondary) !important;
}
.room-mgmt-btn:hover {
  background-color: #059669 !important;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.5) !important;
}

.history-btn {
  background-color: #8b5cf6 !important;
}
.history-btn:hover {
  background-color: #7c3aed !important;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.5) !important;
}

.save-btn {
  background-color: #06b6d4 !important;
}
.save-btn:hover {
  background-color: #0891b2 !important;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.5) !important;
}

.import-btn {
  background-color: #e11d48 !important;
}
.import-btn:hover {
  background-color: #be123c !important;
  box-shadow: 0 0 15px rgba(225, 29, 72, 0.5) !important;
}



.modal-history {
  max-width: 650px !important;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 500px;
  overflow-y: auto;
}

.history-item {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 1rem;
  transition: var(--transition);
}

.history-item:hover {
  border-color: #8b5cf6;
  background: rgba(15, 23, 42, 0.8);
}

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

.history-item-type {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.history-item-type.primary {
  background: rgba(79, 70, 229, 0.3);
  color: #818cf8;
}

.history-item-type.delayed {
  background: rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.history-item-type.manual {
  background: rgba(6, 182, 212, 0.3);
  color: #22d3ee;
}

.history-item-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-item-details {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.history-item-details span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.history-item-actions {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.restore-btn {
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.restore-btn:hover {
  background-color: var(--primary-hover);
}

.delete-history-btn {
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid var(--surface-border);
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.delete-history-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.history-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: fadeInUp 0.3s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--surface-border);
}

.modal-header h3 {
  font-weight: 600;
  font-size: 1.1rem;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  padding: 0 0.25rem;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

/* Room List */
.room-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.room-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 8px;
  transition: var(--transition);
}

.room-list-item:hover {
  background: rgba(51, 65, 85, 0.5);
}

.room-list-item span {
  font-weight: 500;
}

/* Add Room Form */
.add-room-form {
  display: flex;
  gap: 0.75rem;
  border-top: 1px solid var(--surface-border);
  padding-top: 1.25rem;
}

.room-mgmt-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition);
}

.room-mgmt-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

/* Delete Button */
.delete-btn {
  background-color: var(--danger);
  color: white;
  border: none;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.delete-btn:hover {
  background-color: #dc2626;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.delete-row-btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

/* Add Button */
.add-btn {
  background-color: var(--secondary);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.add-btn:hover {
  background-color: #059669;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

/* Toolbar User Area */
.toolbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-chip {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--surface-border);
  color: var(--text-muted);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
}

.admin-btn {
  background-color: #8b5cf6 !important;
}
.admin-btn:hover {
  background-color: #7c3aed !important;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.5) !important;
}

.logout-btn {
  background-color: transparent !important;
  border: 1px solid var(--danger) !important;
  color: var(--danger) !important;
  margin-top: 0 !important;
}
.logout-btn:hover {
  background-color: rgba(239, 68, 68, 0.15) !important;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4) !important;
}

/* Auth Modal */
.modal-auth {
  max-width: 400px !important;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.auth-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 0.4rem;
}

.auth-submit {
  width: 100%;
  padding: 0.7rem 1.2rem;
  font-size: 1rem;
  margin-top: 0.5rem;
}

.auth-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.auth-switch-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.4rem;
  transition: var(--transition);
}

.auth-switch-btn:hover {
  color: #818cf8;
  text-decoration: underline;
}

.auth-tip {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  opacity: 0.7;
}

/* User Create Form */
.user-create-form {
  flex-wrap: wrap;
}

.user-create-form .room-mgmt-input {
  flex: 1 1 40%;
  min-width: 120px;
}

/* Admin badge in user list */
.history-item-type.admin {
  background: rgba(139, 92, 246, 0.3);
  color: #a78bfa;
}

/* Navigation Page */
.nav-container {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  animation: fadeIn 0.5s ease-in;
}

.nav-header {
  text-align: center;
}

.nav-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(to right, #818cf8, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.nav-header p {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.nav-section {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.nav-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  letter-spacing: 0.05em;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.entry-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 1.75rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-main);
  transition: var(--transition);
}

.entry-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3);
}

.entry-card-primary {
  border-color: rgba(79, 70, 229, 0.5);
}

.entry-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.entry-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.link-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.link-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  transition: var(--transition);
}

.link-item:hover {
  border-color: var(--secondary);
  background: rgba(15, 23, 42, 0.8);
}

.link-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-decoration: none;
  color: var(--text-main);
  min-width: 0;
}

.link-name {
  font-weight: 600;
}

.link-url {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-add-form {
  display: flex;
  gap: 0.75rem;
  border-top: 1px solid var(--surface-border);
  padding-top: 1.25rem;
}

.link-add-form .room-mgmt-input {
  flex: 1;
}

.empty-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem 0;
}

.nav-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
}

.nav-footer .logout-btn {
  margin-top: 0;
}

/* Dashboard header back link */
.header-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.back-home-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  transition: var(--transition);
}

.back-home-link:hover {
  color: var(--text-main);
  border-color: var(--primary);
}

/* Meter activation status badges */
.status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  background: rgba(51, 65, 85, 0.5);
  color: var(--text-muted);
}

.status-new {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
}

.status-checkout {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
}

.status-guard {
  background: rgba(139, 92, 246, 0.25);
  color: #a78bfa;
}

.status-canteen {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

/* ===== 交费数据表单 ===== */
.jf-form-section {
  background: var(--surface, rgba(30, 41, 59, 0.6));
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem 1.25rem;
  margin-bottom: 1.25rem;
}

.jf-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem 1rem;
  align-items: end;
}

.jf-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.jf-field label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.jf-field .room-mgmt-input {
  width: 100%;
  flex: none;
}

.jf-field-action {
  justify-content: flex-end;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.jf-field-action .add-btn {
  width: auto;
  flex: 1;
}

.jf-field-action #scanBtn {
  flex: 1;
  padding: 0.6rem 1.2rem;
}

/* 相机扫描录入（拍照 OCR） */
.scan-camera {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin: 0 auto 0.5rem;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-camera video,
.scan-camera canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.scan-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.scan-actions .add-btn,
.scan-actions .upload-btn {
  flex: 1;
  font-size: 0.9rem;
  padding: 0.6rem 0.8rem;
}

.ocr-progress {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.3rem 0;
}

.modal-scan {
  max-width: 420px;
}

.scan-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.scan-result {
  min-height: 1.5em;
  font-size: 0.9rem;
  margin: 0.5rem 0;
  text-align: center;
}

.scan-result-ok {
  color: var(--secondary);
}

.scan-result-error {
  color: var(--danger);
}

.amount-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--secondary);
}

/* ============================================================
   移动端自适应 (Mobile Responsive)
   ============================================================ */

/* 防止 iOS 聚焦输入框时自动放大页面 */
@media (max-width: 768px) {
  input, select, textarea, button {
    font-size: 16px;
  }
}

@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

  header h1,
  .nav-header h1 {
    font-size: 1.8rem;
  }

  header p,
  .nav-header p {
    font-size: 0.95rem;
  }

  /* 顶部标题与返回按钮在窄屏下竖排 */
  .header-row {
    flex-direction: column;
    gap: 0.6rem;
    text-align: center;
  }

  .dashboard {
    gap: 1rem;
  }

  /* 统计卡片：窄屏最少 140px，极窄时单列 */
  .stats {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
  }

  .stat-card {
    padding: 1.1rem;
  }

  .stat-value {
    font-size: 1.6rem;
  }

  /* 工具栏：允许换行，按钮自然折行 */
  .toolbar {
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem;
    justify-content: flex-start;
  }

  .toolbar-left {
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .toolbar-user {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  /* 工具栏内独立的搜索框容器占满整行 */
  .toolbar > div:not(.toolbar-left):not(.toolbar-user) {
    flex: 1 1 100%;
  }

  /* 表格控制栏与搜索框 */
  .table-controls {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .search-box {
    width: 100%;
    flex: 1 1 200px;
  }

  .table-wrapper {
    max-height: 70vh;
  }

  /* 窄屏下将数据表转换为卡片布局，便于阅读 */
  .table-wrapper {
    overflow-x: visible;
  }

  table {
    white-space: normal;
  }

  thead {
    display: none;
  }

  table, tbody, tr, td {
    display: block;
    width: 100%;
  }

  tbody tr {
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    padding: 0.4rem 0.2rem;
    background: rgba(15, 23, 42, 0.4);
  }

  tbody tr:hover {
    background: rgba(15, 23, 42, 0.4);
  }

  td {
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.55rem 0.85rem;
    text-align: right;
  }

  td:not([data-label])::before {
    content: '';
  }

  td[data-label]::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    flex-shrink: 0;
  }

  td[colspan] {
    display: block;
    text-align: center;
  }

  td[colspan]::before {
    content: none;
  }

  /* 导航入口卡片单列 */
  .entry-grid {
    grid-template-columns: 1fr;
  }

  .entry-card {
    padding: 1.25rem;
  }

  .nav-section {
    padding: 1.1rem;
  }

  /* 表单行在窄屏下竖排，输入框占满宽度 */
  .add-room-form,
  .link-add-form,
  .user-create-form {
    flex-direction: column;
  }

  .user-create-form .room-mgmt-input {
    flex: 1 1 100%;
  }

  /* 交费记录新增表单单列 */
  .jf-form {
    grid-template-columns: 1fr;
  }

  .jf-field-action {
    justify-content: stretch;
    flex-direction: row;
  }

  .jf-field-action .add-btn {
    width: auto;
    flex: 1 1 0;
  }

  /* 弹窗在窄屏下更紧凑 */
  .modal {
    width: 95%;
  }

  .modal-body,
  .modal-header {
    padding: 1.1rem;
  }

  .history-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0.6rem;
  }

  header h1,
  .nav-header h1 {
    font-size: 1.5rem;
  }

  .upload-btn {
    font-size: 0.85rem;
    padding: 0.65rem 1rem;
  }

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

  th,
  td {
    padding: 0.75rem 0.85rem;
    font-size: 0.82rem;
  }

  .toolbar-left .upload-btn {
    flex: 1 1 100%;
  }
}
