/* ===== CSS Variables (SRS §7.4) ===== */
:root {
  --primary: #3B7EF8;
  --primary-light: #EBF2FF;
  --primary-dark: #2563EB;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #6366F1;
  --bg-page: #F2F4F7;
  --bg-card: #FFFFFF;
  --bg-sidebar: #1E293B;
  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --text-inverse: #FFFFFF;
  --border-default: #E5E7EB;
  --border-light: #F0F0F0;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-family);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow: hidden;
}

/* ===== Login Page ===== */
.login-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #1E293B 0%, #334155 100%);
}
.login-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: 48px 40px; width: 400px; box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.login-card .subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 32px; }
.login-card .form-group { margin-bottom: 20px; }
.login-card label { display: block; font-size: 13px; font-weight: 500; color: var(--text-primary); margin-bottom: 6px; }
.login-card input {
  width: 100%; height: 40px; border: 1px solid var(--border-default);
  border-radius: var(--radius-md); padding: 0 12px; font-size: 14px;
  font-family: var(--font-family); transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.login-card input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,126,248,0.1);
}
.login-card .btn-login {
  width: 100%; height: 40px; background: var(--primary); color: var(--text-inverse);
  border: none; border-radius: var(--radius-md); font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: var(--font-family); transition: background var(--transition-fast);
  margin-top: 8px;
}
.login-card .btn-login:hover { background: var(--primary-dark); }
.login-card .login-error { color: var(--danger); font-size: 12px; margin-top: 12px; text-align: center; display: none; }

/* ===== Main App Layout ===== */
.app-container { display: none; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px; background: var(--bg-sidebar); height: 100vh;
  position: fixed; left: 0; top: 0; display: flex; flex-direction: column; z-index: 100;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden;
}
/* Sidebar toggle button — positioned outside sidebar to avoid clip */
.sidebar-toggle-btn {
  position: fixed; left: 220px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 36px; background: var(--bg-sidebar);
  border: 1px solid rgba(255,255,255,0.12); border-left: none;
  border-radius: 0 4px 4px 0; color: #94A3B8; cursor: pointer;
  font-size: 8px; display: flex; align-items: center; justify-content: center;
  z-index: 200; transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.15s, color 0.15s;
  padding: 0; line-height: 1;
}
.sidebar-toggle-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.sidebar-toggle-btn .toggle-icon { transition: transform 0.25s; }
.sidebar.collapsed + * + .sidebar-toggle-btn,
.sidebar.collapsed ~ .sidebar-toggle-btn { left: 60px; }
.sidebar.collapsed ~ .sidebar-toggle-btn .toggle-icon { transform: rotate(180deg); }
/* Collapsed sidebar */
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-group-title,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-footer .user-name,
.sidebar.collapsed .btn-change-pwd,
.sidebar.collapsed .btn-logout { display: none; }
.sidebar.collapsed .sidebar-logo { padding: 16px 8px; justify-content: center; }
.sidebar.collapsed .nav-item { padding: 10px; justify-content: center; gap: 0; border-left: none; }
.sidebar.collapsed .nav-item .nav-icon { width: auto; font-size: 18px; }
.sidebar.collapsed .nav-item .nav-badge { position: absolute; top: 4px; right: 4px; font-size: 9px; padding: 1px 4px; min-width: 14px; }
.sidebar.collapsed .sidebar-nav { padding: 8px 4px; }
.sidebar.collapsed .sidebar-footer { padding: 8px; justify-content: center; }
.sidebar.collapsed .sidebar-footer .user-avatar { margin: 0; }
.sidebar-logo {
  padding: 20px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08); cursor: pointer; transition: opacity 0.15s;
}
.sidebar-logo:hover { opacity: 0.8; }
.sidebar-logo .logo-icon { width: 32px; height: 32px; background: var(--primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.sidebar-logo .logo-text { color: var(--text-inverse); font-size: 15px; font-weight: 600; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-nav .nav-group { margin-bottom: 4px; }
.sidebar-nav .nav-group-title {
  font-size: 11px; color: rgba(255,255,255,0.3); text-transform: uppercase;
  letter-spacing: 0.5px; padding: 12px 12px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-md); color: #94A3B8; font-size: 13px;
  cursor: pointer; transition: all var(--transition-fast); border-left: 3px solid transparent;
  margin-bottom: 2px; text-decoration: none; position: relative;
}
.nav-item:hover { color: #E2E8F0; background: rgba(255,255,255,0.04); }
.nav-item.active {
  color: var(--text-inverse); background: rgba(59,126,248,0.15);
  border-left-color: var(--primary);
}
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto; background: var(--danger); color: white; font-size: 10px;
  padding: 1px 6px; border-radius: 10px; font-weight: 600; min-width: 18px; text-align: center;
}
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-user { display: flex; align-items: center; gap: 8px; }
.sidebar-user .user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--info);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 600;
}
.sidebar-user .user-name { color: #CBD5E1; font-size: 12px; }
.sidebar-footer .btn-logout {
  background: none; border: none; color: #94A3B8; cursor: pointer;
  font-size: 12px; padding: 4px 8px; border-radius: var(--radius-sm); font-family: var(--font-family);
  transition: all var(--transition-fast);
}
.sidebar-footer .btn-logout:hover { color: var(--danger); background: rgba(239,68,68,0.1); }
.sidebar-footer .btn-change-pwd {
  background: none; border: 1px solid #475569; color: #94A3B8; cursor: pointer;
  font-size: 12px; padding: 3px 8px; border-radius: var(--radius-sm); font-family: var(--font-family);
  transition: all var(--transition-fast);
}
.sidebar-footer .btn-change-pwd:hover { border-color: var(--primary); color: var(--primary); }
.sidebar-footer .sidebar-actions { display: flex; gap: 6px; }

/* Main Content */
.main-content {
  margin-left: 220px; height: 100vh; padding: 20px 24px 4px;
  display: flex; flex-direction: column; overflow-y: auto; min-width: 0;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.collapsed ~ .main-content,
.sidebar.collapsed + .main-content { margin-left: 60px; }

/* ===== Accordion Nav Groups ===== */
.nav-group.collapsible { margin-bottom: 2px; }
.nav-group-toggle {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-md); color: #94A3B8; font-size: 13px;
  cursor: pointer; transition: all var(--transition-fast); border-left: 3px solid transparent;
  position: relative;
}
.nav-group-toggle:hover { color: #E2E8F0; background: rgba(255,255,255,0.04); }
.nav-group-toggle .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-group-toggle .nav-arrow {
  font-size: 10px; margin-left: auto; transition: transform 0.2s;
  color: rgba(255,255,255,0.3);
}
.nav-group.expanded .nav-group-toggle .nav-arrow { transform: rotate(180deg); }
.nav-group-toggle .nav-group-badge {
  margin-left: 4px; font-size: 10px; padding: 1px 6px; border-radius: 10px;
  font-weight: 600; min-width: 18px; text-align: center;
  background: var(--danger); color: white;
}

/* Sub-menu */
.nav-sub {
  overflow: hidden; max-height: 0; transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-group.expanded .nav-sub { max-height: 600px; }
.nav-sub-item {
  padding-left: 44px !important;
}
.nav-sub-item .nav-icon { font-size: 14px; width: 18px; }

/* ===== Flyout (collapsed state) ===== */
.nav-flyout {
  position: fixed; z-index: 300; background: #1E293B; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  min-width: 160px; padding: 8px 0; opacity: 0; visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s; pointer-events: none;
}
.nav-flyout.visible { opacity: 1; visibility: visible; pointer-events: auto; }
.nav-flyout-title {
  font-size: 11px; color: rgba(255,255,255,0.35); padding: 4px 14px 8px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.nav-flyout-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px;
  color: #94A3B8; font-size: 12px; cursor: pointer; transition: all 0.12s;
}
.nav-flyout-item:hover { color: #E2E8F0; background: rgba(255,255,255,0.06); }
.nav-flyout-item .nav-badge {
  margin-left: auto; background: var(--danger); color: white; font-size: 9px;
  padding: 1px 5px; border-radius: 10px; font-weight: 600; min-width: 14px; text-align: center;
}
.nav-flyout-sep { height: 1px; background: rgba(255,255,255,0.06); margin: 4px 0; }

/* Collapsed sidebar — accordion behavior */
.sidebar.collapsed .nav-arrow { display: none; }
.sidebar.collapsed .nav-group-badge { display: none; }
.sidebar.collapsed .nav-sub { display: none; }
.sidebar.collapsed .nav-group-toggle {
  justify-content: center; padding: 10px; gap: 0;
}
.sidebar.collapsed .nav-group-toggle .nav-icon { width: auto; font-size: 18px; }
.sidebar.collapsed .nav-group-toggle .nav-label { display: none; }
.sidebar.collapsed .nav-group.collapsible { margin-bottom: 2px; }
/* When collapsed, group toggle gets title attribute for tooltip */
.page { display: none; }
.page.active { display: flex; flex-direction: column; flex: 1; min-height: 0; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Card — full-height flex column within each page */
.page.active > .card { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.page.active .card-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.page.active .card-body.no-padding { padding: 0; }
.page.active .table-wrap { flex: 1; overflow: auto; }
.page.active .pagination { flex-shrink: 0; }
.page.active .filter-bar { flex-shrink: 0; }
.page.active .resource-breadcrumb { flex-shrink: 0; }

/* Card / Panel */
.card {
  background: var(--bg-card); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.help-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; background: #D1D5DB;
  color: white; font-size: 10px; font-weight: 700; cursor: help;
  margin-left: 6px; vertical-align: middle; transition: background 0.15s;
}
.help-icon:hover { background: var(--primary); }
.card-body { padding: 20px; }
.card-body.no-padding { padding: 0; }

/* Stats Row */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-card {
  background: var(--bg-card); border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  padding: 20px; display: flex; flex-direction: column; gap: 6px; cursor: pointer;
  transition: all var(--transition-fast);
}
.stat-card.alert { border-left: 3px solid var(--warning); }
.stat-card .stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { font-size: 12px; font-weight: 500; }
.stat-card .stat-sub { font-size: 11px; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); }
.stat-icon.green { background: #D1FAE5; }
.stat-icon.yellow { background: #FEF3C7; }
.stat-icon.purple { background: #E0E7FF; }
.stat-icon.blacklist { background: #FEE2E2; }
.stat-icon.teal { background: #CCFBF1; color: #0F766E; }

/* Filter Bar */
.filter-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
}
.filter-bar .search-input {
  width: 240px; height: 32px; border: 1px solid var(--border-default);
  border-radius: var(--radius-md); padding: 0 10px 0 32px; font-size: 13px;
  font-family: var(--font-family); background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 10px center no-repeat;
  transition: all var(--transition-fast);
}
.filter-bar .search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,126,248,0.1); }
.filter-bar select {
  height: 32px; border: 1px solid var(--border-default); border-radius: var(--radius-md);
  padding: 0 28px 0 10px; font-size: 13px; font-family: var(--font-family);
  background: white; cursor: pointer; color: var(--text-primary);
  appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; min-width: 120px;
}
.filter-bar select:focus { outline: none; border-color: var(--primary); }
.filter-bar .filter-count { font-size: 12px; color: var(--text-secondary); margin-left: auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px;
  padding: 0 16px; border-radius: var(--radius-md); font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; font-family: var(--font-family);
  transition: all var(--transition-fast); white-space: nowrap; text-decoration: none;
}
.btn-primary { background: var(--primary); color: var(--text-inverse); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: white; color: var(--text-primary); border: 1px solid var(--border-default); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #D97706; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #4F46E5; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn + .btn { margin-left: 8px; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th {
  background: #F8FAFC; color: var(--text-secondary); font-size: 12px;
  font-weight: 500; text-align: left; padding: 0 12px; height: 40px;
  border-bottom: 1px solid var(--border-light); white-space: nowrap;
}
table td {
  padding: 10px 12px; font-size: 13px; color: var(--text-primary);
  border-bottom: 1px solid var(--border-light); white-space: nowrap;
}
table tbody tr { transition: background var(--transition-fast); }
table tbody tr:hover { background: var(--primary-light); }
table .col-actions { text-align: right; }
table .col-actions .btn + .btn { margin-left: 4px; }
/* TTS音色表格自动换行 */
#ttsVoiceTable td { white-space: normal; word-break: break-word; vertical-align: top; }
#ttsVoiceTable td:last-child { white-space: nowrap; }

.clickable-name { color: var(--primary); cursor: pointer; font-weight: 600; }
.clickable-name:hover .copy-word-icon, tr:hover .copy-word-icon { display: inline !important; }
.clickable-name:hover { text-decoration: underline; color: var(--primary-dark); }

/* ===== Clickable name cell (v2.51) ===== */
.clickable-name { color: var(--primary); cursor: pointer; font-weight: 600; }
.clickable-name:hover .copy-word-icon, tr:hover .copy-word-icon { display: inline !important; }
.clickable-name:hover { text-decoration: underline; color: var(--primary-dark); }

/* ===== Column Resize (drag to resize) ===== */
th { position: relative; }
.col-resize-handle {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 5px; cursor: col-resize; z-index: 2;
  background: transparent; transition: background 0.15s;
}
.col-resize-handle:hover,
.col-resize-handle.dragging {
  background: var(--primary);
}
body.resizing-col { user-select: none; }
body.resizing-col * { cursor: col-resize !important; }
.col-resize-ghost {
  position: absolute; top: 0; height: 100%;
  width: 2px; background: var(--primary); z-index: 3;
  pointer-events: none;
}

/* Status Badge */
.status-badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 500;
}
.status-badge.pending { background: #FEF3C7; color: #92400E; }
.status-badge.online { background: #D1FAE5; color: #065F46; }
.status-badge.offline { background: #F3F4F6; color: #4B5563; }
.status-badge.review { background: var(--primary-light); color: var(--primary); }
.status-badge.blacklist { background: #FEE2E2; color: #991B1B; }

/* Word type badge */
.wt-badge { display:inline-block; padding:2px 8px; border-radius:4px; font-size:11px; font-weight:500; white-space:nowrap; }

/* Tag Badge */
.tag-badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 500; margin: 1px 2px;
}
.tag-blue { background: #DBEAFE; color: #1E40AF; }
.tag-green { background: #D1FAE5; color: #065F46; }
.tag-orange { background: #FED7AA; color: #9A3412; }
.tag-purple { background: #E0E7FF; color: #3730A3; }
.tag-red { background: #FEE2E2; color: #991B1B; }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 16px 20px;
}
.pagination button {
  min-width: 32px; height: 32px; border: 1px solid var(--border-default);
  background: white; border-radius: var(--radius-sm); font-size: 13px;
  color: var(--text-primary); cursor: pointer; font-family: var(--font-family);
  transition: all var(--transition-fast); display: flex; align-items: center; justify-content: center;
}
.pagination button:hover:not(.active):not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination .page-info { font-size: 12px; color: var(--text-secondary); margin: 0 8px; }

/* ===== Lightbox ===== */
.lightbox-overlay { display:none; position:fixed; z-index:9999; left:0;top:0;width:100%;height:100%;
  background:rgba(0,0,0,0.92); justify-content:center; align-items:center; }
.lightbox-overlay.show { display:flex; }
.lightbox-close { position:absolute; top:20px; right:30px; color:#fff; font-size:36px; cursor:pointer; z-index:1; }
.lightbox-close:hover { color:#ef4444; }
.lightbox-prev, .lightbox-next { position:absolute; top:50%; transform:translateY(-50%); color:#fff; font-size:48px;
  cursor:pointer; padding:20px; user-select:none; z-index:1; }
.lightbox-prev { left:10px; } .lightbox-next { right:10px; }
.lightbox-prev:hover, .lightbox-next:hover { color:#3B7EF8; }
.lightbox-img { max-width:90%; max-height:85%; object-fit:contain; }
.lightbox-info { position:absolute; bottom:20px; color:#ccc; font-size:13px; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; animation: fadeIn 0.2s ease; }
.modal {
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 640px;
  max-height: 85vh; display: flex; flex-direction: column;
  animation: slideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal.wide { max-width: 1050px; }
.modal.fullscreen { position: fixed !important; inset: 0 !important; max-width: none !important; max-height: 100vh !important; width: 100vw !important; height: 100vh !important; border-radius: 0 !important; margin: 0 !important; transform: none !important; }
.modal.fullscreen .modal-body { max-height: none; }
.preview-wide { max-width: 95vw !important; width:95vw; }
.preview-full { max-width: 100vw !important; width:100vw; height:100vh !important; max-height:100vh !important; border-radius:0 !important; }
.modal.compact { max-width: 420px; }
.modal.compact .modal-header { padding: 10px 16px; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-default);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 18px; color: var(--text-secondary);
  cursor: pointer; width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; transition: all var(--transition-fast);
}
.modal-close:hover { background: #F3F4F6; color: var(--text-primary); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--border-default);
}

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full-width { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; }
.form-group label { font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 4px; }
.form-group label .required { color: var(--danger); margin-left: 2px; }
.form-group input, .form-group select, .form-group textarea {
  height: 32px; border: 1px solid var(--border-default);
  border-radius: var(--radius-md); padding: 0 10px; font-size: 13px;
  font-family: var(--font-family); transition: all var(--transition-fast);
}
.form-group textarea { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,126,248,0.1);
}
.form-group .helper { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.form-group .error-msg { font-size: 11px; color: var(--danger); margin-top: 2px; display: none; }

/* Checkbox group */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.checkbox-group label {
  display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 400;
  padding: 4px 10px; border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition-fast); user-select: none;
}
.checkbox-group label:hover { border-color: var(--primary); }
.checkbox-group input[type="checkbox"] { display: none; }
.checkbox-group input[type="checkbox"]:checked + span { font-weight: 600; }
.checkbox-group input[type="checkbox"]:checked + label,
.checkbox-group label:has(input:checked) { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* Toast */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px; border-radius: 8px; color: white; font-size: 13px;
  box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 8px;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1); max-width: 360px;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
.toast.warning { background: var(--warning); color: #1F2937; }

/* Empty State */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 14px; color: var(--text-secondary); }

/* Confirm Dialog */
.confirm-content { text-align: center; padding: 4px 0; }
.confirm-content .confirm-icon { font-size: 24px; margin-bottom: 8px; }
.confirm-content .confirm-text { font-size: 13px; color: var(--text-primary); line-height: 1.5; }
.confirm-content .confirm-sub { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

/* Detail View */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-grid .full-width { grid-column: 1 / -1; }
.detail-item { padding: 8px 0; }
.detail-item .detail-label { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 2px; }
.detail-item .detail-value { font-size: 13px; color: var(--text-primary); }
.detail-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-light); }
.detail-section h4 { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 10px; }

/* Detail/Edit — card-style sections */
.detail-card {
  background: #F8FAFC; border-radius: 8px; padding: 16px;
  border: 1px solid #EDF2F7; margin-bottom: 12px;
}
.detail-card-title {
  font-size: 11px; font-weight: 600; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.detail-word-title {
  font-size: 26px; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.detail-phonetics { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.detail-phonetics span { background: #F3F4F6; border-radius: 4px; padding: 1px 6px; margin: 0 2px; font-size: 12px; color: var(--text-tertiary); }
.detail-meta-row { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; align-items: center; }
.detail-meta-row .meta-item { display: flex; align-items: center; gap: 4px; }
.detail-meta-row .meta-label { color: var(--text-tertiary); font-size: 11px; }
.detail-meaning { font-size: 15px; color: var(--text-primary); line-height: 1.7; padding: 8px 0; }
.detail-meaning .meaning-item { padding: 4px 0; display: flex; gap: 8px; }
.detail-meaning .meaning-item .pos-tag { display: inline-block; background: var(--primary-light); color: var(--primary); border-radius: 4px; padding: 1px 6px; font-size: 11px; font-weight: 600; min-width: 32px; text-align: center; flex-shrink: 0; }
.detail-freq-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 12px; }
.detail-freq-row .freq-label { min-width: 60px; font-weight: 500; }
.detail-freq-row .freq-bar-wrap { flex: 1; height: 8px; background: #EDF2F7; border-radius: 4px; overflow: hidden; }
.detail-freq-row .freq-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s; }
.detail-freq-row .freq-val { min-width: 32px; text-align: right; font-weight: 600; color: var(--primary); }
.detail-freq-total { font-size: 16px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.phrase-card { background: white; border: 1px solid var(--border-light); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; }
.phrase-card .phrase-en { font-weight: 600; color: var(--primary); font-size: 13px; }
.phrase-card .phrase-cn { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }
.sentence-card { background: white; border: 1px solid var(--border-light); border-radius: 6px; padding: 12px; margin-bottom: 8px; }
.sentence-card .sentence-index { font-size: 10px; color: var(--text-tertiary); margin-bottom: 4px; }
.sentence-card .sentence-en { font-size: 13px; color: var(--text-primary); line-height: 1.6; }
.sentence-card .sentence-en .hl { color: var(--primary); font-weight: 600; }
.sentence-card .sentence-cn { font-size: 12px; color: var(--text-secondary); margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--border-light); }
.detail-info-row { display: flex; gap: 24px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; }
.empty-hint { color: var(--text-tertiary); font-size: 12px; font-style: italic; }
.edit-section { background: #F8FAFC; border-radius: 8px; padding: 14px; border: 1px solid #EDF2F7; margin-bottom: 12px; }
.edit-section-title { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.edit-row { display: flex; gap: 10px; margin-bottom: 8px; align-items: flex-start; }
.edit-row label { min-width: 60px; font-size: 12px; color: var(--text-secondary); padding-top: 6px; flex-shrink: 0; }
.edit-row input, .edit-row select, .edit-row textarea { flex: 1; height: 32px; border: 1px solid var(--border-default); border-radius: 6px; padding: 0 10px; font-size: 13px; font-family: var(--font-family); }
.edit-row textarea { height: auto; min-height: 60px; padding: 8px 10px; }
.edit-row input:focus, .edit-row select:focus, .edit-row textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,126,248,0.1); }
/* Dynamic edit rows for phrases/sentences */
.dynamic-rows { margin: 0; }
.dyn-row { display: flex; gap: 8px; align-items: center; padding: 8px; background: white; border: 1px solid var(--border-light); border-radius: 6px; margin-bottom: 6px; transition: all 0.2s; }
.dyn-row:hover { border-color: var(--border-default); }
.dyn-row input { flex: 1; height: 30px; border: 1px solid var(--border-default); border-radius: 4px; padding: 0 8px; font-size: 12px; font-family: var(--font-family); transition: border-color 0.15s; }
.dyn-row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(59,126,248,0.1); }
.dyn-row .dyn-index { color: var(--text-tertiary); font-size: 11px; font-weight: 600; width: 20px; text-align: center; flex-shrink: 0; }
.dyn-row .dyn-del { width: 26px; height: 26px; border: none; background: transparent; color: #9CA3AF; font-size: 14px; cursor: pointer; border-radius: 4px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.15s; }
.dyn-row .dyn-del:hover { background: #FEE2E2; color: var(--danger); }
.dyn-add-btn { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border: 1px dashed var(--border-default); background: transparent; color: var(--primary); border-radius: 6px; font-size: 12px; cursor: pointer; font-family: var(--font-family); transition: all 0.15s; margin-top: 4px; }
.dyn-add-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.dyn-add-btn .add-icon { font-size: 14px; line-height: 1; }

/* Folder Tree — Enhanced Interactive Version */
.folder-sidebar {
  width: 240px; min-width: 240px; background: #FAFBFC; border-right: 1px solid var(--border-light);
  padding: 0; flex-shrink: 0; overflow-y: auto; overflow-x: hidden; user-select: none;
}
.folder-tree-root { padding: 8px 0; }

/* 全部文件根节点 */
.tree-all-files {
  display: flex; align-items: center; height: 36px; padding: 0 12px;
  cursor: pointer; border-radius: 0; margin-bottom: 4px;
  transition: all var(--transition-fast); font-size: 13px; font-weight: 500; color: var(--text-primary);
}
.tree-all-files:hover { background: #F3F4F6; }
.tree-all-files.active { background: #EBF2FF; color: var(--primary); }
.tree-all-files .tree-badge { margin-left: auto; font-size: 11px; color: var(--text-secondary); }

/* 分组标题 */
.tree-group-title {
  display: flex; align-items: center; height: 28px; padding: 0 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: #9CA3AF; border-bottom: 1px solid #F0F0F0; position: sticky; top: 0; background: #FAFBFC; z-index: 1;
}
.tree-group-title .group-count { margin-left: auto; font-size: 10px; background: #F0F0F0; border-radius: 8px; padding: 1px 6px; color: #9CA3AF; }
.tree-group-body { padding-bottom: 4px; }

/* 标签节点 */
.tree-tag-node {
  display: flex; align-items: center; height: 34px; padding: 0 8px; cursor: pointer;
  border-radius: 4px; margin: 1px 4px; transition: all var(--transition-fast);
  font-size: 13px; color: #374151; position: relative;
}
.tree-tag-node:hover { background: #F3F4F6; }
.tree-tag-node.active { background: #EBF2FF; color: var(--primary); font-weight: 500; }
.tree-tag-node.active::before { content:''; position:absolute; left:0; top:4px; bottom:4px; width:3px; background:var(--primary); border-radius:0 2px 2px 0; }
.tree-tag-arrow { width: 18px; height: 18px; display:flex; align-items:center; justify-content:center;
  flex-shrink:0; color:#9CA3AF; font-size:10px; transition:transform 200ms ease; }
.tree-tag-arrow.expanded { transform: rotate(90deg); }
.tree-tag-name { flex:1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-tag-badge { font-size: 11px; background: #F0F0F0; border-radius: 8px; padding: 1px 6px; color: #6B7280; margin-left: 4px; white-space: nowrap; }
.tree-tag-add-btn { opacity:0; width:20px; height:20px; border-radius:50%; border:none; background:#EBF2FF; color:var(--primary); font-size:14px; cursor:pointer; display:flex; align-items:center; justify-content:center; flex-shrink:0; transition:all var(--transition-fast); line-height:1; padding:0; }
.tree-tag-node:hover .tree-tag-add-btn { opacity:1; }
.tree-tag-add-btn:hover { background: var(--primary); color: #fff; transform: scale(1.1); }

/* 文件夹列表容器 */
.tree-folder-list { overflow: hidden; transition: max-height 250ms ease; max-height: 0; }
.tree-folder-list.expanded { max-height: 600px; } /* enough for most folders */

/* 文件夹节点 */
.tree-folder-node {
  display: flex; align-items: center; height: 30px; padding: 0 8px 0 26px;
  cursor: pointer; border-radius: 4px; margin: 1px 4px; transition: all var(--transition-fast);
  font-size: 12.5px; color: #4B5563; position: relative;
}
.tree-folder-node:hover { background: #F3F4F6; }
.tree-folder-node.active { background: #DBEAFE; color: #2563EB; font-weight: 500; }
.tree-folder-icon { width: 18px; text-align: center; margin-right: 5px; flex-shrink: 0; font-size: 13px; }
.tree-folder-name { flex:1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-folder-badge { font-size: 10.5px; background: #EDF2F7; border-radius: 8px; padding: 1px 5px; color: #6B7280; margin-left: 4px; }
.tree-folder-actions { display:none; gap:2px; margin-left:4px; }
.tree-folder-node:hover .tree-folder-actions { display:flex; }
.tree-folder-action-btn { width:18px; height:18px; border-radius:4px; border:none; background:transparent; color:#9CA3AF; font-size:11px; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:all var(--transition-fast); line-height:1; padding:0; }
.tree-folder-action-btn:hover { background: #E5E7EB; color: var(--text-primary); }
.tree-folder-action-btn.delete:hover { background: #FEE2E2; color: var(--danger); }

/* 行内编辑 */
.tree-inline-edit { flex:1; display:flex; align-items:center; }
.tree-inline-edit input { width:100%; height:24px; border:1px solid var(--primary); border-radius:4px; padding:0 6px; font-size:12.5px; outline:none; box-shadow:0 0 0 2px rgba(59,126,248,0.15); }

/* 面包屑 */
.resource-breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-tertiary); margin-bottom: 12px; padding: 0 4px; }
.resource-breadcrumb a { color: var(--primary); cursor: pointer; text-decoration: none; }
.resource-breadcrumb a:hover { text-decoration: underline; }
.resource-breadcrumb .breadcrumb-sep { color: #D1D5DB; }
.resource-breadcrumb .breadcrumb-current { color: var(--text-primary); font-weight: 500; }

/* 右键菜单 */
.tree-context-menu {
  position: fixed; z-index: 1000; background: #fff; border: 1px solid #E5E7EB;
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 4px 0;
  min-width: 150px; display: none; animation: ctxMenuIn 150ms ease;
}
@keyframes ctxMenuIn { from{opacity:0;transform:scale(0.95) translateY(-4px);} to{opacity:1;transform:scale(1) translateY(0);} }
.tree-context-menu.show { display: block; }
.ctx-menu-item { display: flex; align-items: center; height: 32px; padding: 0 12px; cursor: pointer;
  font-size: 13px; color: var(--text-primary); transition: background var(--transition-fast); }
.ctx-menu-item:hover { background: #F3F4F6; }
.ctx-menu-item.danger { color: var(--danger); }
.ctx-menu-item.danger:hover { background: #FEF2F2; }
.ctx-menu-item .ctx-icon { margin-right: 8px; width: 16px; text-align: center; }
.ctx-menu-divider { height: 1px; background: #F0F0F0; margin: 4px 0; }

/* Upload Modal Mini Tree */
.upload-tree-tag { padding:5px 8px; cursor:pointer; font-size:12.5px; color:#374151; border-radius:4px; font-weight:500; }
.upload-tree-tag:hover { background:#F3F4F6; }
.upload-tree-folders { padding-left:14px; margin-bottom:6px; }
.upload-tree-folder { display:flex; align-items:center; height:26px; padding:0 8px; cursor:pointer; font-size:12px; color:#4B5563; border-radius:4px; margin:1px 0; transition:all var(--transition-fast); }
.upload-tree-folder:hover { background:#F3F4F6; }
.upload-tree-folder.active { background:#DBEAFE; color:#2563EB; font-weight:500; }

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--border-default); border-radius: var(--radius-md);
  padding: 32px; text-align: center; cursor: pointer; transition: all var(--transition-fast);
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-zone .upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-zone .upload-text { font-size: 13px; color: var(--text-secondary); }
.upload-zone .upload-hint { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }

/* Tab */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border-default); margin-bottom: 16px; }
.tab-item {
  padding: 8px 16px; font-size: 13px; color: var(--text-secondary); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all var(--transition-fast);
}
.tab-item:hover { color: var(--text-primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* Frequency bar */
.freq-bar {
  display: inline-block; height: 4px; background: var(--primary-light);
  border-radius: 2px; vertical-align: middle; margin-left: 6px; min-width: 40px;
}
.freq-bar .freq-fill { height: 100%; background: var(--primary); border-radius: 2px; }

/* Responsive helper */
.text-mono { font-family: "SF Mono", "Fira Code", "Consolas", monospace; font-size: 12px; }
.text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.cursor-pointer { cursor: pointer; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.ml-auto { margin-left: auto; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }

/* ============================================================
   RESPONSIVE LAYOUT (SRS §7.4)
   ============================================================ */

/* Core: flex item must fill available width */
.main-content { max-width: none !important; flex: 1; min-width: 0; }

/* Page: fill parent width */
.page { width: 100%; }

/* Dashboard layout base */
.dash-row { display: grid; gap: 16px; margin-bottom: 16px; align-items: stretch; }
.dash-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.dash-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* Dashboard cards: fill grid cell height */
.dash-row .card {
  display: flex; flex-direction: column;
  margin-bottom: 0; min-height: 0;
}
.dash-row .card .card-body {
  flex: 1; display: flex; flex-direction: column;
  min-height: 0; overflow-y: auto;
}
.dash-row .card-donut .card-body {
  align-items: center; justify-content: center;
}
.dash-row .card-list .card-body {
  justify-content: flex-start; overflow-y: auto;
}

/* Dashboard page grid: allow content to grow, main-content scrolls */
#page-dashboard.active {
  display: grid !important;
  grid-template-rows: auto auto auto;
  gap: 16px;
}
#page-dashboard.active .stats-row { margin-bottom: 0; }
#page-dashboard.active .dash-row { margin-bottom: 0; }

/* ============================================================
   DASHBOARD RESPONSIVE — 4 tiers
   1600px+ : full (6 stats / 3 dash / 4 dash)
   1200-1600 : 3 stats / 2 dash / 2 dash
   900-1200 : 2 stats / 1 dash / auto rows + reduced fonts
   900-     : 2 stats / 1 dash + minimal
   ============================================================ */

/* Tier 1: wide desktop — full layout */
@media (min-width: 1601px) {
  .stats-row { grid-template-columns: repeat(6, 1fr); }
}

/* Tier 2: standard desktop — reduce */
@media (max-width: 1600px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .dash-row-3 { grid-template-columns: 1fr 1fr; }
  .dash-row-4 { grid-template-columns: 1fr 1fr; }
}

/* Tier 3: laptop (~1366px) — stack */
@media (max-width: 1200px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .dash-row-3, .dash-row-4 { grid-template-columns: 1fr; }
  #page-dashboard.active { grid-template-rows: auto auto auto; }
  .donut-ring svg { width: 130px !important; height: 130px !important; }
  .donut-hole .total { font-size: 22px !important; }
  .donut-legend { font-size: 11px !important; gap: 10px !important; }
  .stat-card { padding: 14px !important; }
  .stat-card .stat-value { font-size: 22px !important; }
}

/* Tier 4: tablet / small laptop — minimal */
@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .donut-ring svg { width: 110px !important; height: 110px !important; }
  .donut-hole .total { font-size: 18px !important; }
  .donut-legend { font-size: 10px !important; gap: 6px !important; }
  .stat-card .stat-value { font-size: 18px !important; }
  .card-header h3 { font-size: 13px !important; }
}

/* Tables: stretch full width */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 100%; table-layout: auto; }

/* Scrollbar styling (cross-browser) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* Firefox scrollbar */
* { scrollbar-width: thin; scrollbar-color: #D1D5DB transparent; }

/* Narrow screens: adjust sidebar + content */
@media (max-width: 1366px) {
  .main-content { padding: 16px; }
  .folder-sidebar { width: 200px !important; min-width: 200px !important; }
}

/* Ultra-wide: allow dashboard to fill available width naturally.
   The grid layout distributes space proportionally across columns,
   so removing max-width lets content breathe on large screens. */
@media (min-width: 1921px) {
  /* No max-width clamp — dash grid handles wide-space distribution */
}

/* Filter bar: wrap on small screens */
@media (max-width: 1280px) {
  .filter-bar { gap: 8px; }
  .filter-bar .search-input { width: 180px; }
  .filter-bar select { min-width: 100px; }
}

/* Cards fill width */
.card { width: 100%; }
.card-body { width: 100%; }

/* Tags grid: responsive */
.tags-grid { width: 100%; }

/* Tag management table responsive */
@media (max-width: 1366px) {
  #tagTable th:nth-child(4),
  #tagTable td:nth-child(4) { display: none; }
}

/* ============================================================
   TOOLTIP SYSTEM (v2.22 — SRS §4.9)
   ============================================================ */
.tooltip-popup {
  position: fixed; z-index: 999; background: #fff; border: 1px solid #E5E7EB;
  border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); padding: 10px 12px;
  display: none; max-width: 300px; font-size: 12px;
  animation: tooltipIn 150ms ease;
}
.tooltip-popup.freq-tooltip { max-width: 280px; }
.tooltip-popup .tt-header {
  font-weight: 600; color: var(--text-primary); margin-bottom: 6px;
  padding-bottom: 4px; border-bottom: 1px solid var(--border-light); font-size: 12.5px;
}
.tooltip-popup .tt-row {
  display: flex; align-items: center; gap: 6px; padding: 2px 0;
  font-size: 11px; color: var(--text-secondary);
}
.tooltip-popup .tt-row .tt-bar-bg {
  flex: 1; height: 6px; background: #F0F0F0; border-radius: 3px; overflow: hidden;
  min-width: 60px;
}
.tooltip-popup .tt-row .tt-bar-fill {
  height: 100%; background: var(--primary); border-radius: 3px;
}
@keyframes tooltipIn { from{opacity:0;transform:translateY(2px);} to{opacity:1;transform:translateY(0);} }

/* Tag overflow badge */
.tag-overflow-n {
  display: inline-block; padding: 2px 7px; border-radius: 10px;
  font-size: 11px; font-weight: 500; background: #F3F4F6; color: #6B7280;
  cursor: pointer; vertical-align: middle; margin-left: 2px;
}
.tag-overflow-n:hover { background: #E5E7EB; color: var(--text-primary); }

/* Frequency hover zone */
.freq-hover-zone {
  display: inline-flex; align-items: center; gap: 3px;
  cursor: pointer; font-weight: 700; color: var(--primary);
  border-bottom: 1px dashed var(--primary); padding-bottom: 1px;
}
.freq-hover-zone:hover { opacity: 0.8; }
.freq-hover-zone .freq-icon { font-size: 13px; }

/* ===== Dashboard Donut Charts (v2.53) ===== */
.donut-ring { position: relative; display: inline-block; }
.donut-ring svg { transform: rotate(-90deg); }
.donut-hole {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.donut-hole .total { font-size: 28px; font-weight: 500; }
.donut-hole .sub { font-size: 12px; color: var(--text-secondary); }
.donut-legend { display: flex; gap: 18px; margin-top: 14px; font-size: 13px; flex-wrap: wrap; justify-content: center; }
.donut-legend span { display: flex; align-items: center; gap: 5px; }
.donut-legend .dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* Activity feed */
.activity-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 0.5px solid var(--border-light); font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.activity-time { font-size: 11px; color: var(--text-tertiary); margin-left: auto; flex-shrink: 0; }

/* Resource summary */
.res-summary-item {
  background: #F8FAFC; border-radius: 8px; padding: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.res-summary-row { display: flex; justify-content: space-between; align-items: center; }
.res-summary-bar { height: 8px; background: #F2F4F7; border-radius: 4px; overflow: hidden; }
.res-summary-bar-fill { height: 100%; border-radius: 4px; }

/* Alert cards */
.alert-item { border-radius: 8px; padding: 14px 16px; border-left: 3px solid; }
.alert-item .alert-label { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.alert-item .alert-value { font-size: 28px; font-weight: 500; }
.alert-item .alert-sub { font-size: 11px; margin-top: 2px; }


.status-badge.queued{background:#f1f5f9;color:#64748b;}
/* Publish page: same grid as dashboard */
#page-publish.active { display: grid !important; gap: 16px; }
#page-publish.active .dash-row { margin-bottom: 0; }
#publishLogTableWrap { max-height: 192px; overflow-y: auto; }
.status-badge.running{background:#fef3c7;color:#d97706;}
.status-badge.done{background:#d1fae5;color:#059669;}
.status-badge.partial{background:#fef3c7;color:#d97706;}
.status-badge.degraded{background:#fef3c7;color:#d97706;}
.status-badge.failed{background:#fee2e2;color:#dc2626;}
.status-badge.cancelled{background:#f1f5f9;color:#94a3b8;}
@keyframes scorePulse { 0% { background:#fef3c7; } 100% { background:transparent; } }
.score-updated { animation: scorePulse 1.5s ease-out; }
