/* ============================================================
   SigForge Admin Portal - Styles
   ============================================================ */

:root {
  --brand: #0078d4;
  --brand-dark: #005a9e;
  --brand-light: #deecf9;
  --success: #107c10;
  --success-bg: #dff6dd;
  --warning: #8a6c00;
  --warning-bg: #fff4ce;
  --danger: #a4262c;
  --danger-bg: #fde7e9;
  --neutral-900: #201f1e;
  --neutral-800: #323130;
  --neutral-700: #484644;
  --neutral-600: #605e5c;
  --neutral-400: #a19f9d;
  --neutral-200: #edebe9;
  --neutral-100: #f3f2f1;
  --neutral-50: #faf9f8;
  --sidebar-w: 240px;
  --header-h: 52px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
  --radius: 6px;
  --radius-lg: 10px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--neutral-800);
  background: var(--neutral-100);
  overflow: hidden;
}

/* ============================================================ Login */
#login-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0078d4 0%, #004578 100%);
}

.login-box {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 380px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-mark {
  font-size: 40px;
  display: block;
  margin-bottom: 8px;
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--neutral-900);
  margin: 0;
}

.login-logo p { color: var(--neutral-600); margin: 4px 0 0; font-size: 13px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 12px; margin-bottom: 5px; color: var(--neutral-700); text-transform: uppercase; letter-spacing: 0.3px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--neutral-800);
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-light);
}
.form-group textarea { resize: vertical; }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-row .form-group.flex-2 { flex: 2; }

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}

/* ============================================================ App Shell */
#app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================ Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: #1b1a19;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon { font-size: 24px; }
.brand-text h1 { margin: 0; font-size: 16px; font-weight: 700; color: white; }
.brand-text span { font-size: 11px; color: rgba(255,255,255,.5); }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,.35);
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  border-radius: 0;
  text-decoration: none;
  font-size: 13px;
  transition: background 0.12s, color 0.12s;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: rgba(255,255,255,.06); color: white; }
.nav-item.active { background: rgba(0,120,212,.25); color: white; border-left-color: var(--brand); }
.nav-item i { width: 16px; text-align: center; font-size: 13px; }

.sidebar-user {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
#user-badge { color: white; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
#user-role-badge { font-size: 10px; color: rgba(255,255,255,.5); text-transform: capitalize; }
.logout-btn { background: none; border: none; color: rgba(255,255,255,.4); cursor: pointer; font-size: 14px; padding: 4px; }
.logout-btn:hover { color: rgba(255,255,255,.8); }

/* ============================================================ Main Content */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid var(--neutral-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
}

.topbar h2 { font-size: 16px; font-weight: 600; margin: 0; color: var(--neutral-900); flex: 1; }

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.page-panel { display: none; }

/* ============================================================ Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
  line-height: 1;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: white; }
.btn-secondary { background: var(--neutral-200); color: var(--neutral-800); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.link-btn { background: none; border: none; color: var(--brand); cursor: pointer; font-size: inherit; padding: 0; text-decoration: underline; }

.icon-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--neutral-600);
  transition: background 0.12s, color 0.12s;
  font-size: 13px;
}
.icon-btn:hover { background: var(--neutral-100); color: var(--neutral-900); border-color: var(--neutral-200); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn.small { width: 22px; height: 22px; font-size: 11px; }

/* ============================================================ Badges & Pills */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
}
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--neutral-200); color: var(--neutral-600); }
.badge-warn { background: var(--warning-bg); color: var(--warning); }
.badge-global { background: #e9d7f7; color: #6b00a8; }

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}
.status-pill.active, .status-pill.success { background: var(--success-bg); color: var(--success); }
.status-pill.inactive, .status-pill.skipped { background: var(--neutral-200); color: var(--neutral-600); }
.status-pill.failed { background: var(--danger-bg); color: var(--danger); }
.status-pill.warn { background: var(--warning-bg); color: var(--warning); }

.template-badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-right: 4px;
}
.type-full { background: #dae3f3; color: #1f4e79; }
.type-reply { background: #e2f0d9; color: #375623; }
.type-global_block { background: #f0e6f6; color: #6b00a8; }
.status-draft { background: var(--neutral-100); color: var(--neutral-600); }
.status-active { background: var(--success-bg); color: var(--success); }
.status-archived { background: #fde7e9; color: #8b0000; }

.role-badge { padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 500; }
.role-badge.superadmin { background: #ffd700; color: #7a5600; }
.role-badge.editor { background: var(--brand-light); color: var(--brand-dark); }
.role-badge.viewer { background: var(--neutral-200); color: var(--neutral-600); }

/* ============================================================ Dashboard */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { margin: 0; font-size: 20px; font-weight: 700; }

#stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  gap: 14px;
  align-items: center;
  box-shadow: var(--shadow);
}
.stat-icon { font-size: 24px; opacity: 0.85; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; color: var(--neutral-900); }
.stat-label { font-size: 13px; font-weight: 500; color: var(--neutral-700); margin-top: 3px; }
.stat-sub { font-size: 11px; color: var(--neutral-400); margin-top: 2px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dash-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.dash-card h3 { margin: 0 0 14px; font-size: 14px; font-weight: 600; color: var(--neutral-700); text-transform: uppercase; letter-spacing: 0.4px; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--neutral-100);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.activity-body { flex: 1; min-width: 0; }
.activity-action { font-weight: 500; }
.activity-resource { color: var(--neutral-700); margin-left: 4px; }
.activity-actor { color: var(--neutral-400); font-size: 11px; display: block; margin-top: 1px; }
.activity-time { color: var(--neutral-400); font-size: 11px; flex-shrink: 0; }

.sync-info { font-size: 13px; padding: 8px 0; }
.text-success { color: var(--success); }
.text-warning { color: #8a6c00; }
.text-danger { color: var(--danger); }
.text-muted { color: var(--neutral-400); }
.text-sm { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* Charts */
.chart-header { font-size: 13px; color: var(--neutral-600); margin-bottom: 10px; }
.chart-total { font-size: 22px; font-weight: 700; color: var(--neutral-900); }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 64px; }
.bar-group { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; }
.bar-stack { display: flex; flex-direction: column; justify-content: flex-end; width: 100%; }
.bar-seg { width: 100%; min-height: 2px; border-radius: 2px 2px 0 0; transition: height 0.3s; }
.bar-seg.addin { background: var(--brand); }
.bar-seg.fallback { background: #107c10; }
.bar-label { font-size: 10px; color: var(--neutral-400); }
.chart-legend { display: flex; gap: 12px; font-size: 11px; margin-top: 6px; color: var(--neutral-600); }
.legend-item.addin { color: var(--brand); }
.legend-item.fallback { color: #107c10; }

/* ============================================================ Templates */
.list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.list-header h2 { margin: 0; }
.list-filters { display: flex; gap: 8px; }
.filter-select { padding: 6px 10px; border: 1px solid var(--neutral-200); border-radius: var(--radius); font-size: 13px; background: white; }

#templates-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.template-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--neutral-200);
  transition: border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.template-card:hover { border-color: var(--brand); }
.template-card.draft { opacity: 0.85; }
.template-card.archived { opacity: 0.6; }

.template-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.template-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.template-actions { display: flex; gap: 4px; flex-shrink: 0; }
.template-name { font-size: 15px; font-weight: 600; color: var(--neutral-900); margin: 0; }
.template-desc { font-size: 13px; color: var(--neutral-600); margin: 0; line-height: 1.4; }
.template-footer { display: flex; gap: 8px; margin-top: 4px; }
.template-stat { font-size: 11px; color: var(--neutral-400); background: var(--neutral-100); padding: 2px 6px; border-radius: 4px; }

/* ============================================================ Template Editor Modal */
.editor-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.editor-sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--neutral-200);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-section h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--neutral-600);
  font-weight: 600;
  margin: 0 0 10px;
}

.ph-category { margin-bottom: 10px; }
.ph-cat-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--neutral-400); margin-bottom: 4px; }
.ph-chip {
  display: inline-block;
  background: var(--brand-light);
  color: var(--brand-dark);
  border: 1px solid #c7e0f4;
  border-radius: 4px;
  font-size: 11px;
  padding: 2px 6px;
  margin: 2px;
  cursor: pointer;
  font-family: monospace;
  transition: background 0.1s;
}
.ph-chip:hover { background: #c7e0f4; }

.editor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-tabs {
  display: flex;
  border-bottom: 1px solid var(--neutral-200);
  background: var(--neutral-50);
  padding: 0 16px;
  gap: 4px;
}
.editor-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--neutral-600);
  transition: color 0.12s;
  font-family: inherit;
  font-weight: 500;
}
.editor-tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.editor-tab-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 16px;
}

.editor-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.toolbar-btn {
  background: var(--neutral-100);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.toolbar-btn:hover { background: var(--neutral-200); }

.code-editor {
  flex: 1;
  width: 100%;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 12px;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius);
  padding: 10px;
  resize: none;
  background: #1e1e1e;
  color: #d4d4d4;
  min-height: 300px;
  line-height: 1.6;
}
.code-editor:focus { outline: none; border-color: var(--brand); }

.preview-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.preview-controls select { flex: 1; padding: 6px; border: 1px solid var(--neutral-200); border-radius: var(--radius); font-size: 13px; }

.preview-frame {
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius);
  padding: 16px;
  background: white;
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
}

/* ============================================================ Rules */
.rules-list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.rules-help { font-size: 12px; color: var(--neutral-600); margin-bottom: 16px; background: var(--brand-light); padding: 10px 14px; border-radius: var(--radius); border-left: 3px solid var(--brand); }

#rules-list { display: flex; flex-direction: column; gap: 10px; }

.rule-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--neutral-200);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: border-color 0.15s;
}
.rule-card:hover { border-color: #c8c6c4; }
.rule-card.inactive { opacity: 0.6; }
.rule-card.default-rule { border-left: 3px solid #107c10; }

.rule-drag-handle { cursor: grab; color: var(--neutral-400); font-size: 16px; padding-top: 2px; flex-shrink: 0; }
.rule-priority-badge { background: var(--neutral-100); color: var(--neutral-600); border-radius: 4px; font-size: 11px; font-weight: 700; padding: 3px 7px; flex-shrink: 0; align-self: flex-start; }
.rule-body { flex: 1; min-width: 0; }
.rule-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.rule-header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.rule-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.rule-template { font-size: 13px; color: var(--neutral-600); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.rule-conditions { display: flex; flex-wrap: wrap; gap: 4px; }

.badge-applies { border-radius: 4px; font-size: 11px; font-weight: 500; padding: 2px 7px; }
.badge-applies.both { background: #e9d7f7; color: #6b00a8; }
.badge-applies.new_email { background: var(--brand-light); color: var(--brand-dark); }
.badge-applies.reply_forward { background: #e2f0d9; color: #375623; }

.cond-chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.cond-chip.include { background: var(--success-bg); color: var(--success); }
.cond-chip.exclude { background: var(--danger-bg); color: var(--danger); }
.cond-chip.all { background: var(--neutral-100); color: var(--neutral-600); }

.rule-editor-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(80vh - 120px);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.form-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--neutral-100);
}
.form-section:last-child { border-bottom: none; }
.form-section h4 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--neutral-600); margin: 0 0 14px; }

.add-condition-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  background: var(--neutral-50);
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--neutral-200);
}
.add-condition-bar select { padding: 6px 8px; border: 1px solid var(--neutral-200); border-radius: var(--radius); font-size: 13px; background: white; }

.condition-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--neutral-200);
  margin-bottom: 4px;
  font-size: 13px;
}
.condition-item.include { border-left: 3px solid var(--success); }
.condition-item.exclude { border-left: 3px solid var(--danger); }
.cond-type-badge { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; }
.cond-type-badge.include { background: var(--success-bg); color: var(--success); }
.cond-type-badge.exclude { background: var(--danger-bg); color: var(--danger); }
.cond-desc { flex: 1; }
.no-conditions { color: var(--neutral-400); font-size: 13px; font-style: italic; padding: 8px; }

/* ============================================================ Toggle Switch */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--neutral-400);
  border-radius: 22px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--brand); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-label { display: flex; align-items: center; gap: 10px; }

/* ============================================================ Users */
.users-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.users-meta { display: flex; flex-direction: column; gap: 2px; }
.user-count { font-size: 14px; font-weight: 600; }
.sync-time { font-size: 12px; color: var(--neutral-400); }
.users-actions { display: flex; gap: 8px; }
#user-search { padding: 7px 12px; border: 1px solid var(--neutral-200); border-radius: var(--radius); font-size: 13px; width: 240px; }
.users-table-wrap { background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.user-name { font-weight: 500; }
.user-upn { font-size: 11px; }

/* ============================================================ Assets */
.assets-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.asset-section { margin-bottom: 24px; }
.asset-cat-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--neutral-600); margin: 0 0 10px; }
.asset-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.asset-card {
  width: 160px;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--neutral-200);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.asset-thumb { height: 80px; display: flex; align-items: center; justify-content: center; background: var(--neutral-100); overflow: hidden; }
.asset-thumb img { max-height: 80px; max-width: 160px; object-fit: contain; }
.asset-info { padding: 8px 10px; }
.asset-name { font-size: 12px; font-weight: 500; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-ph code { font-size: 10px; background: var(--brand-light); color: var(--brand-dark); padding: 1px 4px; border-radius: 3px; }
.asset-actions { display: flex; justify-content: flex-end; padding: 4px 6px; border-top: 1px solid var(--neutral-100); gap: 2px; }

.upload-dropzone {
  border: 2px dashed var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-dropzone:hover, .upload-dropzone.drag-over {
  border-color: var(--brand);
  background: var(--brand-light);
}

/* ============================================================ Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--neutral-50);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--neutral-600);
  border-bottom: 1px solid var(--neutral-200);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--neutral-100);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--neutral-50); }
.data-table.compact td, .data-table.compact th { padding: 7px 12px; }

.log-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.log-header h3 { margin: 0; }
.action-badge { padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.action-badge.action-template { background: var(--brand-light); color: var(--brand-dark); }
.action-badge.action-rule { background: #e2f0d9; color: #375623; }
.action-badge.action-asset { background: #e9d7f7; color: #6b00a8; }
.action-badge.action-sync { background: var(--warning-bg); color: var(--warning); }
.action-badge.action-auth { background: var(--neutral-100); color: var(--neutral-700); }
.resource-type { font-weight: 500; }
.method-badge { font-size: 12px; }
.code-block { background: #1e1e1e; color: #d4d4d4; padding: 12px; border-radius: var(--radius); font-family: monospace; font-size: 12px; overflow-x: auto; white-space: pre; }

/* ============================================================ Settings */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.settings-card h3 { font-size: 14px; font-weight: 600; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.entra-setup-guide, .server-fallback-guide { font-size: 13px; color: var(--neutral-600); }
.setup-steps { padding-left: 18px; margin: 8px 0; line-height: 1.8; }
.code-snippet { background: var(--neutral-900); color: #a8d5a8; padding: 10px 12px; border-radius: var(--radius); font-family: monospace; font-size: 12px; margin: 8px 0; line-height: 1.8; }
.help-text { font-size: 11px; color: var(--neutral-400); margin-top: 3px; display: block; }

/* ============================================================ Add-in Page */
.addin-hero { text-align: center; margin-bottom: 24px; padding: 32px; background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.addin-hero-icon { font-size: 48px; display: block; margin-bottom: 10px; }
.addin-hero h2 { font-size: 24px; margin: 0 0 8px; }
.addin-hero p { color: var(--neutral-600); margin: 0; }
.addin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.addin-card { background: white; border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.addin-card.full-width { grid-column: 1 / -1; }
.addin-card h3 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
.deploy-steps { padding-left: 18px; margin: 10px 0; line-height: 2; font-size: 14px; }
.fallback-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.fallback-method { background: var(--neutral-50); border-radius: var(--radius); padding: 14px; }
.fallback-method h4 { font-size: 13px; margin: 0 0 6px; }

/* ============================================================ Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--neutral-200);
  flex-shrink: 0;
}
.modal-header h2 { margin: 0; font-size: 16px; font-weight: 600; }
.close-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--neutral-400); line-height: 1; padding: 4px; border-radius: 4px; }
.close-btn:hover { background: var(--neutral-100); color: var(--neutral-700); }

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--neutral-200);
  flex-shrink: 0;
}

/* ============================================================ Alerts */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 10px;
}
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-error { background: var(--danger-bg); color: var(--danger); }

/* ============================================================ Empty States */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--neutral-400);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; opacity: 0.4; }
.empty-state p { font-size: 14px; margin: 0; }

/* ============================================================ Toast */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow-md);
  display: none;
  animation: slide-up 0.2s ease;
  max-width: 400px;
}
@keyframes slide-up { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast-success { background: #107c10; color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--brand); color: white; }

/* ============================================================ Pagination */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 16px; }
.page-btn { padding: 5px 10px; border: 1px solid var(--neutral-200); background: white; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.page-btn.active { background: var(--brand); color: white; border-color: var(--brand); }
.page-btn:hover:not(.active) { background: var(--neutral-100); }
.page-ellipsis { padding: 5px; color: var(--neutral-400); }

/* Preview modal */
.preview-modal-body { padding: 16px 20px; overflow-y: auto; max-height: calc(80vh - 120px); }
.preview-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab-btn { padding: 5px 12px; border: 1px solid var(--neutral-200); background: white; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.tab-btn.active { background: var(--brand); color: white; border-color: var(--brand); }

.sig-info-banner { background: var(--brand-light); color: var(--brand-dark); padding: 8px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 8px; }

/* Checkbox */
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.checkbox-label input[type="checkbox"] { width: auto; }

/* ============================================================ Responsive */
@media (max-width: 1200px) {
  #stats-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .addin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .editor-layout { flex-direction: column; }
  .editor-sidebar { width: 100%; height: 200px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .fallback-methods { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .sidebar { display: none; }
  #stats-grid { grid-template-columns: 1fr 1fr; }
}
