/* ============================================================
   AgreeMint -- Institutional-Grade AI Agreement Platform
   Professional Dark Theme
   ============================================================ */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-card: #16162a;
  --bg-hover: #1e1e3a;
  --bg-input: #0e0e1a;
  --border: #2a2a4a;
  --border-light: #3a3a5a;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0c0;
  --text-muted: #6a6a8a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-dim: rgba(99, 102, 241, 0.15);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --yellow: #f59e0b;
  --yellow-dim: rgba(245, 158, 11, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --transition: 0.2s ease;
}

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---- Login Page ---- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

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

.login-logo .logo-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-logo p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-light); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid transparent;
}

.btn-danger:hover { background: var(--red); color: white; }

.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-xs { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-xs); }

.login-error {
  color: var(--red);
  font-size: 13px;
  text-align: center;
  margin-bottom: 12px;
  display: none;
}

/* ---- App Layout ---- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header .logo-icon { font-size: 24px; }

.sidebar-header .logo-text {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 8px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}

.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item .nav-icon { font-size: 18px; width: 24px; text-align: center; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
}

.user-email {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
}

.logout-btn:hover { color: var(--red); }

/* ---- Main Content ---- */
.main {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.topbar-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
}

.topbar-title {
  font-weight: 600;
  font-size: 16px;
}

.page-content {
  flex: 1;
  padding: 32px;
  max-width: 1400px;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
}

.page-header p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 2px;
}

.page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- Stats Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
}

.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 32px; font-weight: 700; margin-top: 4px; }
.stat-card .stat-icon { font-size: 24px; float: right; margin-top: -4px; }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.blue .stat-value { color: var(--blue); }

/* ---- Agreement Cards / Table ---- */
.agreements-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agreement-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition);
  cursor: pointer;
}

.agreement-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }

.agreement-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.agreement-info { flex: 1; min-width: 0; }
.agreement-info h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agreement-meta { display: flex; gap: 16px; flex-wrap: wrap; }
.agreement-meta span { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }

.agreement-actions { display: flex; gap: 8px; flex-shrink: 0; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-draft { background: var(--blue-dim); color: var(--blue); }
.status-pending { background: var(--yellow-dim); color: var(--yellow); }
.status-signed { background: var(--green-dim); color: var(--green); }
.status-expired { background: var(--red-dim); color: var(--red); }
.status-disputed { background: rgba(239,68,68,0.12); color: #ef4444; }
.status-cancelled { background: rgba(107,114,128,0.15); color: #9ca3af; }
.status-resolved { background: rgba(168,85,247,0.12); color: #a855f7; }
.status-active { background: var(--green-dim); color: var(--green); }

/* ---- Template Grid ---- */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.template-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition);
}

.template-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.template-card .template-icon { font-size: 32px; margin-bottom: 12px; }
.template-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.template-card p { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }
.template-card .template-meta { display: flex; gap: 12px; }
.template-card .template-meta span { font-size: 11px; color: var(--text-muted); background: var(--bg-tertiary); padding: 3px 8px; border-radius: var(--radius-xs); }

/* ---- Category Filter ---- */
.category-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.category-btn {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

.category-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.category-btn.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* ---- Create Form ---- */
.create-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
}

.create-section h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
  transition: border-color var(--transition);
}

.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236a6a8a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

.form-select:focus {
  outline: none;
  border-color: var(--accent);
}

.party-row {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  align-items: center;
}

.party-row .form-input { flex: 1; }
.party-row .remove-party { background: none; border: none; color: var(--red); cursor: pointer; font-size: 18px; padding: 4px; }

/* ---- Agreement View ---- */
.agreement-view {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}

.agreement-content-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.agreement-content-panel .content-body {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-primary);
}

.agreement-content-panel .content-body h1 { font-size: 22px; margin: 24px 0 12px; }
.agreement-content-panel .content-body h2 { font-size: 18px; margin: 20px 0 10px; color: var(--accent); }
.agreement-content-panel .content-body h3 { font-size: 15px; margin: 16px 0 8px; }
.agreement-content-panel .content-body p { margin-bottom: 10px; }
.agreement-content-panel .content-body ul, .agreement-content-panel .content-body ol { margin: 8px 0 8px 24px; }
.agreement-content-panel .content-body li { margin-bottom: 4px; }
.agreement-content-panel .content-body table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.agreement-content-panel .content-body th, .agreement-content-panel .content-body td { padding: 8px 12px; border: 1px solid var(--border); font-size: 13px; }
.agreement-content-panel .content-body th { background: var(--bg-tertiary); font-weight: 600; }
.agreement-content-panel .content-body strong { color: var(--text-primary); }
.agreement-content-panel .content-body blockquote { border-left: 3px solid var(--accent); padding-left: 16px; color: var(--text-secondary); margin: 12px 0; }

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.side-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.side-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 12px;
}

.side-card .detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.side-card .detail-row:last-child { border: none; }
.side-card .detail-label { color: var(--text-muted); }
.side-card .detail-value { color: var(--text-primary); font-weight: 500; }

.party-list { display: flex; flex-direction: column; gap: 8px; }

.party-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.party-item .party-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.party-item .party-name { font-size: 13px; font-weight: 500; }
.party-item .party-email { font-size: 11px; color: var(--text-muted); }
.party-item .party-signed { font-size: 18px; margin-left: auto; }

/* ---- Chat ---- */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-message {
  display: flex;
  gap: 12px;
  max-width: 80%;
}

.chat-message.user { align-self: flex-end; flex-direction: row-reverse; }

.chat-message .msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.chat-message.user .msg-avatar { background: var(--accent-dim); color: var(--accent); }
.chat-message.assistant .msg-avatar { background: var(--green-dim); color: var(--green); }

.chat-message .msg-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.7;
}

.chat-message.user .msg-content { background: var(--accent-dim); border-color: rgba(99,102,241,0.3); }

.chat-message .msg-content h1, .chat-message .msg-content h2, .chat-message .msg-content h3 { margin: 12px 0 6px; }
.chat-message .msg-content h2 { font-size: 16px; color: var(--accent); }
.chat-message .msg-content h3 { font-size: 14px; }
.chat-message .msg-content p { margin-bottom: 8px; }
.chat-message .msg-content table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 12px; }
.chat-message .msg-content th, .chat-message .msg-content td { padding: 6px 10px; border: 1px solid var(--border); }
.chat-message .msg-content th { background: var(--bg-tertiary); }
.chat-message .msg-content ul { margin: 4px 0 4px 20px; }

.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-input-row {
  display: flex;
  gap: 10px;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  resize: none;
}

.chat-input:focus { outline: none; border-color: var(--accent); }

.chat-send {
  padding: 12px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font);
  transition: background var(--transition);
}

.chat-send:hover { background: var(--accent-hover); }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Analysis Results ---- */
.analysis-result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-top: 16px;
}

.analysis-result h2 { color: var(--accent); font-size: 18px; margin-bottom: 16px; }

/* ---- Activity Feed ---- */
.activity-feed {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.activity-item:last-child { border: none; }
.activity-item .activity-action { font-weight: 500; }
.activity-item .activity-time { color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* ---- Loading ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

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

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h2 { font-size: 18px; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

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

.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ---- Sign Page (Public) ---- */
.sign-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px;
}

.sign-header {
  text-align: center;
  margin-bottom: 32px;
}

.sign-header h1 { font-size: 24px; margin-bottom: 8px; }
.sign-header p { color: var(--text-muted); }

.sign-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
  max-height: 500px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.8;
}

.sign-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.sign-form .consent-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0;
}

.sign-form .consent-check input { margin-top: 3px; }
.sign-form .consent-check label { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .agreement-view { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .topbar { display: flex; }
  .main { margin-left: 0; }
  .page-content { padding: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .templates-grid { grid-template-columns: 1fr; }
  .chat-message { max-width: 95%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-box { padding: 32px 24px; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast-success { background: var(--green); color: white; }
.toast-error { background: var(--red); color: white; }
.toast-info { background: var(--accent); color: white; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- Generating overlay ---- */
.generating-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  gap: 16px;
}

.generating-overlay .spinner-lg {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.generating-overlay p {
  font-size: 16px;
  color: var(--text-secondary);
}

.generating-overlay .gen-sub {
  font-size: 13px;
  color: var(--text-muted);
}
