@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg: #0d0d0d;
  --surface: #161616;
  --surface2: #1e1e1e;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #6366f1;
  --accent2: #22d3ee;
  --radius-card: 14px;
  --radius: 8px;
  --transition: 150ms ease;
  --sidebar-width: 240px;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}

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

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

#topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
  flex-shrink: 0;
  transition: height var(--transition), opacity var(--transition);
}

#topbar.hidden {
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

#status-bar {
  height: 36px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  flex-shrink: 0;
  overflow: hidden;
}

#dock {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  flex-shrink: 0;
  overflow-x: auto;
}

#main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  transition: width var(--transition), transform var(--transition);
}

#sidebar.collapsed {
  width: 56px;
}

#sidebar.hidden {
  width: 0;
  overflow: hidden;
}

#content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
}

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

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: #ef4444;
  color: white;
}
.btn-danger:hover { opacity: 0.85; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 10px;
}
.btn-ghost:hover { color: var(--text); background: var(--surface2); }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: all var(--transition);
  color: var(--text-muted);
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 150ms ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 150ms ease;
}

.modal-lg { max-width: 760px; }
.modal-sm { max-width: 400px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

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

/* Form groups */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Tags / pills */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Status dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.up { background: #22c55e; box-shadow: 0 0 6px #22c55e66; }
.status-dot.down { background: #ef4444; box-shadow: 0 0 6px #ef444466; }
.status-dot.warn { background: #f59e0b; box-shadow: 0 0 6px #f59e0b66; }
.status-dot.unknown { background: var(--border); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

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

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

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 150ms ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.toast.success { border-left: 3px solid #22c55e; }
.toast.error { border-left: 3px solid #ef4444; }
.toast.info { border-left: 3px solid var(--accent); }
.toast.warning { border-left: 3px solid #f59e0b; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn { padding: 10px 16px; font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; transition: all var(--transition); background: none; border-top: none; border-left: none; border-right: none; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}

.empty-state-icon { font-size: 48px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text); }
.empty-state p { font-size: 13px; }

/* Context menu */
.context-menu {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  z-index: 2000;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: fadeIn 100ms ease;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
}
.context-menu-item:hover { background: var(--surface); }
.context-menu-item.danger { color: #ef4444; }
.context-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

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

/* Sidebar nav */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 13px;
  font-weight: 500;
  user-select: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--accent); }
.nav-item .nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }

.sidebar-section { padding: 8px 12px 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-top: 8px; }

/* Topbar elements */
.topbar-logo { font-size: 16px; font-weight: 700; color: var(--text); white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.topbar-logo span { color: var(--accent); }

.topbar-center { flex: 1; max-width: 400px; margin: 0 auto; }

.topbar-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
}
.search-trigger:hover { border-color: var(--accent); color: var(--text); }

.search-kbd {
  margin-left: auto;
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Theme selector */
.theme-selector { display: flex; gap: 4px; align-items: center; }
.theme-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 2px solid transparent;
}
.theme-dot:hover { transform: scale(1.2); }
.theme-dot.active { border-color: white; box-shadow: 0 0 0 2px var(--accent); }

/* Avatar */
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 180px;
  z-index: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: fadeIn 150ms ease;
  overflow: hidden;
}
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition);
  color: var(--text);
}
.dropdown-item:hover { background: var(--surface); }
.dropdown-item.danger { color: #ef4444; }
.dropdown-divider { height: 1px; background: var(--border); }

/* Bento grid */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  overflow: hidden;
  position: relative;
  min-height: 120px;
}

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

.widget-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* Dock */
.dock-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text-muted);
  flex-shrink: 0;
}
.dock-app:hover { background: var(--surface2); color: var(--text); }
.dock-app img, .dock-app .dock-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  object-fit: contain;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.dock-app-name { font-size: 10px; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Status bar chips */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

/* App cards */
.app-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  text-decoration: none;
  color: var(--text);
}

.app-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.app-card-logo {
  width: 48px; height: 48px;
  border-radius: 10px;
  object-fit: contain;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.app-card-name {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.app-card-status {
  position: absolute;
  top: 8px;
  right: 8px;
}

.app-card-pin {
  position: absolute;
  top: 6px;
  left: 6px;
  opacity: 0;
  transition: opacity var(--transition);
  font-size: 14px;
}
.app-card:hover .app-card-pin { opacity: 1; }

/* Checklist */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item.done .checklist-text { text-decoration: line-through; color: var(--text-muted); }

/* Calendar mini */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.calendar-day:hover { background: var(--surface2); }
.calendar-day.today { background: var(--accent); color: white; font-weight: 700; }
.calendar-day.has-event::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent2);
}
.calendar-day.other-month { color: var(--text-muted); opacity: 0.4; }

/* Focus mode */
body.focus-mode #topbar { height: 0; overflow: hidden; opacity: 0; pointer-events: none; }
body.focus-mode #sidebar { width: 0; overflow: hidden; }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface2); }

/* Pagination */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 16px; }
.page-btn { padding: 6px 12px; border-radius: var(--radius); font-size: 13px; cursor: pointer; background: var(--surface2); border: 1px solid var(--border); color: var(--text); transition: all var(--transition); }
.page-btn:hover, .page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* Section headers */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 18px; font-weight: 700; }

/* Color picker for notes */
.color-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.color-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition);
}
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.active { border-color: white; }

/* Changelog */
.changelog-item {
  padding: 16px;
  border-radius: var(--radius);
  border-left: 4px solid var(--border);
  background: var(--surface2);
  margin-bottom: 12px;
}
.changelog-item.info { border-left-color: var(--accent); }
.changelog-item.success { border-left-color: #22c55e; }
.changelog-item.warning { border-left-color: #f59e0b; }
.changelog-item.danger { border-left-color: #ef4444; }
.changelog-item.unread { background: var(--surface2); }
.changelog-item.read { opacity: 0.6; }
