/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Variables */
:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #666;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;
  --urgent: #dc2626;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* Nav */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 52px;
}

.nav-brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
  letter-spacing: 0.5px;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 14px;
}

.nav-links a:hover, .nav-links a.active {
  background: var(--bg);
  color: var(--text);
}

.nav-links a.active { font-weight: 600; }

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.nav-user a {
  color: var(--text-muted);
  text-decoration: none;
}

.nav-user a:hover { color: var(--text); }

/* Main */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

/* Page header */
.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 20px; font-weight: 600; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

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

/* Grid */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

textarea { resize: vertical; }

.inline-create-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.inline-create-form input[type="text"] { flex: 1; min-width: 200px; }
.inline-create-form select,
.inline-create-form input[type="date"] { width: auto; }

.inline-form { display: inline; }

.note-create-form { display: flex; flex-direction: column; gap: 10px; }

/* Alert */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

/* Login */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin-bottom: 4px;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}

/* Task list */
.task-list, .event-list { list-style: none; }

.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.task-item:last-child { border-bottom: none; }

.task-title { flex: 1; }

.event-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.event-item:last-child { border-bottom: none; }
.event-time { font-size: 12px; color: var(--text-muted); min-width: 48px; }
.event-title { flex: 1; }
.event-location { font-size: 12px; color: var(--text-muted); }

/* Priority badges */
.priority-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.priority-urgent { background: #fef2f2; color: var(--urgent); }
.priority-high { background: #fff7ed; color: var(--warning); }
.priority-medium { background: #fefce8; color: #a16207; }
.priority-low { background: #f0fdf4; color: var(--success); }

/* Due date */
.due-date { font-size: 12px; color: var(--text-muted); }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.tab {
  padding: 7px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.tab:hover { color: var(--text); background: var(--bg); }
.tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

.data-table select {
  padding: 4px 6px;
  font-size: 12px;
  width: auto;
}

/* Notes */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

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

.note-content {
  font-size: 14px;
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.note-date { font-size: 11px; color: var(--text-muted); flex: 1; }

.note-tags { display: flex; gap: 4px; flex-wrap: wrap; }

.tag {
  font-size: 11px;
  padding: 2px 7px;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 10px;
}

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

/* Page subtitle */
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* Alert success */
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* Grid 3 */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr; } }

/* Connect card */
.connect-card { text-align: center; }
.connect-card h3 { font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--text); margin-bottom: 8px; }
.connect-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; min-height: 40px; }
.connect-icon { font-size: 32px; margin-bottom: 10px; }
.connected-label { display: inline-block; color: var(--success); font-size: 13px; font-weight: 600; padding: 7px 0; }

/* Provider badges */
.provider-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}
.provider-gmail { background: #fef2f2; color: #b91c1c; }
.provider-outlook_mail { background: #eff6ff; color: var(--primary); }
.provider-outlook_calendar { background: #eff6ff; color: var(--primary); }
.provider-google_calendar { background: #fef2f2; color: #b91c1c; }
.provider-mailcow { background: #f0fdf4; color: var(--success); }

/* Status badges */
.status-badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.status-active { background: #f0fdf4; color: var(--success); }
.status-inactive { background: #fef2f2; color: var(--danger); }

/* AI Usage — stat cards */
.stat-card { text-align: center; padding: 24px 20px; }
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* AI Usage — filters */
.ai-filters { padding: 16px 20px; margin-bottom: 20px; }
.ai-filters-row { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-group label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); }
.filter-group select { width: auto; min-width: 160px; }

/* AI Usage — service badges */
.service-badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.service-anthropic { background: #faf5ff; color: #7c3aed; }
.service-openai { background: #f0fdf4; color: #16a34a; }

/* AI Usage — table helpers */
.log-date { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.model-name { font-size: 11px; color: var(--text-muted); font-family: monospace; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.pagination-info { font-size: 13px; color: var(--text-muted); }
.btn.disabled { opacity: 0.4; cursor: default; pointer-events: none; }

/* Text color helpers */
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* MailCow form */
.mailcow-details summary { list-style: none; cursor: pointer; }
.mailcow-details summary::-webkit-details-marker { display: none; }
.mailcow-form { margin-top: 14px; text-align: left; }

/* Integration rename form */
.rename-form { display: flex; align-items: center; gap: 6px; }
.rename-input { font-size: 13px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; width: 160px; background: var(--bg); color: var(--text); }
.rename-input:focus { outline: none; border-color: var(--primary); }
.btn-xs { font-size: 11px; padding: 3px 8px; }
