:root {
  --bg: #edf2f8;
  --bg-soft: #f6f9fe;
  --surface: #ffffff;
  --surface-muted: #f4f7fc;
  --sidebar-bg: #0e2135;
  --sidebar-border: #1f3a57;
  --text: #10233a;
  --muted: #607089;
  --line: #d8e2f0;
  --brand: #1d4ed8;
  --brand-soft: #e8efff;
  --danger: #c62828;
  --success: #1f8a4c;
  --shadow: 0 10px 30px rgba(16, 35, 58, 0.08);
  --shadow-soft: 0 4px 12px rgba(16, 35, 58, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

a:hover {
  text-decoration: underline;
}

.app-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
  background-image: url('/static/svg/app-mesh.svg');
  background-size: cover;
}

.sidebar {
  background: linear-gradient(180deg, #0d1f33 0%, #122842 100%);
  border-right: 1px solid var(--sidebar-border);
  color: #d8e7f8;
  display: flex;
  flex-direction: column;
  padding: 0.9rem 0.8rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-block {
  margin-bottom: 0.9rem;
}

.brand-link {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  color: #eaf4ff;
  text-decoration: none;
  padding: 0.45rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-link strong {
  display: block;
  line-height: 1.2;
}

.brand-link small {
  color: #9eb8d4;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.side-nav {
  display: grid;
  gap: 0.2rem;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #cfe2f7;
  padding: 0.46rem 0.5rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  text-decoration: none;
}

.side-nav a:hover,
.side-nav a.active {
  background: rgba(116, 173, 255, 0.14);
  border-color: rgba(116, 173, 255, 0.34);
}

.nav-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  color: #a9caf2;
  flex-shrink: 0;
}

.side-bottom {
  margin-top: auto;
  display: grid;
  gap: 0.6rem;
}

.quote-card {
  margin-top: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(167, 215, 255, 0.14), rgba(167, 215, 255, 0.04));
  border-radius: 10px;
  padding: 0.6rem;
}

.quote-card p {
  margin: 0;
  color: #eaf3ff;
  font-size: 0.81rem;
  line-height: 1.35;
}

.quote-card small {
  display: block;
  margin-top: 0.45rem;
  color: #9ec0e5;
  font-size: 0.74rem;
}

.workspace-quote {
  display: none;
  grid-column: 1 / -1;
  margin: -0.15rem 0 0.1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
  padding: 0.48rem 0.62rem;
}

.workspace-quote p {
  margin: 0;
  color: #17335f;
  font-size: 0.8rem;
  line-height: 1.35;
}

.workspace-quote small {
  display: block;
  margin-top: 0.34rem;
  color: var(--muted);
  font-size: 0.74rem;
}

.user-card {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 0.55rem;
}

.user-card strong {
  display: block;
  color: #f1f8ff;
  margin-bottom: 0.2rem;
  font-size: 0.9rem;
}

.user-card small {
  color: #9eb8d4;
  font-size: 0.78rem;
  word-break: break-word;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

.workspace-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem 1rem;
  align-items: start;
  padding: 0.95rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 15;
}

.workspace-header h1 {
  margin: 0;
  font-size: 1.26rem;
}

.workspace-title {
  min-width: 0;
}

.workspace-header p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.workspace-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.header-link {
  border: 1px solid #bcd1ee;
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  background: #eff6ff;
  color: #103a77;
  font-size: 0.84rem;
  white-space: nowrap;
}

.quick-tools {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 1.4fr);
  gap: 0.55rem;
}

.quick-search,
.quick-capture {
  display: grid;
  gap: 0.45rem;
  align-items: end;
  margin: 0;
}

.quick-search {
  grid-template-columns: 1fr auto;
}

.quick-capture {
  grid-template-columns: 1fr minmax(130px, 170px) auto;
}

.quick-search input,
.quick-capture input,
.quick-capture select {
  background: #fff;
}

.container {
  width: min(1240px, calc(100vw - 310px));
  margin: 1rem auto 1.4rem;
}

.workspace-footer,
.footer {
  color: var(--muted);
  text-align: center;
  padding: 0.7rem 1rem 1.1rem;
  font-size: 0.82rem;
}

.auth-screen {
  width: min(980px, 95vw);
  margin: 0 auto;
  min-height: calc(100vh - 70px);
  display: grid;
  place-items: center;
}

.auth-wrap {
  width: 100%;
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(460px, 94vw);
  background: linear-gradient(180deg, #ffffff, #f7faff);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.1rem;
}

.auth-card h1 {
  margin: 0 0 1rem;
  font-size: 1.3rem;
}

.intruder-card {
  border-color: #f3b4b4;
  background: linear-gradient(180deg, #fff8f8, #fff1f1);
}

.intruder-card h1 {
  color: #8f1d1d;
}

.intruder-actions {
  margin: 0.9rem 0;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.page-head {
  margin-bottom: 0.9rem;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  padding: 0.9rem;
  margin-bottom: 0.95rem;
}

h2 {
  margin: 0 0 0.7rem;
  font-size: 1.02rem;
}

.panel h3 {
  margin: 0.45rem 0 0.35rem;
  font-size: 0.9rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.95rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.72rem 0.78rem;
  min-width: 0;
  overflow: hidden;
}

.kpi h3 {
  margin: 0;
  font-size: 0.79rem;
  color: var(--muted);
}

.kpi p {
  margin: 0.3rem 0 0;
  font-weight: 800;
  font-size: 1.52rem;
  line-height: 1.14;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

.kpi p.danger {
  color: var(--danger);
}

.kpi p.metric-number {
  font-size: clamp(1.18rem, 1.2vw + 0.95rem, 1.92rem);
}

.kpi p.metric-split {
  font-size: clamp(1.02rem, 0.95vw + 0.88rem, 1.52rem);
}

.two-col,
.three-col {
  display: grid;
  gap: 0.9rem;
}

.two-col {
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
}

.three-col {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.agenda-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.agenda-filter {
  align-items: end;
}

.agenda-filter button {
  width: fit-content;
  min-width: 140px;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.5rem 0.6rem;
  background: var(--surface);
  color: var(--text);
}

input[type="checkbox"] {
  width: auto;
  padding: 0;
  margin: 0;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #77a6f6;
  outline: 3px solid rgba(119, 166, 246, 0.24);
}

textarea {
  resize: vertical;
}

button {
  border: 1px solid transparent;
  border-radius: 9px;
  background: linear-gradient(140deg, #1d4ed8, #1c69c9);
  color: #fff;
  cursor: pointer;
  padding: 0.5rem 0.82rem;
  font-weight: 700;
}

button:hover {
  filter: brightness(1.04);
}

button.ghost {
  background: transparent;
  border-color: rgba(223, 237, 255, 0.42);
  color: #d9eaff;
}

button.danger-btn {
  background: linear-gradient(140deg, #d92d20, #bb2419);
}

.stack {
  display: grid;
  gap: 0.64rem;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.72rem;
}

.grid-form .full {
  grid-column: 1 / -1;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filters a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.81rem;
  color: var(--muted);
  text-decoration: none;
  background: var(--surface);
}

.filters a.active,
.filters a:hover {
  border-color: #9fc0f6;
  color: #173d80;
  background: #edf4ff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

th,
td {
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #e4ebf5;
  padding: 0.56rem 0.36rem;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.79rem;
}

.inline-form {
  margin: 0;
}

.inline-form select {
  min-width: 110px;
}

.action-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  border-radius: 999px;
  border: 1px solid;
  padding: 0.12rem 0.46rem;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge.critical { color: #991b1b; background: #fee2e2; border-color: #fecaca; }
.badge.high { color: #9a3412; background: #ffedd5; border-color: #fed7aa; }
.badge.normal { color: #1d4ed8; background: #dbeafe; border-color: #bfdbfe; }
.badge.low { color: #166534; background: #dcfce7; border-color: #bbf7d0; }

.muted {
  color: var(--muted);
  font-size: 0.81rem;
  margin-top: 0.16rem;
}

.market-change {
  font-weight: 700;
  color: #334155;
}

.market-change.up,
.ok-text {
  color: #166534;
}

.market-change.down,
.danger-text {
  color: #991b1b;
}

.signal-buy {
  color: #166534;
}

.signal-sell {
  color: #991b1b;
}

.signal-hold {
  color: #1e3a8a;
}

.chart-wrap {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-wrap.compact {
  max-height: 280px;
}

.chart-toolbar {
  margin: 0.58rem 0 0.5rem;
  display: grid;
  gap: 0.42rem;
}

.chart-range-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chart-zoom-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chart-range-btn {
  padding: 0.3rem 0.58rem;
  font-size: 0.78rem;
}

button.chart-range-btn.is-active {
  border-color: #1d4ed8;
  background: #dbe8ff;
  color: #0f336f;
}

.chart-toggle-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.chart-toggle-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.26rem;
  font-size: 0.79rem;
  color: #334155;
  border: 1px solid #d9e1ee;
  border-radius: 999px;
  background: #f8fbff;
  padding: 0.24rem 0.52rem;
}

.chart-toggle-controls input {
  margin: 0;
}

.chart-pan-controls {
  display: grid;
  gap: 0.26rem;
}

.chart-pan-controls label {
  font-size: 0.79rem;
  color: #334155;
  font-weight: 600;
}

.chart-pan-controls input[type='range'] {
  width: min(620px, 100%);
  accent-color: #1d4ed8;
}

.chart-hover-info {
  margin-top: 0.45rem;
  min-height: 1.2rem;
}

#price-hover-hitbox {
  cursor: crosshair;
}

.chart-legend {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: #475569;
}

.chart-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 0.24rem;
}

.chart-legend .dot.price { background: #1d4ed8; }
.chart-legend .dot.sma20 { background: #16a34a; }
.chart-legend .dot.sma50 { background: #d97706; }
.chart-legend .dot.sma200 { background: #6d28d9; }
.chart-legend .dot.ema20 { background: #0ea5e9; }
.chart-legend .dot.bb { background: #64748b; }
.chart-legend .dot.support { background: #0891b2; }
.chart-legend .dot.buy { background: #16a34a; }
.chart-legend .dot.sell { background: #dc2626; }

.chart-marker.buy circle,
.chart-marker.buy_zone circle {
  fill: #16a34a;
  stroke: #14532d;
}

.chart-marker.sell circle,
.chart-marker.sell_zone circle {
  fill: #dc2626;
  stroke: #7f1d1d;
}

.macd-pos {
  fill: #86efac;
  opacity: 0.75;
}

.macd-neg {
  fill: #fca5a5;
  opacity: 0.75;
}

.vol-bar {
  fill: #93c5fd;
  opacity: 0.85;
}

.flash {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
}

.flash.success {
  background: #e8f8ee;
  border-color: #aee5c4;
  color: #146b3b;
}

.flash.error {
  background: #fdecec;
  border-color: #f6c1c1;
  color: #962020;
}

.global-alerts {
  border: 1px solid #f2c27f;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff8ee 0%, #fff3e0 100%);
  box-shadow: 0 8px 20px rgba(196, 127, 28, 0.08);
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.75rem;
}

.global-alerts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.65rem;
}

.global-alerts-head p {
  margin: 0.2rem 0 0;
  font-size: 0.84rem;
  color: #7c4a12;
}

.global-alerts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.38rem;
}

.global-alert-item a {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid #f3d2a3;
  border-radius: 9px;
  background: #fffdfa;
  padding: 0.44rem 0.52rem;
  text-decoration: none;
  color: #1f2937;
}

.global-alert-module {
  font-size: 0.74rem;
  font-weight: 700;
  color: #7c2d12;
  background: #ffedd5;
  border: 1px solid #fdba74;
  border-radius: 999px;
  padding: 0.08rem 0.46rem;
}

.global-alert-title {
  font-size: 0.86rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-alert-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.79rem;
  color: #8a4b14;
}

.global-alert-state {
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.08rem 0.4rem;
  border: 1px solid transparent;
}

.global-alert-item.overdue .global-alert-state {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fecaca;
}

.global-alert-item.today .global-alert-state {
  color: #9a3412;
  background: #ffedd5;
  border-color: #fed7aa;
}

.global-alert-item.soon .global-alert-state {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #bfdbfe;
}

.advice-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.4rem;
}

.three-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.9rem;
}

.metric-list {
  display: grid;
  gap: 0.35rem;
}

.metric-list div {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 0.22rem;
}

.metric-list span {
  color: var(--muted);
  font-size: 0.82rem;
}

.metric-list strong {
  font-size: 0.9rem;
  max-width: 62%;
  text-align: right;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

.checklist {
  margin: 0.45rem 0 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 0.4rem;
}

.checklist li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.46rem 0.55rem;
  background: #ffffff;
}

.checklist li.ok {
  border-color: #9dd5ad;
  background: #edf9f0;
}

.checklist li.warn {
  border-color: #f6c48b;
  background: #fff7ed;
}

.diary-snippets {
  display: grid;
  gap: 0.55rem;
}

.diary-snippets article,
.diary-preview {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
  padding: 0.7rem;
}

.diary-snippets h3,
.diary-preview h3 {
  margin: 0;
}

.diary-snippets p,
.diary-preview p {
  margin: 0.35rem 0 0;
}

.month-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.month-switch h2 {
  margin: 0;
  text-transform: capitalize;
}

.month-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.32rem 0.66rem;
  background: #f1f6ff;
  color: #1a4f95;
  text-decoration: none;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.weekday-row span {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
}

.calendar-cell {
  min-height: 116px;
  border: 1px solid #d6e1f0;
  border-radius: 10px;
  padding: 0.38rem;
  background: #fff;
  min-width: 0;
}

.calendar-cell.empty {
  background: #f4f7fb;
}

.calendar-cell.today {
  border-color: #84b9ff;
  box-shadow: inset 0 0 0 1px #a8ccff;
}

.day-number {
  font-weight: 800;
  font-size: 0.83rem;
  margin-bottom: 0.22rem;
}

.event-chips {
  display: grid;
  gap: 0.22rem;
}

.event-chip {
  border-radius: 7px;
  border: 1px solid #bfd8ff;
  background: #eaf3ff;
  padding: 0.22rem 0.3rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.event-chip.done {
  border-color: #b9e1c5;
  background: #e9f8ef;
}

.event-chip.cancelled {
  border-color: #f5c1c1;
  background: #fdecec;
}

.event-chip strong {
  display: block;
  font-size: 0.73rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.event-chip small {
  color: var(--muted);
  font-size: 0.68rem;
  overflow-wrap: anywhere;
}

.filter-form {
  margin-top: 0.8rem;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: end;
}

.result-list {
  display: grid;
  gap: 0.55rem;
}

.result-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: var(--surface-muted);
}

.result-item h3 {
  margin: 0;
  font-size: 0.95rem;
}

.result-item p {
  margin: 0.25rem 0 0;
}

.assistant-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: end;
}

.assistant-state {
  margin-top: 0;
}

.assistant-state p {
  margin: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.panel-head h2 {
  margin: 0;
}

.panel-head form {
  margin: 0;
}

.news-panel-head {
  margin-bottom: 0.7rem;
}

.assistant-head {
  margin-bottom: 0.7rem;
}

.assistant-state.ok {
  border-color: #bde4c8;
  background: #edf9f1;
}

.assistant-state.warn {
  border-color: #f2d2a3;
  background: #fff8ec;
}

.assistant-prompts {
  margin-top: 0.7rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.assistant-prompts form {
  margin: 0;
}

.assistant-chat {
  display: grid;
  gap: 0.55rem;
  max-height: 470px;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.assistant-message {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
  padding: 0.62rem 0.72rem;
}

.assistant-message.user {
  width: min(92%, 700px);
  margin-left: auto;
  border-color: #b7cff4;
  background: #edf4ff;
}

.assistant-message.assistant {
  width: min(96%, 760px);
  margin-right: auto;
}

.assistant-meta {
  margin: 0 0 0.35rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
}

.assistant-meta strong {
  font-size: 0.83rem;
}

.assistant-meta span {
  color: var(--muted);
  font-size: 0.77rem;
}

.assistant-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

button.chip {
  background: #edf4ff;
  border: 1px solid #b7cff4;
  color: #163e7e;
  font-weight: 600;
}

.assistant-lines {
  margin: 0.6rem 0 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.36rem;
}

.assistant-message .assistant-lines {
  margin-top: 0.45rem;
}

.assistant-message .muted {
  margin-bottom: 0;
}

.filter-chips {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.chip-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.42rem 0.66rem;
  border: 1px solid #b7cff4;
  background: #edf4ff;
  color: #163e7e;
  border-radius: 10px;
  font-size: 0.84rem;
  text-decoration: none;
}

.chip-link:hover {
  text-decoration: none;
  background: #e6f0ff;
}

.chip-link.active {
  border-color: #1d4ed8;
  background: #dbe8ff;
  color: #0f336f;
}

.news-list,
.news-compact-list {
  display: grid;
  gap: 0.55rem;
}

.news-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
  padding: 0.55rem 0.68rem;
}

.news-item summary {
  cursor: pointer;
  list-style: none;
  display: grid;
  gap: 0.24rem;
}

.news-item summary::-webkit-details-marker {
  display: none;
}

.news-item-title {
  display: block;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.news-item-meta {
  margin-top: 0.26rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.news-summary {
  margin: 0.6rem 0 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.news-links {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.news-links a {
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.news-item.compact {
  background: #f6f9fe;
}

.news-failure-log {
  margin-top: 0.65rem;
  border: 1px solid #f3d7ac;
  border-radius: 10px;
  background: #fffaf2;
  padding: 0.5rem 0.6rem;
}

.news-failure-log summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: #7a4a11;
  font-weight: 600;
}

.news-failure-log ul {
  margin: 0.45rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.3rem;
}

.news-failure-log li {
  font-size: 0.8rem;
  color: #8a4b14;
  overflow-wrap: anywhere;
}

.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  z-index: 1200;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.loading-bar::before {
  content: "";
  display: block;
  width: 35%;
  height: 100%;
  background: linear-gradient(90deg, #1d4ed8, #38bdf8);
  border-radius: 999px;
  animation: loading-slide 1s ease-in-out infinite;
}

.loading-bar.show {
  opacity: 1;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 22, 36, 0.3);
  backdrop-filter: blur(2px);
  z-index: 1190;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.loading-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.loading-card {
  min-width: 220px;
  max-width: 90vw;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #c9d8ee;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(16, 35, 58, 0.18);
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  padding: 0.9rem 1rem;
}

.loading-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid #d2def0;
  border-top-color: #1d4ed8;
  animation: spin 0.75s linear infinite;
}

.loading-text {
  font-size: 0.84rem;
  color: #1e3654;
  text-align: center;
}

body.loading-lock,
body.loading-lock * {
  cursor: progress !important;
}

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

@keyframes loading-slide {
  0% {
    transform: translateX(-120%);
  }
  50% {
    transform: translateX(80%);
  }
  100% {
    transform: translateX(240%);
  }
}

.ultra-mobile {
  display: none;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 80px 1fr;
  }

  .brand-link div,
  .side-nav a span,
  .user-card,
  .quote-card {
    display: none;
  }

  .workspace-quote {
    display: block;
  }

  .side-nav a {
    justify-content: center;
  }

  .side-bottom form {
    display: block;
  }

  .side-bottom .ghost {
    width: 100%;
    padding: 0.36rem 0.3rem;
    font-size: 0.72rem;
  }

  .nav-icon {
    width: 18px;
    height: 18px;
  }

  .container {
    width: min(1240px, calc(100vw - 110px));
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .brand-link div,
  .side-bottom {
    display: block;
  }

  .side-nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.3rem;
  }

  .side-nav a {
    justify-content: center;
    padding: 0.42rem 0.3rem;
  }

  .side-nav a span {
    display: none;
  }

  .container {
    width: min(1240px, 96vw);
  }

  .workspace-header {
    position: static;
    padding: 0.75rem 0.9rem;
  }

  .workspace-header h1 {
    font-size: 1.12rem;
  }

  .quick-tools {
    grid-template-columns: 1fr;
  }

  .quick-capture {
    grid-template-columns: 1fr;
  }

  .quick-search {
    grid-template-columns: 1fr;
  }

  .calendar-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  }

  .weekday-row {
    display: none;
  }
}

@media (max-width: 640px) {
  .two-col,
  .three-col,
  .three-col-grid {
    grid-template-columns: 1fr;
  }

  .month-switch {
    flex-wrap: wrap;
  }

  .month-switch h2 {
    width: 100%;
    text-align: center;
    order: -1;
  }

  .month-switch .month-btn {
    flex: 1 1 calc(50% - 0.6rem);
    text-align: center;
  }

  .workspace-header {
    grid-template-columns: 1fr;
  }

  .workspace-actions {
    width: 100%;
    justify-content: stretch;
  }

  .header-link {
    flex: 1;
    text-align: center;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .kpi p.metric-number {
    font-size: clamp(1.02rem, 7.5vw, 1.45rem);
  }

  .kpi p.metric-split {
    font-size: clamp(0.94rem, 6.6vw, 1.26rem);
  }

  .panel {
    padding: 0.78rem;
  }

  table {
    font-size: 0.84rem;
  }

  th,
  td {
    padding: 0.46rem 0.28rem;
  }

  .table-wrap table {
    min-width: 600px;
  }

  .assistant-form,
  .search-form {
    grid-template-columns: 1fr;
  }

  .news-links {
    gap: 0.45rem;
  }

  .filter-chips .chip-link {
    flex: 1 1 calc(50% - 0.45rem);
    justify-content: center;
    min-height: 36px;
  }

  .chart-range-controls .chart-range-btn {
    flex: 1 1 calc(33.33% - 0.35rem);
    min-width: 74px;
  }

  .chart-zoom-controls .chip {
    flex: 1 1 calc(50% - 0.35rem);
    min-width: 110px;
  }

  .chart-pan-controls input[type='range'] {
    width: 100%;
  }

  .chart-toggle-controls {
    gap: 0.35rem;
  }

  .chart-toggle-controls label {
    font-size: 0.74rem;
    padding: 0.2rem 0.44rem;
  }

  .panel-head {
    align-items: stretch;
  }

  .panel-head form {
    width: 100%;
  }

  .panel-head form .ghost {
    width: 100%;
  }

  .assistant-chat {
    max-height: 52vh;
  }

  .assistant-message,
  .assistant-message.user,
  .assistant-message.assistant {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .global-alerts-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .global-alert-item a {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .global-alert-title {
    white-space: normal;
    overflow: visible;
  }

  .ultra-mobile {
    position: fixed;
    left: 0.6rem;
    right: 0.6rem;
    bottom: 0.6rem;
    z-index: 90;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    padding: 0.45rem;
    border-radius: 13px;
    border: 1px solid #b9cbe6;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 10px 26px rgba(16, 35, 58, 0.2);
  }

  .ultra-mobile a,
  .ultra-mobile button {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 36px;
    font-size: 0.84rem;
    border-radius: 8px;
    text-decoration: none;
  }

  .ultra-mobile a {
    border: 1px solid #b7cff4;
    background: #edf4ff;
    color: #163e7e;
  }

  .ultra-mobile form {
    margin: 0;
  }

  .workspace-footer {
    padding-bottom: 4.8rem;
  }
}
