:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #071018;
  --bg-soft: #0a151f;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-strong: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.085);
  --border-strong: rgba(139, 198, 255, 0.45);
  --muted: #91a0ad;
  --soft: #c8d0d7;
  --text: #f6f8fb;
  --good: #7bd6a4;
  --warn: #f1b45a;
  --accent: #8bc6ff;
  --sidebar-collapsed: 74px;
  --sidebar-expanded: 196px;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 10%, rgba(76, 131, 180, 0.16), transparent 30%),
    radial-gradient(circle at 90% 0%, rgba(80, 116, 153, 0.10), transparent 26%),
    var(--bg);
  color: var(--text);
  user-select: none;
}
button { font: inherit; }
button, .widget-drag-handle, .widget-resize-handle { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-expanded) minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}
.app-shell.is-sidebar-collapsed { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }

.sidebar {
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 10px 8px;
  background: rgba(5, 13, 20, 0.9);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(16px);
  overflow: hidden;
  z-index: 20;
}
.sidebar-header {
  height: 50px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px 8px;
}
.sidebar-toggle {
  width: 46px;
  height: 42px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  color: var(--soft);
  cursor: pointer;
}
.sidebar-toggle:active { transform: scale(0.97); }
.sidebar-toggle-icon { font-size: 18px; }
.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}
.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(139,198,255,0.12);
  color: #d8ecff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.brand-label {
  white-space: nowrap;
  color: #dfe7ed;
  font-size: 14px;
  font-weight: 680;
  opacity: 1;
  transition: opacity 120ms ease;
}
.is-sidebar-collapsed .brand-label,
.is-sidebar-collapsed .brand-mark { display: none; }

.sidebar-nav {
  display: grid;
  gap: 5px;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }
.sidebar-footer { margin-top: auto; padding-top: 8px; }
.nav-button {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0 12px;
  background: transparent;
  color: #8797a5;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}
.nav-button:active { transform: scale(0.985); }
.nav-button.is-active {
  background: rgba(139,198,255,0.10);
  border-color: rgba(139,198,255,0.10);
  color: #dceeff;
}
.nav-icon {
  width: 28px;
  flex: 0 0 28px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}
.nav-label { white-space: nowrap; font-size: 13px; font-weight: 620; }
.is-sidebar-collapsed .nav-button { justify-content: center; padding: 0; }
.is-sidebar-collapsed .nav-label { display: none; }

.app-area {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
}
.appbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.045);
}
.page-heading { min-width: 0; }
.page-kicker {
  display: block;
  margin-bottom: 2px;
  color: #647483;
  font-size: 9px;
  font-weight: 760;
  letter-spacing: 0.14em;
}
.page-heading h1 {
  margin: 0;
  color: #edf4f9;
  font-size: 21px;
  font-weight: 680;
  letter-spacing: -0.025em;
}
.appbar-actions { display: flex; align-items: center; gap: 9px; }
.layout-actions { display: flex; align-items: center; gap: 7px; }
.layout-actions[hidden] { display: none; }
.toolbar-button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 13px;
  background: rgba(255,255,255,0.055);
  color: #d8e1e8;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.toolbar-button.primary {
  background: rgba(139,198,255,0.16);
  border-color: rgba(139,198,255,0.24);
  color: #e7f5ff;
}
.toolbar-button.secondary { color: #aab7c1; }
.toolbar-button:active { transform: scale(0.98); }
.connection-status {
  min-width: 78px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  color: #7e8d99;
  font-size: 10px;
}
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.connection-dot.offline { background: var(--warn); }

.view-container { min-width: 0; min-height: 0; height: 100%; padding: 10px 12px 12px; overflow: hidden; }
.view { width: 100%; height: 100%; min-width: 0; min-height: 0; }
.view[hidden] { display: none !important; }

.dashboard-grid {
  --grid-gap: 10px;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  gap: var(--grid-gap);
  position: relative;
}
.widget {
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(12px);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.widget-content { width: 100%; height: 100%; min-width: 0; min-height: 0; padding: 16px 18px; overflow: hidden; }
.dashboard-grid.is-editing .widget {
  border-color: rgba(139,198,255,0.32);
  box-shadow: 0 0 0 1px rgba(139,198,255,0.06), 0 18px 46px rgba(0,0,0,0.22);
}
.dashboard-grid.is-editing::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 18px;
  background-image:
    linear-gradient(to right, rgba(139,198,255,0.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(139,198,255,0.055) 1px, transparent 1px);
  background-size: calc((100% + var(--grid-gap)) / 12) calc((100% + var(--grid-gap)) / 8);
  z-index: 0;
}
.dashboard-grid.is-editing .widget { z-index: 1; }
.widget-drag-handle,
.widget-resize-handle { display: none; }
.dashboard-grid.is-editing .widget-drag-handle {
  display: grid;
  place-items: center;
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  z-index: 5;
  border: 1px solid rgba(139,198,255,0.22);
  border-radius: 11px;
  background: rgba(7,16,24,0.88);
  color: #b9d8f5;
  font-size: 18px;
  cursor: grab;
  touch-action: none;
}
.dashboard-grid.is-editing .widget-drag-handle:active { cursor: grabbing; }
.dashboard-grid.is-editing .widget-resize-handle {
  display: block;
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 24px;
  height: 24px;
  z-index: 5;
  cursor: nwse-resize;
  touch-action: none;
}
.dashboard-grid.is-editing .widget-resize-handle::before,
.dashboard-grid.is-editing .widget-resize-handle::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  border-right: 2px solid rgba(185,216,245,0.75);
  border-bottom: 2px solid rgba(185,216,245,0.75);
}
.dashboard-grid.is-editing .widget-resize-handle::before { width: 14px; height: 14px; }
.dashboard-grid.is-editing .widget-resize-handle::after { width: 7px; height: 7px; }
.widget.is-dragging, .widget.is-resizing { transform: scale(0.995); border-color: var(--border-strong); }

.eyebrow {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.13em;
  color: #7f90a0;
}
h2 { margin: 0; font-size: 19px; font-weight: 660; letter-spacing: -0.025em; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.panel-heading.compact { margin-bottom: 12px; }
.source-badge, .count-badge, .status-chip {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 10px;
  font-weight: 700;
}
.source-badge { color: #b8d9f8; background: rgba(91,154,211,0.13); border: 1px solid rgba(139,198,255,0.14); }
.source-badge.muted { color: #9aa8b4; background: rgba(255,255,255,0.045); border-color: rgba(255,255,255,0.06); }
.count-badge { min-width: 28px; text-align: center; color: #d7e9fb; background: rgba(139,198,255,0.12); }
.status-chip.neutral { color: #aeb9c3; background: rgba(255,255,255,0.055); }

.clock-content { display: flex; flex-direction: column; justify-content: center; }
.clock { font-size: clamp(62px, 6vw, 88px); line-height: 0.88; font-weight: 730; letter-spacing: -0.065em; }
.date-line { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 15px; color: var(--soft); text-transform: capitalize; }
.separator { color: #5f6e7a; }

.widget-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mini-status { color: #667887; font-size: 9px; }
.weather-content { display: flex; flex-direction: column; justify-content: center; }
.weather-current { display: flex; align-items: center; gap: 13px; min-width: 0; }
.weather-icon { width: 58px; height: 58px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 19px; background: var(--panel-strong); border: 1px solid var(--border); font-size: 29px; }
.weather-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.weather-main strong { font-size: 38px; letter-spacing: -0.045em; }
.weather-main span { color: var(--soft); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weather-detail { margin-top: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.agenda-list, .task-list { display: grid; gap: 7px; }
.agenda-item { display: grid; grid-template-columns: 60px 3px minmax(0, 1fr); gap: 11px; align-items: center; min-height: 43px; }
.agenda-time { font-size: 15px; font-variant-numeric: tabular-nums; color: #edf3f8; }
.agenda-bar { width: 3px; height: 31px; border-radius: 8px; background: #6f9bc4; }
.agenda-copy { min-width: 0; }
.agenda-copy strong, .agenda-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-copy strong { font-size: 13px; font-weight: 630; }
.agenda-copy span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.task-item { display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 6px 8px; border-radius: 12px; background: rgba(255,255,255,0.025); }
.task-check { width: 15px; height: 15px; flex: 0 0 auto; border-radius: 50%; border: 2px solid #6f8293; }
.task-item span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #dce4ea; }
.empty-state { min-height: 88px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 12px; }

.metro-line { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 10px 11px; border-radius: 14px; background: rgba(255,255,255,0.035); }
.metro-dot { width: 15px; height: 15px; flex: 0 0 auto; border-radius: 50%; }
.metro-dot.orange { background: #f18a2b; box-shadow: 0 0 0 5px rgba(241,138,43,0.10); }
.metro-copy { min-width: 0; flex: 1; }
.metro-copy strong, .metro-copy span { display: block; }
.metro-copy strong { font-size: 12px; }
.metro-copy span { margin-top: 3px; color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.home-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.home-action { min-width: 0; min-height: 55px; display: flex; align-items: center; gap: 7px; border: 1px solid rgba(255,255,255,0.07); border-radius: 14px; background: rgba(255,255,255,0.04); color: #dfe7ed; padding: 8px; text-align: left; }
.home-action:disabled { opacity: 0.58; }
.action-icon { width: 27px; height: 27px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; background: rgba(255,255,255,0.07); font-size: 14px; }
.home-action strong, .home-action small { display: block; }
.home-action strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.home-action small { margin-top: 1px; color: var(--muted); font-size: 8px; }

.module-page { padding: 6px 4px; overflow: auto; }
.module-hero { min-height: 122px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 24px; border: 1px solid var(--border); border-radius: 22px; background: var(--panel); }
.module-hero h2 { font-size: 29px; }
.module-hero p { max-width: 650px; margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.segmented-control { display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(255,255,255,0.045); }
.segmented-control span { padding: 8px 12px; border-radius: 10px; color: #778794; font-size: 11px; }
.segmented-control .is-selected { background: rgba(139,198,255,0.12); color: #d9edff; }
.week-preview { margin-top: 10px; height: calc(100% - 132px); display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 8px; }
.week-day { min-width: 0; padding: 13px; border: 1px solid var(--border); border-radius: 17px; background: rgba(255,255,255,0.035); }
.week-day strong { display: block; margin-bottom: 12px; color: #8192a0; font-size: 10px; letter-spacing: 0.1em; }
.week-day span { display: block; padding: 9px; border-radius: 10px; background: rgba(139,198,255,0.08); color: #d7e7f4; font-size: 11px; }
.weather-page-current { display: grid; min-width: 190px; text-align: right; }
.weather-page-current strong { font-size: 48px; letter-spacing: -0.05em; }
.weather-page-current span { color: var(--soft); font-size: 13px; }
.weather-page-current small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.module-grid { display: grid; gap: 10px; margin-top: 10px; }
.module-grid.three-columns { grid-template-columns: repeat(3, minmax(0,1fr)); }
.module-grid.two-columns { grid-template-columns: repeat(2, minmax(0,1fr)); }
.module-card { min-height: 160px; padding: 18px; border: 1px solid var(--border); border-radius: 18px; background: rgba(255,255,255,0.035); }
.module-card p { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.module-empty { width: 100%; height: 100%; display: grid; place-items: center; align-content: center; text-align: center; border: 1px solid var(--border); border-radius: 22px; background: var(--panel); }
.module-symbol { width: 62px; height: 62px; display: grid; place-items: center; margin-bottom: 16px; border-radius: 20px; background: rgba(139,198,255,0.10); color: #d9edff; font-size: 27px; font-weight: 720; }
.module-empty h2 { font-size: 26px; }
.module-empty p { max-width: 560px; margin: 8px 18px 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 12px);
  z-index: 100;
  min-width: 180px;
  max-width: min(520px, calc(100vw - 40px));
  padding: 10px 14px;
  border: 1px solid rgba(139,198,255,0.18);
  border-radius: 13px;
  background: rgba(8,18,27,0.96);
  color: #dcecff;
  text-align: center;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1050px) {
  :root { --sidebar-expanded: 176px; }
  .app-area { grid-template-rows: 58px minmax(0,1fr); }
  .appbar { padding-inline: 11px; }
  .view-container { padding: 8px 9px 9px; }
  .dashboard-grid { --grid-gap: 8px; }
  .widget-content { padding: 13px 14px; }
  .clock { font-size: 58px; }
  .module-hero { min-height: 108px; padding: 18px; }
}
