/* Variables */
:root {
  --bg: #0f111a;
  --surface: #1a1d2e;
  --surface-hover: #222640;
  --border: #2a2e45;
  --text: #c9cde8;
  --text-muted: #7b82a8;
  --heading: #e8ebf7;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-bg: rgba(99, 102, 241, 0.12);
  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

::-webkit-scrollbar-corner {
  background: var(--bg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

input, textarea, button, select {
  font-family: inherit;
  font-size: inherit;
}

input, textarea, select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

select {
  cursor: pointer;
  appearance: none;
  -webkit-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='%237b82a8' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

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

select:hover {
  border-color: var(--primary);
}

textarea { resize: vertical; }

/* Banners */
#save-error-banner {
  background: rgba(239, 68, 68, 0.15);
  border-bottom: 2px solid var(--danger);
  color: var(--danger);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  z-index: 300;
}

#save-error-banner button {
  background: var(--danger);
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}

#save-error-banner button:last-child {
  background: none;
  color: var(--danger);
  border: 1px solid var(--danger);
}

#undo-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 300;
}

#undo-banner button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}

#undo-banner button:last-child {
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Company Logo Watermark */
#header-company-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
  vertical-align: middle;
}

.logo-preview {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.logo-preview img {
  max-width: 60px;
  max-height: 40px;
  object-fit: contain;
}

/* Sync Toast */
.sync-toast {
  position: fixed;
  top: 60px;
  right: 24px;
  background: var(--success);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 300;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s;
}

.sync-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.app-header h1 {
  color: var(--heading);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.db-status {
  font-size: 8px;
  cursor: default;
  transition: color 0.3s ease;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 24px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Search */
.search-box {
  position: relative;
  width: 100%;
  max-width: 420px;
}

.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  font-size: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.search-box input:focus {
  border-color: var(--primary);
}

.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
}

.search-results.visible {
  display: block;
}

.search-result-row {
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.search-result-row:last-child {
  border-bottom: none;
}

.search-result-row:hover {
  background: var(--primary-bg);
}

.search-result-title {
  color: var(--heading);
  font-size: 14px;
  font-weight: 500;
}

.search-result-meta {
  display: flex;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  align-items: center;
}

.search-due {
  margin-left: auto;
  font-weight: 600;
}

.search-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.settings-btn {
  font-size: 20px;
  color: var(--text-muted);
}

.settings-btn:hover { color: var(--text); }

.db-status.connected { color: var(--success); }
.db-status.saving { color: var(--warning); animation: pulse 1s ease-in-out infinite; }
.db-status.offline { color: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Settings */
.settings-modal { width: 80vw !important; max-width: 900px !important; max-height: 85vh; overflow-y: auto; }

.settings-section {
  padding: 8px 0;
}

.settings-section h4 {
  color: var(--heading);
  font-size: 15px;
  margin-bottom: 6px;
}

.settings-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.settings-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
}

.settings-status.connected {
  background: rgba(34, 197, 94, 0.08);
  color: var(--text);
}

.settings-status.disconnected {
  background: rgba(239, 68, 68, 0.08);
  color: var(--text);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.green { background: var(--success); }
.status-dot.red { background: var(--danger); }

/* Contact search results */
.contact-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 10;
  max-height: 200px;
  overflow-y: auto;
}

.contact-row {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.contact-row:hover {
  background: var(--primary-bg);
}

.contact-row strong {
  color: var(--heading);
}

.contact-row span {
  color: var(--text-muted);
  font-size: 12px;
}

.cal-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cal-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
  color: var(--text);
}

.cal-checkbox:hover {
  background: var(--surface-hover);
}

.cal-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Company Tabs */
.company-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 12px 20px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

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

.tab-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  border-radius: 3px;
  opacity: 0;
  transition: all 0.15s;
}

.tab:hover .tab-close { opacity: 0.6; }
.tab-close:hover { opacity: 1 !important; color: var(--danger); background: rgba(239, 68, 68, 0.1); }

.tab-add {
  font-size: 20px;
  padding: 10px 16px;
  color: var(--text-muted);
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
}

.tab-add:hover { color: var(--primary); }

.tab-edit-input {
  background: var(--bg);
  border: 1px solid var(--primary);
  border-radius: 4px;
  color: var(--heading);
  padding: 2px 8px;
  font-size: 15px;
  font-weight: 500;
  width: 140px;
  outline: none;
}

.tab-hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.5;
  white-space: nowrap;
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  padding: 10px 18px;
  font-size: 14px;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 18px;
  font-size: 14px;
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }
.btn-delete:hover { color: var(--danger); }

/* Main content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.main-content:has(.kanban-header) {
  padding: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Client / Dashboard Sections */
.clients-section {
  padding: 24px;
  flex: 1;
}

.dashboard-section {
  background: #141624;
  border-top: 1px solid var(--border);
  padding: 24px;
  margin-top: auto;
}

/* Space list */
.space-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.space-list-header h2 {
  color: var(--heading);
  font-size: 20px;
}

.space-list-header-right {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.space-list-header-right .btn {
  padding: 10px 18px;
  font-size: 14px;
}

.space-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.space-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.space-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.space-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.space-card-header h3 {
  color: var(--heading);
  font-size: 17px;
  margin-bottom: 6px;
}

.space-card-info {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.space-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 20px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 15px;
}

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

.modal-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 420px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-form h3 {
  color: var(--heading);
  font-size: 18px;
}

.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Kanban */
.kanban-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.kanban-header h2 {
  color: var(--heading);
  font-size: 20px;
}

.client-meta {
  display: flex;
  gap: 12px;
  align-items: center;
}

.client-info {
  color: var(--text-muted);
  font-size: 13px;
}

.client-email {
  color: var(--primary);
  font-size: 12px;
}

.kanban-header-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.kanban-header-right .btn {
  padding: 10px 18px;
  font-size: 14px;
}

/* Status dots */
.status-dot.yellow { background: var(--warning); }

.space-card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.space-card-title-row .status-dot {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

/* Archive Panel */
.archive-panel {
  background: #141624;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  max-height: 250px;
  overflow-y: auto;
}

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

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.archive-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: background 0.15s;
}

.archive-row:hover {
  background: var(--surface-hover);
}

.archive-row-info strong {
  color: var(--heading);
  font-size: 14px;
}

.archive-meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.archive-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
  flex: 1;
  min-height: 0;
}

.kanban-column {
  flex: 0 0 260px;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
}

.kanban-column.drag-over {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.column-header:hover { background: var(--primary-bg); border-radius: 6px 6px 0 0; margin: -4px -4px 12px -4px; padding: 4px 4px 12px 4px; }

.column-header h3 {
  color: var(--heading);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.column-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.column-delete, .column-move, .column-sort {
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 14px;
}

.column-header:hover .column-delete,
.column-header:hover .column-move,
.column-header:hover .column-sort { opacity: 0.6; }
.column-delete:hover { opacity: 1 !important; }
.column-move:hover { opacity: 1 !important; color: var(--primary); }
.column-sort:hover { opacity: 1 !important; color: var(--primary); }

.column-edit-input {
  background: var(--bg);
  border: 1px solid var(--primary);
  border-radius: 4px;
  color: var(--heading);
  padding: 2px 8px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: 140px;
  outline: none;
}

.task-count {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.kanban-column-add {
  min-width: 200px;
  max-width: 200px;
  border-style: dashed;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: all 0.2s;
}

.kanban-column-add:hover {
  opacity: 1;
  border-color: var(--primary);
  background: var(--primary-bg);
}

.add-column-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
}

.add-column-content span:first-child {
  font-size: 28px;
}

.task-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 40px;
  overflow-y: auto;
}

.task-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: grab;
  transition: all 0.2s;
}
.task-card:hover { border-color: var(--primary); }
.task-card:active { cursor: grabbing; }
.task-card.dragging { opacity: 0.4; }

.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.task-card-header strong {
  color: var(--heading);
  font-size: 14px;
  word-break: break-word;
}

.task-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.task-card:hover .task-actions { opacity: 1; }

.task-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 6px;
  word-break: break-word;
}

.task-move-buttons {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.btn-move {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-move:hover {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-add-task {
  width: 100%;
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}
.btn-add-task:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

.new-task-form, .task-edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.new-task-form input,
.new-task-form textarea,
.task-edit-form input,
.task-edit-form textarea {
  font-size: 13px;
  padding: 8px 10px;
}

.date-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-field label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.date-field input[type="date"] {
  font-size: 13px;
  padding: 6px 10px;
  flex: 1;
  color-scheme: dark;
}

.task-card-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.task-created {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
}

.task-due {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Task Modal */
.task-modal {
  width: 90vw;
  max-width: 1100px;
  height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.task-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.task-modal-header h3 {
  color: var(--heading);
  font-size: 20px;
  word-break: break-word;
}

.task-modal-meta-inline {
  display: flex;
  gap: 16px;
}

.task-modal-two-col {
  display: flex;
  gap: 20px;
  flex-direction: row-reverse;
  flex: 1;
  min-height: 0;
}

.task-modal-left {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  overflow-y: auto;
}

.task-modal-left label {
  font-size: 12px;
}

.task-modal-left input,
.task-modal-left textarea {
  font-size: 13px;
  padding: 6px 10px;
}

.task-modal-left textarea {
  rows: 5;
}

.task-modal-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.task-modal-right h4 {
  color: var(--heading);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.activity-log {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  min-height: 0;
}

.activity-entry {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.activity-entry:last-child {
  border-bottom: none;
}

.activity-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.activity-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.activity-entry:hover .activity-actions {
  opacity: 1;
}

.activity-actions .btn-icon {
  font-size: 14px;
  padding: 1px 4px;
}

.activity-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.activity-text {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.activity-edit-input {
  width: 100%;
  font-size: 13px;
  padding: 4px 8px;
}

.activity-input-row {
  display: flex;
  gap: 6px;
}

.activity-input-row input {
  flex: 1;
  font-size: 13px;
  padding: 6px 10px;
}

.desc-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.desc-label-row label {
  font-size: 14px;
  color: var(--text-muted);
}

.task-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.task-meta-item {
  font-size: 13px;
  color: var(--text-muted);
}

.task-modal-body {
  padding: 16px 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 60px;
}

/* Templates */
.desc-template-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.desc-template-row label {
  font-size: 12px;
  color: var(--text-muted);
}

.desc-template-row select {
  width: auto;
  font-size: 12px;
  padding: 4px 28px 4px 10px;
}

.template-manager-modal {
  width: 560px;
  max-height: 80vh;
  overflow-y: auto;
}

.template-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 20px;
}

.template-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.template-row:hover {
  background: var(--surface-hover);
}

.template-row-info strong {
  color: var(--heading);
  font-size: 14px;
  display: block;
}

.template-preview {
  font-size: 11px;
  color: var(--text-muted);
}

.template-row-actions {
  display: flex;
  gap: 4px;
}

.company-template-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.company-template-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 14px;
  color: var(--heading);
}

.company-template-row select {
  width: auto;
  min-width: 160px;
}

/* Presets */
.preset-tasks-section {
  margin-top: 8px;
}

.preset-tasks-section h4 {
  color: var(--heading);
  font-size: 14px;
}

.preset-task-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}

.preset-task-row .preset-task-title {
  flex: 1;
}

.preset-task-row .preset-task-desc {
  flex: 1;
}

.preset-task-row .btn-icon {
  flex-shrink: 0;
}

.preset-apply-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preset-apply-row {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.preset-apply-row:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.preset-apply-row strong {
  color: var(--heading);
  font-size: 14px;
  display: block;
}

.editable-label {
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.2s;
}

.editable-label:hover {
  border-bottom-color: var(--text-muted);
}

.label-edit-input {
  font-size: 12px;
  padding: 2px 6px;
  width: auto;
  display: inline;
  background: var(--bg);
  border: 1px solid var(--primary);
  border-radius: 4px;
  color: var(--text);
}

.modal-hint {
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.5;
  padding-top: 4px;
}

.task-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
}

/* File Browser */
.files-panel {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.files-panel #files-content {
  flex: 1;
  overflow-y: auto;
}

.files-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.files-panel h3 {
  color: var(--heading);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.files-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.files-breadcrumb-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-sort-buttons {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.files-dropzone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 100px;
  transition: all 0.2s;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}

.files-dropzone.drag-over {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.file-item:hover {
  background: var(--surface-hover);
}

.file-icon {
  font-size: 28px;
  line-height: 1;
  color: var(--text-muted);
}

.file-icon .fa-folder {
  color: var(--warning);
}

.file-name {
  font-size: 11px;
  color: var(--heading);
  word-break: break-word;
  line-height: 1.3;
  max-height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.file-size {
  font-size: 10px;
  color: var(--text-muted);
}

.files-empty {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.files-empty p {
  margin-bottom: 12px;
}

/* Folder Picker */
.folder-picker-modal {
  width: 500px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}

.folder-picker-path {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 6px 12px;
  border-radius: var(--radius);
  word-break: break-all;
  margin-bottom: 8px;
}

.folder-picker-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.folder-picker-list {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  align-content: start;
}

.folder-picker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px 12px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.folder-picker-item:hover {
  background: var(--primary-bg);
}

.folder-picker-icon {
  font-size: 36px;
  line-height: 1;
  color: var(--text-muted);
}

.folder-picker-icon .fa-folder {
  color: var(--warning);
}

.folder-picker-icon .fa-cloud {
  color: var(--primary);
}

.folder-picker-name {
  font-size: 12px;
  color: var(--heading);
  word-break: break-word;
  line-height: 1.3;
  max-height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.folder-select-row {
  display: flex;
  gap: 8px;
}

.folder-select-row input {
  flex: 1;
  cursor: pointer;
}

/* Kanban Bottom */
.kanban-bottom {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  background: #141624;
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  flex-shrink: 0;
  height: 250px;
  min-height: 200px;
}

/* Bottom Panels */
.bottom-panels {
  display: flex;
  gap: 20px;
  min-height: 400px;
}

.upcoming-panel, .calendar-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.upcoming-panel {
  flex: 1;
  min-width: 300px;
  max-width: 420px;
  overflow-y: auto;
}

.upcoming-panel h3, .calendar-panel h3 {
  color: var(--heading);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upcoming-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.upcoming-row:hover {
  background: var(--surface-hover);
}

.upcoming-color {
  width: 4px;
  height: 24px;
  border-radius: 2px;
  flex-shrink: 0;
}

.upcoming-date {
  font-size: 12px;
  font-weight: 600;
  width: 80px;
  flex-shrink: 0;
}

.upcoming-title {
  flex: 1;
  font-size: 13px;
  color: var(--heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upcoming-client {
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-bg);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.upcoming-col {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.empty-state-sm {
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 0;
  text-align: center;
}

/* Payments */
.payments-panel {
  background: #141624;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.payments-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.payments-panel-header h3 {
  color: var(--heading);
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Company Payments Dashboard — Collapsible */
.cpd-collapsible {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-top: 20px;
  overflow: hidden;
}

.cpd-collapse-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.cpd-collapse-header:hover {
  background: var(--surface-hover);
}

.cpd-collapse-header h3 {
  color: var(--heading);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.cpd-collapse-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cpd-chevron {
  color: var(--text-muted);
  font-size: 12px;
  transition: transform 0.3s;
  transform: rotate(180deg);
}

.cpd-expanded .cpd-chevron {
  transform: rotate(0deg);
}

.cpd-collapse-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
  padding: 0 20px;
}

.cpd-expanded .cpd-collapse-body {
  max-height: 2000px;
  padding: 0 20px 20px;
}

.company-payments-panel {
  min-width: 400px;
}

.cpd-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.cpd-stat {
  flex: 1;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: center;
}

.cpd-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--heading);
}

.cpd-stat-good .cpd-stat-value {
  color: var(--success, #22c55e);
}

.cpd-stat-warn .cpd-stat-value {
  color: var(--warning, #f59e0b);
}

.cpd-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.cpd-currency-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 12px;
  margin-bottom: 6px;
}

.cpd-currency-label:first-child {
  margin-top: 0;
}

.cpd-summary-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
  flex-wrap: wrap;
}

.cpd-invoice-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--heading);
  margin-right: 8px;
}

.cpd-status-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.cpd-row {
  cursor: pointer;
  transition: background 0.15s;
}

.cpd-row:hover {
  background: var(--surface-hover);
}

.cpd-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.cpd-header-row h3 {
  margin-bottom: 0;
}

.cpd-eye-btn {
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px 8px;
  transition: color 0.15s;
}

.cpd-eye-btn:hover {
  color: var(--heading);
}

.cpd-hidden .cpd-stat-value,
.cpd-hidden .num,
.cpd-hidden .balance-due {
  color: transparent !important;
  background: var(--border);
  border-radius: 4px;
  user-select: none;
}

.cpd-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 20px 0 12px;
}

.cpd-job-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  font-weight: 500;
}

.cpd-job-active {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.cpd-job-done {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.cpd-job-empty {
  background: var(--bg);
  color: var(--text-muted);
}

.cpd-job-none {
  background: var(--bg);
  color: var(--text-muted);
  font-style: italic;
}

.payments-table-wrap {
  overflow-x: auto;
}

.payments-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.payments-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.payments-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

.payments-table tbody tr:hover {
  background: var(--surface-hover);
}

.payments-table .inv-num {
  color: var(--primary);
  font-weight: 600;
  font-family: monospace;
}

.payments-table .num {
  text-align: right;
  font-family: monospace;
}

.payments-table .balance-due {
  color: var(--warning);
  font-weight: 600;
}

.payments-table .small-text {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.status-paid { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.status-partial { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.status-active { background: rgba(99, 102, 241, 0.15); color: var(--primary); }
.status-onhold { background: rgba(122, 130, 168, 0.15); color: var(--text-muted); }
.status-overdue { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.status-due { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

.inv-type-retainer {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.inv-type-onetime {
  font-size: 11px;
  color: var(--text-muted);
}

.retainer-due-urgent {
  color: var(--danger) !important;
  font-weight: 600;
}

.retainer-next-due {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(168, 85, 247, 0.1);
  border-radius: var(--radius);
  font-size: 13px;
  color: #c084fc;
}

/* Task Send Update */
.task-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.task-modal-footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-hint-inline {
  font-size: 11px;
  color: var(--text-muted);
}

.task-send-update-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.task-send-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.task-folder-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.task-folder-row input {
  flex: 1;
}

.task-right-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Email preview */
.email-preview-meta {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.email-preview-body {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  max-height: 400px;
  overflow-y: auto;
  color: #1a1a2e;
}

.invoice-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.invoice-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

/* God View */
.god-view {
  padding: 24px;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.god-header {
  margin-bottom: 20px;
}

.god-header h2 {
  color: var(--heading);
  font-size: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.god-filters-wrap {
  margin-bottom: 16px;
}

.god-filters-toggle {
  display: none; /* hidden on desktop */
}

.god-filter-count {
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 4px;
}

.god-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.god-filters select,
.god-filters .god-filter-search {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  width: auto;
}

.god-filters .god-filter-search {
  flex: 1;
  min-width: 220px;
  max-width: 320px;
}

.god-filters select:hover,
.god-filters .god-filter-search:focus {
  border-color: var(--primary);
}

.god-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.god-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  text-align: center;
  flex: 1;
}

.god-stat-card.stat-danger { border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.05); }
.god-stat-card.stat-warning { border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.05); }
.god-stat-card.stat-info { border-color: rgba(99, 102, 241, 0.3); background: rgba(99, 102, 241, 0.05); }

.god-stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--heading);
}

.stat-danger .god-stat-num { color: var(--danger); }
.stat-warning .god-stat-num { color: var(--warning); }
.stat-info .god-stat-num { color: var(--primary); }

.god-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.god-table-wrap {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.god-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.god-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.god-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
}

.god-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.god-row {
  cursor: pointer;
  transition: background 0.15s;
}

.god-row:hover {
  background: var(--primary-bg);
}

.god-due {
  white-space: nowrap;
  min-width: 100px;
}

.god-due-label {
  font-size: 10px;
}

.god-title {
  color: var(--heading);
  font-weight: 600;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.god-desc {
  color: var(--text-muted);
  font-size: 12px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.god-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.god-badge.company {
  background: var(--primary-bg);
  color: var(--primary);
}

.god-badge.client {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

.god-badge.col {
  background: rgba(122, 130, 168, 0.15);
  color: var(--text-muted);
}

.god-created {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

/* Calendar Slide Panel */
.calendar-slide {
  position: fixed;
  top: 0;
  right: -50vw;
  width: 50vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.4);
  z-index: 250;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
}

.calendar-slide.open {
  right: 0;
}

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

.calendar-slide-header h3 {
  color: var(--heading);
  font-size: 16px;
  font-weight: 600;
}

.calendar-slide-body {
  flex: 1;
  padding: 0;
}

.calendar-iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
}

/* Login Screen */
#login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
}

.login-box h1 {
  color: var(--heading);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.login-box h1 i {
  color: var(--primary);
}

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

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.login-box label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.login-btn {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 15px;
  margin-top: 4px;
}

.login-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  text-align: center;
}

.login-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  margin-top: 16px;
  padding: 0;
  transition: color 0.2s;
}

.login-toggle:hover {
  color: var(--primary);
}

/* ════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
  max-width: 420px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 280px;
  max-width: 420px;
}

.toast-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-leaving {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  line-height: 1.4;
  word-break: break-word;
}

.toast-action {
  background: none;
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.toast-action:hover {
  background: var(--primary-bg);
  border-color: var(--primary);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  transition: color 0.15s;
}
.toast-close:hover {
  color: var(--text);
}

.toast-success {
  border-left-color: var(--success);
}
.toast-success .toast-icon {
  color: var(--success);
}

.toast-error {
  border-left-color: var(--danger);
}
.toast-error .toast-icon {
  color: var(--danger);
}

.toast-warning {
  border-left-color: var(--warning);
}
.toast-warning .toast-icon {
  color: var(--warning);
}

.toast-info {
  border-left-color: var(--primary);
}
.toast-info .toast-icon {
  color: var(--primary);
}

/* Confirm dialog */
.toast-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.toast-confirm-overlay.visible {
  opacity: 1;
}
.toast-confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast-confirm-overlay.visible .toast-confirm-box {
  transform: scale(1);
}
.toast-confirm-message {
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 20px;
}
.toast-confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.toast-confirm-actions .btn {
  padding: 8px 18px;
  font-size: 14px;
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: var(--danger-hover);
}

/* ════════════════════════════════════════════════════════════
   SKELETON LOADERS
   ════════════════════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-hover) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 4px;
  display: inline-block;
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line {
  height: 14px;
  width: 100%;
  margin: 4px 0;
}
.skeleton-line.short {
  width: 40%;
}
.skeleton-line.medium {
  width: 70%;
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
}
.skeleton-card .skeleton-line {
  height: 12px;
  margin: 6px 0;
}

.skeleton-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.skeleton-row .skeleton {
  height: 14px;
}

.skeleton-table {
  width: 100%;
}
.skeleton-table .skeleton-row > .skeleton:nth-child(1) { flex: 0 0 100px; }
.skeleton-table .skeleton-row > .skeleton:nth-child(2) { flex: 1; }
.skeleton-table .skeleton-row > .skeleton:nth-child(3) { flex: 0 0 80px; }
.skeleton-table .skeleton-row > .skeleton:nth-child(4) { flex: 0 0 80px; }
.skeleton-table .skeleton-row > .skeleton:nth-child(5) { flex: 0 0 80px; }

/* ════════════════════════════════════════════════════════════
   POLISH — Modal animations, focus rings, transitions
   ════════════════════════════════════════════════════════════ */
.modal-overlay {
  animation: overlay-fade-in 0.2s ease;
}
@keyframes overlay-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-form {
  animation: modal-pop-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modal-pop-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Better focus rings for keyboard navigation */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.task-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Smooth scroll for the main content */
html {
  scroll-behavior: smooth;
}

/* Subtle hover lift on space cards (already exists, just ensure smooth) */
.space-card,
.task-card,
.upcoming-row {
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

/* Toast on mobile — slide up from bottom, full width */
@media (max-width: 768px) {
  #toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }
  .toast {
    min-width: 0;
    max-width: none;
  }
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤1024px)
   ════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .task-modal {
    width: 95vw;
    height: 90vh;
  }
  .task-modal-left {
    width: 240px;
  }
  .calendar-slide {
    width: 70vw;
    right: -70vw;
  }
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤768px)
   ════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── Header ── */
  .app-header {
    padding: 10px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .app-header h1 {
    font-size: 18px;
  }
  #header-company-logo {
    height: 22px;
  }
  .header-center {
    order: 3;
    flex-basis: 100%;
    padding: 0;
  }
  .search-box {
    max-width: none;
  }
  .search-box input {
    font-size: 13px;
    padding: 6px 12px 6px 32px;
  }
  .header-right {
    gap: 8px;
  }
  .settings-btn {
    font-size: 18px;
    padding: 4px;
  }

  /* ── Tabs ── */
  .company-tabs {
    padding: 0 12px;
  }
  .tab {
    padding: 10px 14px;
    font-size: 14px;
  }
  .tab-hint {
    display: none;
  }

  /* ── Main content padding ── */
  .clients-section {
    padding: 16px 14px;
  }
  .main-content:has(.kanban-header) {
    padding: 14px;
  }

  /* ── Space list ── */
  .space-list-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }
  .space-list-header h2 {
    font-size: 18px;
  }
  .space-list-header-right {
    flex-wrap: wrap;
  }
  .space-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .space-card {
    padding: 16px;
  }

  /* ── Kanban header ── */
  .kanban-header {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
  }
  .kanban-header h2 {
    font-size: 17px;
  }
  .kanban-header-right {
    margin-left: 0;
    flex-basis: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }
  .kanban-header-right .btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  .client-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  /* ── Kanban board: full-width single-column scroll ── */
  .kanban-board {
    gap: 12px;
  }
  .kanban-column {
    flex: 0 0 85vw;
    max-width: 85vw;
    padding: 12px;
  }
  .kanban-column-add {
    min-width: 85vw;
    max-width: 85vw;
  }

  /* ── Kanban bottom panels ── */
  .kanban-bottom {
    flex-direction: column;
    height: auto;
    min-height: 0;
    padding: 12px;
    gap: 12px;
  }
  .upcoming-panel,
  .files-panel {
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  /* ── Dashboard / bottom panels ── */
  .bottom-panels {
    flex-direction: column;
    min-height: 0;
  }
  .upcoming-panel {
    max-width: none;
  }
  .company-payments-panel {
    min-width: 0;
  }
  .cpd-stats {
    flex-direction: column;
    gap: 8px;
  }
  .cpd-stat {
    padding: 10px 14px;
  }

  /* ── God View ── */
  .god-view {
    padding: 14px;
  }
  .god-header h2 {
    font-size: 18px;
  }
  .god-filters-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 8px;
  }
  .god-filters-toggle:hover {
    border-color: var(--primary);
  }
  .god-filters {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .god-filters-wrap.expanded .god-filters {
    display: flex;
  }
  .god-filters select,
  .god-filters .god-filter-search {
    width: 100%;
    max-width: none;
    min-width: 0;
  }
  .god-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .god-stat-card {
    padding: 12px 16px;
  }
  .god-stat-num {
    font-size: 22px;
  }
  .god-table {
    font-size: 12px;
  }
  .god-table th,
  .god-table td {
    padding: 8px 10px;
  }
  .god-title,
  .god-desc {
    max-width: 140px;
  }

  /* ── Modals ── */
  .modal-overlay {
    padding: 0;
  }
  .modal-form {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    padding: 20px 16px;
    overflow-y: auto;
  }
  .settings-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  .task-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
  .task-modal-two-col {
    flex-direction: column;
    gap: 14px;
  }
  .task-modal-left {
    width: 100%;
    flex-shrink: 1;
    overflow-y: visible;
  }
  .task-modal-right {
    min-height: 280px;
  }
  .activity-log {
    max-height: 240px;
  }
  .invoice-form-grid {
    grid-template-columns: 1fr;
  }
  .form-actions {
    flex-wrap: wrap;
  }
  .task-modal-meta-inline {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* ── Calendar slide ── */
  .calendar-slide {
    width: 100vw;
    right: -100vw;
  }

  /* ── Payments table ── */
  .payments-table {
    font-size: 11px;
  }
  .payments-table th,
  .payments-table td {
    padding: 6px 8px;
  }

  /* ── Banners ── */
  #save-error-banner,
  #multi-tab-warning,
  #undo-banner {
    flex-wrap: wrap;
    font-size: 13px;
    padding: 10px 14px;
  }
  #undo-banner {
    left: 14px;
    right: 14px;
    transform: none;
    width: auto;
  }

  /* ── Login screen ── */
  .login-box {
    padding: 28px 20px;
  }
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — Small phones (≤480px)
   ════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .app-header h1 {
    font-size: 16px;
  }
  .tab {
    padding: 9px 12px;
    font-size: 13px;
  }
  .kanban-column {
    flex: 0 0 90vw;
    max-width: 90vw;
  }
  .god-stats {
    grid-template-columns: 1fr 1fr;
  }
  .god-stat-num {
    font-size: 20px;
  }
  .god-table thead {
    display: none;
  }
  .god-table,
  .god-table tbody,
  .god-table tr,
  .god-table td {
    display: block;
    width: 100%;
  }
  .god-table tr {
    border-bottom: 2px solid var(--border);
    padding: 10px 0;
  }
  .god-table td {
    border-bottom: none;
    padding: 4px 14px;
    text-align: left;
  }
  .god-due {
    font-weight: 600;
  }
  .modal-form {
    padding: 16px 14px;
  }
}

/* Finance Overview */
.finance-overview { margin: 20px 0; }
.finance-overview h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.finance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.finance-card { background: var(--bg-surface, #1a1f2e); border: 1px solid var(--border, #2a3244); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.finance-card-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--border, #2a3244); }
.finance-currency { font-size: 18px; font-weight: 700; color: #a6e22e; letter-spacing: 0.05em; }
.finance-count { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.finance-monthly, .finance-annual { display: flex; justify-content: space-between; align-items: baseline; }
.finance-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; }
.finance-monthly .finance-value { font-size: 20px; font-weight: 700; color: var(--text, #e8ecf4); }
.finance-annual .finance-value { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.finance-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.finance-row .finance-value { font-weight: 700; color: var(--text, #e8ecf4); font-size: 15px; }
.finance-row .finance-value.finance-paid { color: #a6e22e; font-size: 20px; }
.finance-row .finance-value.finance-outstanding { color: #f8b324; }
.finance-divider { height: 1px; background: var(--border, #2a3244); margin: 4px 0; }
.god-finance-cta { display: flex; justify-content: center; margin: 24px 0 16px; }
.finance-modal { max-width: 900px; width: 92vw; }
.finance-modal-body { padding: 8px 4px 4px; }
.finance-loading { text-align: center; padding: 40px; color: var(--text-muted); font-size: 14px; }
.finance-errors { margin-top: 16px; padding: 12px; background: rgba(248, 179, 36, 0.1); border: 1px solid rgba(248, 179, 36, 0.3); border-radius: 8px; font-size: 12px; color: var(--text-muted); }
.finance-errors ul { margin: 6px 0 0 18px; padding: 0; }
