:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --line: #d9e0e7;
  --line-soft: #edf1f4;
  --text: #121820;
  --muted: #64727f;
  --accent: #156f68;
  --accent-dark: #0f4f4a;
  --accent-soft: #e8f4f1;
  --nav: #171a1f;
  --nav-soft: #242a31;
  --gold: #b98832;
  --control: #fbfcfd;
  --panel-glass: rgba(255, 255, 255, 0.92);
  --body-wash: rgba(255, 255, 255, 0.72);
  --body-wash-end: rgba(244, 246, 248, 0.72);
  --body-grid-x: rgba(18, 24, 32, 0.035);
  --body-grid-y: rgba(18, 24, 32, 0.025);
  --chart-grid: #d8e1ea;
  --chart-zero: #94a3b8;
  --green-1: #dcefe6;
  --green-2: #2f9363;
  --green-3: #0d6745;
  --red-1: #f6d9d4;
  --red-2: #c9534c;
  --red-3: #8f2d2a;
  --gray-tile: #65717e;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 14px 34px rgba(18, 24, 32, 0.08);
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --panel: #171c23;
  --panel-soft: #202731;
  --line: #313a46;
  --line-soft: #252d37;
  --text: #eef3f6;
  --muted: #9ba8b5;
  --accent: #62c8b5;
  --accent-dark: #8ee0cf;
  --accent-soft: rgba(98, 200, 181, 0.16);
  --nav: #080b0f;
  --nav-soft: #171d25;
  --gold: #d6aa56;
  --control: #111720;
  --panel-glass: rgba(23, 28, 35, 0.92);
  --body-wash: rgba(13, 17, 23, 0.84);
  --body-wash-end: rgba(15, 20, 27, 0.88);
  --body-grid-x: rgba(255, 255, 255, 0.035);
  --body-grid-y: rgba(255, 255, 255, 0.025);
  --chart-grid: #2c3540;
  --chart-zero: #6f8295;
  --green-2: #168a62;
  --green-3: #0b6a4a;
  --red-2: #bf4a4f;
  --red-3: #89313a;
  --gray-tile: #46515d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 18px 40px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, var(--body-wash), var(--body-wash-end)),
    linear-gradient(90deg, var(--body-grid-x) 1px, transparent 1px),
    linear-gradient(180deg, var(--body-grid-y) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 48px 48px, 48px 48px, auto;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: #eef2f4;
  background: linear-gradient(180deg, var(--nav), #111418);
  box-shadow: 10px 0 28px rgba(18, 24, 32, 0.10);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 26px;
  padding: 4px 4px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  color: #10201e;
  background: linear-gradient(135deg, #e7c56d, #76c2ae);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: #9daab5;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.theme-control {
  display: grid;
  gap: 6px;
  margin-top: 22px;
  padding: 14px 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.theme-control span {
  color: #9daab5;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.theme-control select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 7px;
  color: #eef2f4;
  background: var(--nav-soft);
}

.nav-button,
.secondary-button,
.quick-actions button {
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
}

.nav-button {
  position: relative;
  padding: 11px 12px 11px 14px;
  text-align: left;
  color: #aeb8c2;
  background: transparent;
}

.nav-button.active,
.nav-button:hover {
  color: #ffffff;
  background: var(--nav-soft);
}

.nav-button.active::before {
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 999px;
  background: var(--gold);
  content: "";
}

.content {
  min-width: 0;
  padding: 24px 28px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0;
}

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

.secondary-button,
.quick-actions button {
  padding: 9px 12px;
  color: var(--text);
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.secondary-button:hover,
.quick-actions button:hover {
  border-color: #9fb2c3;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-glass);
  box-shadow: var(--shadow-sm);
}

.toolbar label {
  display: grid;
  gap: 5px;
}

.toolbar label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toolbar input,
.toolbar select {
  height: 36px;
  min-width: 142px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--control);
}

.toolbar .check-label {
  display: flex;
  height: 36px;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
}

.toolbar .check-label input {
  min-width: auto;
  width: 16px;
  height: 16px;
}

.quick-actions {
  display: flex;
  gap: 6px;
}

.market-map {
  display: grid;
  gap: 12px;
  align-items: start;
}

.market-section {
  display: grid;
  gap: 9px;
}

.section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #344250;
  font-size: 15px;
  font-weight: 700;
}

.section-title::before {
  width: 4px;
  height: 16px;
  border-radius: 999px;
  background: var(--gold);
  content: "";
}

.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.tile {
  display: grid;
  grid-template-rows: 36px 20px 22px 16px;
  width: 154px;
  height: 112px;
  padding: 8px 10px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 7px;
  color: #ffffff;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 9px 18px rgba(18, 24, 32, 0.10);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 13px 24px rgba(18, 24, 32, 0.14);
}

.tile-title,
.tile-price,
.tile-change,
.tile-dividend {
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
}

.tile-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  align-self: center;
  font-size: 12px;
  font-weight: 700;
}

.tile-price {
  font-size: 12px;
  font-weight: 700;
}

.tile-change {
  font-size: 12px;
  font-weight: 700;
}

.tile-dividend {
  font-size: 10px;
}

.tile.neutral {
  background: var(--gray-tile);
}

.tile.up-strong {
  background: var(--green-3);
}

.tile.up {
  background: var(--green-2);
}

.tile.up-soft {
  background: #68b983;
}

.tile.down-strong {
  background: var(--red-3);
}

.tile.down {
  background: var(--red-2);
}

.tile.down-soft {
  background: #ec7d72;
}

.chart-toolbar .search-box {
  flex: 1 1 280px;
}

.chart-toolbar .search-box input {
  width: 100%;
}

.chart-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
}

.fundamentals-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.hidden-list {
  display: none !important;
}

.instrument-list,
.chart-panel,
.fundamentals-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-md);
}

.instrument-list {
  max-height: calc(100vh - 188px);
  overflow: auto;
}

.instrument-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.instrument-item:hover,
.instrument-item.active {
  background: var(--accent-soft);
}

.instrument-item strong,
.instrument-item span {
  display: block;
}

.instrument-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-panel {
  position: relative;
  min-height: 420px;
  padding: 16px;
}

.comparison-only {
  display: none !important;
}

body.comparison-mode .comparison-only {
  display: grid !important;
}

body.comparison-mode .single-only {
  display: none !important;
}

.comparison-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
  margin-bottom: 8px;
}

.comparison-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #fbfcfd;
}

.comparison-chip button {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

#price-chart {
  display: block;
  width: 100%;
  height: min(560px, calc(100vh - 214px));
}

.chart-legend {
  display: none;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  min-height: 28px;
  padding: 4px 2px 0;
}

body.comparison-mode .chart-legend {
  display: flex;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #344250;
  font-size: 12px;
  font-weight: 700;
}

.legend-swatch {
  width: 22px;
  height: 3px;
  border-radius: 999px;
}

.chart-tooltip {
  position: absolute;
  display: none;
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 7px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
  font-size: 12px;
  pointer-events: none;
  z-index: 3;
}

.fundamentals-panel {
  min-width: 0;
  padding: 14px;
}

.company-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
}

.company-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(21, 111, 104, 0.06), transparent 42%),
    #ffffff;
  box-shadow: var(--shadow-sm);
}

.company-card:empty {
  display: none;
}

.company-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.company-title {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.company-logo {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-dark);
  background: #fbfcfd;
  font-size: 13px;
  font-weight: 900;
}

.company-logo img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.company-name-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.company-name-line strong {
  font-size: 25px;
  letter-spacing: 0;
}

.company-name-line span {
  color: var(--muted);
  font-size: 14px;
}

.company-card h2 {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  color: #344250;
}

.company-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.company-links a {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--accent-dark);
  background: #fbfcfd;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.company-links a:hover {
  border-color: #9fb2c3;
}

.company-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.company-meta span {
  padding: 5px 8px;
  border-radius: 7px;
  color: #344250;
  background: #f0f3f5;
  font-size: 12px;
  font-weight: 700;
}

.company-key-indicators {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 10px;
  align-items: stretch;
  height: 100%;
}

.company-key-indicator {
  min-width: 0;
  min-height: 82px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.company-key-indicator-accent {
  border-color: #a7d5c9;
  background: linear-gradient(180deg, #ffffff, #f2faf7);
  box-shadow: inset 3px 0 0 var(--accent), var(--shadow-sm);
}

.company-key-indicator-accent span,
.company-key-indicator-accent strong {
  color: #116a3a;
}

.company-key-indicator span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.company-key-indicator strong {
  display: block;
  color: #0f172a;
  font-size: 19px;
  font-weight: 850;
  letter-spacing: 0;
  white-space: nowrap;
}

.company-key-strip {
  display: grid;
  gap: 6px;
  align-self: stretch;
}

.company-key-strip:empty {
  display: none;
}

.company-description {
  max-width: 980px;
  margin: 0;
  color: #475569;
  line-height: 1.5;
  font-size: 13px;
}

@media (max-width: 760px) {
  .company-overview {
    grid-template-columns: 1fr;
  }

  .company-card-head {
    grid-template-columns: 1fr;
  }

  .company-links {
    justify-content: flex-start;
  }

  .company-key-indicators {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 2px 0 12px;
  padding-bottom: 2px;
  overflow-x: auto;
}

.tab-button {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #fbfcfd;
  cursor: pointer;
  white-space: nowrap;
}

.tab-button.active,
.tab-button:hover {
  color: var(--accent-dark);
  border-color: #bdd8d2;
  background: var(--accent-soft);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 240px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.admin-report-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.admin-inline-form label {
  display: grid;
  gap: 4px;
  min-width: 128px;
}

.admin-inline-form label.wide-field {
  flex: 1 1 260px;
}

.admin-inline-form span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-inline-form input,
.admin-inline-form select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  color: var(--text);
  background: #ffffff;
}

.statement-form-panel {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid #c8d7e4;
  border-radius: 8px;
  background: #f4f9fb;
}

.statement-form-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.statement-form-head div {
  display: grid;
  gap: 3px;
}

.statement-form-head span {
  color: var(--muted);
  font-size: 12px;
}

.statement-form-table input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  color: var(--text);
  background: #ffffff;
}

.statement-form-table th:first-child,
.statement-form-table td:first-child {
  min-width: 120px;
  max-width: 180px;
}

.statement-form-table th:nth-child(2),
.statement-form-table td:nth-child(2) {
  min-width: 64px;
  max-width: 76px;
  text-align: center;
}

.statement-form-table th:nth-child(3),
.statement-form-table td:nth-child(3) {
  min-width: 260px;
  max-width: 380px;
  text-align: left;
}

.statement-form-table th:nth-child(4),
.statement-form-table td:nth-child(4) {
  min-width: 150px;
}

.statement-form-table th:nth-child(5),
.statement-form-table td:nth-child(5) {
  min-width: 72px;
  max-width: 88px;
}

.statement-form-table small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.databook-import-panel {
  background: #fbfdff;
}

.databook-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.databook-actions input[type="file"] {
  max-width: 260px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  font-size: 12px;
}

.databook-summary {
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.databook-preview-scroll {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.databook-preview-scroll .data-table {
  border: 0;
}

.databook-preview-table th:first-child,
.databook-preview-table td:first-child {
  min-width: 260px;
}

.databook-preview-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.databook-item-select,
.databook-value-input,
.databook-unit-select {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  font-size: 12px;
}

.databook-value-input {
  width: 120px;
}

.databook-unit-select {
  width: 96px;
}

.databook-save-aliases {
  margin-top: 10px;
}

.required-mark {
  display: inline-flex;
  padding: 3px 6px;
  border-radius: 999px;
  color: #7a2e0e;
  background: #fff2cc;
  font-size: 11px;
  font-weight: 800;
}

.data-table {
  width: max-content;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: #ffffff;
}

.data-table th,
.data-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  white-space: nowrap;
}

.data-table th:not(:first-child),
.data-table td:not(:first-child) {
  min-width: 96px;
}

.data-table th:first-child,
.data-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 220px;
  max-width: 360px;
  text-align: left;
  background: inherit;
  white-space: normal;
}

.data-table tr:nth-child(even) {
  background: #fbfcfd;
}

.data-table tr:hover {
  background: #f4f8f7;
}

.data-table tr:hover td:first-child {
  background: #f4f8f7;
}

.data-table tr.dividend-announced-row,
.data-table tr.dividend-announced-row:hover {
  color: var(--green-3);
  background: var(--green-1);
}

.data-table tr.dividend-announced-row td:first-child,
.data-table tr.dividend-announced-row:hover td:first-child {
  color: var(--green-3);
  background: var(--green-1);
  font-weight: 700;
}

:root[data-theme="dark"] .data-table tr.dividend-announced-row,
:root[data-theme="dark"] .data-table tr.dividend-announced-row:hover,
:root[data-theme="dark"] .data-table tr.dividend-announced-row td:first-child,
:root[data-theme="dark"] .data-table tr.dividend-announced-row:hover td:first-child {
  color: #8ee0b6;
  background: rgba(22, 138, 98, 0.18);
}

.annual-table th:nth-child(2),
.annual-table td:nth-child(2) {
  min-width: 76px;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: #344250;
  background: #f1f4f6;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.data-table th:first-child {
  z-index: 3;
  background: #f1f4f6;
}

.admin-data-table th:first-child,
.admin-data-table td:first-child {
  min-width: 150px;
  max-width: 260px;
}

.statement-items-table th:nth-child(2),
.statement-items-table td:nth-child(2) {
  min-width: 260px;
  max-width: 420px;
  text-align: left;
  white-space: normal;
}

.metric-label {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  border-radius: 4px;
  cursor: help;
  outline: none;
}

.metric-label:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.metric-help {
  display: inline-grid;
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.metric-label:hover .metric-help,
.metric-label:focus-visible .metric-help {
  color: var(--accent-dark);
  border-color: #9fc9c0;
  background: var(--accent-soft);
}

.metric-description-tooltip {
  position: fixed;
  z-index: 500;
  width: min(340px, calc(100vw - 24px));
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  line-height: 1.45;
  white-space: normal;
  pointer-events: none;
}

.metric-description-tooltip[hidden] {
  display: none;
}

.statement-items-table th:first-child,
.statement-items-table td:first-child {
  width: 270px;
  min-width: 270px;
  max-width: 270px;
  white-space: nowrap;
}

.statement-items-table th:nth-child(3),
.statement-items-table td:nth-child(3) {
  min-width: 110px;
  text-align: right;
}

.statement-items-table th:nth-child(4),
.statement-items-table td:nth-child(4) {
  min-width: 120px;
  text-align: left;
}

.statement-items-table th:nth-child(5),
.statement-items-table td:nth-child(5) {
  min-width: 110px;
}

.selected-row td {
  background: var(--accent-soft);
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

.table-link {
  padding: 0;
  border: 0;
  color: var(--accent);
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.table-link:hover {
  text-decoration: underline;
}

.danger-link {
  color: #b42318;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed #b7c4c5;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.compact-empty {
  padding: 10px 12px;
  font-size: 13px;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
  }

  .brand {
    margin: 0;
  }

  .nav {
    display: flex;
  }

  .chart-layout {
    grid-template-columns: 1fr;
  }

  .fundamentals-layout {
    grid-template-columns: 1fr;
  }

  .instrument-list {
    max-height: 220px;
  }
}

.head-actions,
.actions-row,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.primary-button {
  padding: 9px 12px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: #ffffff;
  background: var(--accent);
  box-shadow: var(--shadow-sm);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.tile {
  cursor: default;
}

.tile-title,
.tile-price {
  border: 0;
  padding: 0;
  color: #ffffff;
  background: transparent;
  cursor: pointer;
}

.tile-title:hover,
.tile-price:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 14px;
}

.hidden {
  display: none !important;
}

.portfolio-home {
  margin-top: 16px;
}

.portfolio-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 280px));
  gap: 12px;
}


.portfolio-add-card {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  min-height: 124px;
  padding: 18px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.portfolio-add-card:hover {
  border-style: solid;
  transform: translateY(-1px);
}

.portfolio-add-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--accent);
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
}

.portfolio-operation-modal-panel,
.portfolio-modal-panel {
  grid-template-rows: auto minmax(0, 1fr);
  width: min(520px, 100%);
}

.portfolio-operation-modal-form,
.portfolio-modal-form {
  display: grid;
  gap: 14px;
}

.portfolio-operation-modal-form label,
.portfolio-modal-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.portfolio-operation-modal-form input,
.portfolio-operation-modal-form select,
.portfolio-modal-form input,
.portfolio-modal-form select {
  width: 100%;
}

.portfolio-list-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  text-align: left;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.portfolio-card-main {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 4px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.portfolio-card-actions {
  display: flex;
  gap: 6px;
}

.portfolio-action-button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.portfolio-action-button.danger {
  color: var(--danger);
}

.portfolio-list-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.portfolio-card-main span {
  font-size: 16px;
  font-weight: 700;
}

.portfolio-card-main strong,
.portfolio-card-main small {
  color: var(--muted);
}

.portfolio-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 16px 0;
}

.portfolio-detail-head div {
  display: grid;
  gap: 4px;
  text-align: right;
}

.portfolio-detail-head span {
  color: var(--muted);
  font-size: 12px;
}

.portfolio-detail-head strong {
  font-size: 18px;
}

.portfolio-form-grid.detail-grid {
  grid-template-columns: minmax(260px, 0.8fr) minmax(520px, 2fr);
}

@media (max-width: 760px) {
  .portfolio-create-form,
  .portfolio-form-grid.detail-grid {
    grid-template-columns: 1fr;
  }

  .portfolio-detail-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .portfolio-detail-head div {
    text-align: left;
  }
}

.portfolio-editor {
  margin: 16px 0 18px;
}

.portfolio-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.portfolio-editor-head h2,
.mini-form h3 {
  margin: 0 0 8px;
}

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

.portfolio-form-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1fr) minmax(420px, 1.8fr);
  gap: 12px;
  align-items: start;
}

.mini-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.mini-form label,
.portfolio-operation-grid label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.mini-form input,
.mini-form select,
.portfolio-operation-grid input,
.portfolio-operation-grid select {
  width: 100%;
}

.portfolio-operation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
}

.portfolio-operation-grid .wide {
  grid-column: span 3;
}

.ticker-search-field {
  position: relative;
  z-index: 3;
}

.ticker-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  display: grid;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
}

.ticker-suggestion {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.ticker-suggestion:hover,
.ticker-suggestion:focus-visible {
  background: var(--panel-soft);
}

.ticker-suggestion strong {
  font-size: 13px;
  color: var(--text);
}

.ticker-suggestion span,
.ticker-suggestion-empty {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticker-suggestion-empty {
  padding: 10px;
}

.form-status {
  min-height: 20px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.form-status.error {
  color: var(--red-3);
}

@media (max-width: 1120px) {
  .portfolio-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .portfolio-operation-grid {
    grid-template-columns: 1fr;
  }

  .portfolio-operation-grid .wide {
    grid-column: auto;
  }
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.portfolio-card {
  display: grid;
  gap: 7px;
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-glass);
  box-shadow: var(--shadow-sm);
}

.portfolio-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.portfolio-card strong {
  font-size: 24px;
  line-height: 1;
}

.positive-text {
  color: var(--green);
}

.negative-text {
  color: var(--red);
}

.portfolio-tabs {
  margin-bottom: 12px;
}

.portfolio-layout {
  display: block;
}

.portfolio-tab-panel {
  display: none;
}

.portfolio-tab-panel.active {
  display: block;
}

.management-panel {
  display: none;
}

.management-panel.active {
  display: block;
}

.admin-users-table td:first-child {
  min-width: 220px;
}

.admin-users-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6f8fb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.role-badge.role-moderator {
  border-color: rgba(15, 107, 143, 0.28);
  background: rgba(15, 107, 143, 0.10);
  color: var(--blue);
}

.role-badge.role-admin {
  color: #6b3cc9;
  background: #f1ebff;
  border-color: #d9c8ff;
}

.role-editor {
  display: flex;
  gap: 8px;
  align-items: center;
}

.role-editor select {
  min-width: 150px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--control);
}

.role-editor .secondary-button {
  padding: 7px 10px;
}

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

.compact-table-wrap {
  max-height: 420px;
}

.portfolio-table th,
.portfolio-table td {
  text-align: right;
  vertical-align: top;
}

.portfolio-table th:first-child,
.portfolio-table td:first-child {
  min-width: 120px;
  max-width: 220px;
  text-align: left;
}

.portfolio-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  white-space: normal;
}

.portfolio-position-company {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.portfolio-position-logo {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.portfolio-position-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.portfolio-position-logo.placeholder {
  background: var(--panel-glass);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.portfolio-position-link {
  color: var(--text);
  font-weight: 900;
  text-decoration: none;
}

.portfolio-position-link:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.portfolio-profit strong,
.portfolio-profit small {
  display: block;
}

.portfolio-profit {
  font-weight: 800;
}

.portfolio-profit.strong-positive strong,
.portfolio-profit.strong-positive small {
  color: #15803d;
}

.portfolio-profit.mild-positive strong,
.portfolio-profit.mild-positive small {
  color: #166534;
}

.portfolio-profit.mild-negative strong,
.portfolio-profit.mild-negative small {
  color: #92400e;
}

.portfolio-profit.strong-negative strong,
.portfolio-profit.strong-negative small {
  color: #b91c1c;
}

:root[data-theme="dark"] .portfolio-profit.strong-positive strong,
:root[data-theme="dark"] .portfolio-profit.strong-positive small {
  color: #86efac;
}

:root[data-theme="dark"] .portfolio-profit.mild-positive strong,
:root[data-theme="dark"] .portfolio-profit.mild-positive small {
  color: #bbf7d0;
}

:root[data-theme="dark"] .portfolio-profit.mild-negative strong,
:root[data-theme="dark"] .portfolio-profit.mild-negative small {
  color: #fcd34d;
}

:root[data-theme="dark"] .portfolio-profit.strong-negative strong,
:root[data-theme="dark"] .portfolio-profit.strong-negative small {
  color: #fca5a5;
}

.table-sort-button {
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.table-sort-button:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.portfolio-operations-table th:first-child,
.portfolio-operations-table td:first-child {
  min-width: 132px;
}

.portfolio-operations-table th:nth-child(3),
.portfolio-operations-table td:nth-child(3) {
  min-width: 180px;
  max-width: 320px;
  text-align: left;
}

.panel-block {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
}

.panel-block h2 {
  margin: 0 0 14px;
  font-size: 18px;
  letter-spacing: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.form-grid.single-line {
  grid-template-columns: minmax(0, 1fr);
}

.form-grid label {
  display: grid;
  gap: 5px;
}

.form-grid label span {
  color: var(--muted);
  font-size: 12px;
}

.form-grid .required-field span::after {
  content: " *";
  color: var(--danger);
}

.form-grid .muted-field {
  opacity: 0.72;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  height: 38px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #ffffff;
}

.form-grid textarea {
  height: auto;
  min-height: 92px;
  padding: 9px 10px;
  resize: vertical;
}

.profile-summary {
  display: grid;
  grid-template-columns: 56px minmax(180px, 1fr) minmax(320px, auto);
  align-items: center;
  gap: 16px;
  max-width: 980px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
}

.profile-avatar {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 50%;
  color: #10201e;
  background: linear-gradient(135deg, #e7c56d, #76c2ae);
  font-size: 17px;
  font-weight: 800;
}

.profile-summary h2,
.profile-summary p,
.profile-meta {
  margin: 0;
}

.profile-summary h2 {
  font-size: 19px;
}

.profile-summary p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.profile-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(135px, 1fr));
  gap: 20px;
}

.profile-meta div {
  min-width: 0;
}

.profile-meta dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.profile-meta dd {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.profile-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 980px;
}

.profile-panel {
  align-self: start;
}

.profile-form {
  display: grid;
  gap: 12px;
}

.profile-form label {
  display: grid;
  gap: 5px;
}

.profile-form label span {
  color: var(--muted);
  font-size: 12px;
}

.profile-form input {
  width: 100%;
  height: 40px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #ffffff;
}

.profile-form-actions {
  display: flex;
  justify-content: flex-start;
  padding-top: 2px;
}

.profile-form .form-status {
  min-height: 18px;
}

:root[data-theme="dark"] .profile-summary,
:root[data-theme="dark"] .profile-form input {
  background: #182321;
}

@media (max-width: 820px) {
  .profile-summary {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .profile-meta {
    grid-column: 1 / -1;
  }

  .profile-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .profile-meta {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.wide-field {
  grid-column: 1 / -1;
}

.log-box {
  min-height: 170px;
  max-height: 360px;
  margin-top: 14px;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #334155;
  background: #f8fafc;
  font-family: Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.factory-table {
  max-height: calc(100vh - 190px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
}

.data-factory-tabs {
  flex-wrap: wrap;
}

.quality-dashboard {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.quality-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.quality-header h2 {
  margin: 0;
  font-size: 20px;
}

.quality-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.quality-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
}

.quality-card {
  display: grid;
  gap: 8px;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-align: left;
  background: #ffffff;
  cursor: pointer;
}

.quality-card:hover,
.quality-card.active {
  border-color: #7da9bb;
  background: #edf7fb;
}

.quality-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.quality-card strong {
  font-size: 28px;
  line-height: 1;
}

.quality-summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.quality-summary-strip div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid #e3ebf2;
  border-radius: 8px;
  background: #f8fafc;
}

.quality-summary-strip span {
  color: var(--muted);
  font-size: 12px;
}

.quality-summary-strip strong {
  font-size: 18px;
}

.quality-issues-table {
  width: 100%;
  min-width: 980px;
}

.quality-issues-table th,
.quality-issues-table td {
  text-align: left;
  white-space: normal;
  vertical-align: top;
}

.quality-issues-table th:first-child,
.quality-issues-table td:first-child {
  min-width: 118px;
  max-width: 150px;
}

.quality-issues-table th:nth-child(3),
.quality-issues-table td:nth-child(3) {
  min-width: 230px;
  max-width: 340px;
}

.quality-issues-table th:nth-child(4),
.quality-issues-table td:nth-child(4) {
  min-width: 260px;
  max-width: 380px;
}

.quality-issues-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.severity-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 50%;
  background: #94a3b8;
}

.severity-critical {
  background: var(--red-2);
}

.severity-warning {
  background: #d99a22;
}

.severity-info {
  background: var(--accent);
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(780px, 100%);
  max-height: min(760px, 92vh);
  padding: 16px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-head h2 {
  margin: 0;
  font-size: 22px;
}

.modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #ffffff;
  cursor: pointer;
}

.modal-toolbar {
  margin-bottom: 10px;
}

.selection-list {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.selection-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border-bottom: 1px solid #edf2f7;
}

.selection-item:last-child {
  border-bottom: 0;
}

.selection-item strong,
.selection-item span {
  display: block;
}

.selection-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.selection-item input {
  width: 16px;
  height: 16px;
}

:root[data-theme="dark"] .secondary-button,
:root[data-theme="dark"] .quick-actions button,
:root[data-theme="dark"] .comparison-chip,
:root[data-theme="dark"] .tab-button,
:root[data-theme="dark"] .company-links a,
:root[data-theme="dark"] .icon-button {
  color: var(--text);
  background: var(--control);
}

:root[data-theme="dark"] .secondary-button:hover,
:root[data-theme="dark"] .quick-actions button:hover,
:root[data-theme="dark"] .company-links a:hover {
  border-color: #526274;
}

:root[data-theme="dark"] .toolbar input,
:root[data-theme="dark"] .toolbar select,
:root[data-theme="dark"] .form-grid input,
:root[data-theme="dark"] .form-grid select,
:root[data-theme="dark"] .form-grid textarea,
:root[data-theme="dark"] .admin-inline-form input,
:root[data-theme="dark"] .admin-inline-form select,
:root[data-theme="dark"] .statement-form-table input,
:root[data-theme="dark"] .databook-actions input[type="file"],
:root[data-theme="dark"] .databook-item-select,
:root[data-theme="dark"] .databook-value-input,
:root[data-theme="dark"] .databook-unit-select {
  color: var(--text);
  background: var(--control);
}

:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder {
  color: #6f7d8b;
}

:root[data-theme="dark"] .instrument-list,
:root[data-theme="dark"] .chart-panel,
:root[data-theme="dark"] .fundamentals-panel,
:root[data-theme="dark"] .panel-block,
:root[data-theme="dark"] .factory-table,
:root[data-theme="dark"] .table-wrap,
:root[data-theme="dark"] .modal-panel {
  background: var(--panel-glass);
}

:root[data-theme="dark"] .company-card {
  background:
    linear-gradient(90deg, rgba(98, 200, 181, 0.10), transparent 44%),
    var(--panel);
}

:root[data-theme="dark"] .company-logo,
:root[data-theme="dark"] .company-key-indicator,
:root[data-theme="dark"] .data-table,
:root[data-theme="dark"] .databook-preview-scroll,
:root[data-theme="dark"] .quality-card {
  background: var(--panel);
}

:root[data-theme="dark"] .company-key-indicator-accent {
  border-color: rgba(98, 200, 181, 0.42);
  background: linear-gradient(180deg, rgba(98, 200, 181, 0.14), var(--panel));
}

:root[data-theme="dark"] .ticker-suggestions {
  background: var(--panel);
  border-color: #334155;
}

:root[data-theme="dark"] .ticker-suggestion:hover,
:root[data-theme="dark"] .ticker-suggestion:focus-visible {
  background: var(--control);
}

:root[data-theme="dark"] .company-key-indicator strong,
:root[data-theme="dark"] .company-key-indicator-accent span,
:root[data-theme="dark"] .company-key-indicator-accent strong,
:root[data-theme="dark"] .company-card h2,
:root[data-theme="dark"] .company-description,
:root[data-theme="dark"] .legend-item,
:root[data-theme="dark"] .section-title,
:root[data-theme="dark"] .log-box,
:root[data-theme="dark"] .databook-summary,
:root[data-theme="dark"] .data-table th {
  color: var(--text);
}

:root[data-theme="dark"] .company-meta span,
:root[data-theme="dark"] .log-box,
:root[data-theme="dark"] .admin-inline-form,
:root[data-theme="dark"] .statement-form-panel,
:root[data-theme="dark"] .quality-summary-strip div {
  background: var(--panel-soft);
}

:root[data-theme="dark"] .company-meta span {
  border: 1px solid rgba(98, 200, 181, 0.30);
  color: #dbe7ec;
  background: rgba(98, 200, 181, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

:root[data-theme="dark"] .data-table tr:nth-child(even),
:root[data-theme="dark"] .quality-card:hover,
:root[data-theme="dark"] .quality-card.active {
  background: #1b222b;
}

:root[data-theme="dark"] .data-table tr:hover,
:root[data-theme="dark"] .data-table tr:hover td:first-child {
  background: #202b32;
}

:root[data-theme="dark"] .data-table th,
:root[data-theme="dark"] .data-table th:first-child {
  background: #222a33;
}

:root[data-theme="dark"] .chart-tooltip {
  border-color: var(--line);
  background: rgba(17, 23, 32, 0.96);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.34);
}

:root[data-theme="dark"] .empty-state {
  background: rgba(23, 28, 35, 0.78);
}

:root[data-theme="dark"] .required-mark {
  color: #f0c674;
  background: rgba(214, 170, 86, 0.16);
}

:root[data-theme="dark"] .danger-link {
  color: #ff8d8d;
}

:root[data-theme="dark"] .selection-item {
  border-bottom-color: var(--line-soft);
}

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

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

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

  .theme-control {
    width: 150px;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
}

/* Compact period picker kept from the current functional version. */
.quick-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  align-items: center;
  min-height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.range-control {
  position: relative;
  display: grid;
  gap: 8px;
  align-self: end;
}

.quick-actions button {
  min-width: 38px;
  min-height: 28px;
  padding: 0 8px;
  border-color: transparent;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.quick-actions button:hover {
  border-color: transparent;
  color: var(--text);
  background: rgba(8, 119, 111, 0.08);
}

.quick-actions button.active {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 4px 10px rgba(8, 119, 111, 0.22);
}

.quick-actions button.active:hover {
  color: #ffffff;
  background: var(--accent-dark);
}

.quick-actions button.open:not(.active) {
  color: var(--accent-dark);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(8, 119, 111, 0.20);
}

.calendar-range-button {
  position: relative;
  width: 32px;
  min-width: 32px !important;
  padding: 0 !important;
}

.calendar-range-button::before {
  position: absolute;
  inset: 7px 8px 6px;
  border: 2px solid currentColor;
  border-top-width: 4px;
  border-radius: 3px;
  content: "";
}

.calendar-range-button::after {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 5px 0 currentColor;
  content: "";
}

.custom-range-panel {
  display: none;
  grid-template-columns: repeat(2, minmax(138px, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.range-control.custom-open .custom-range-panel {
  display: grid;
}

.custom-range-panel label {
  display: grid;
  gap: 5px;
}

.custom-range-panel label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.custom-range-panel input {
  height: 34px;
  min-width: 132px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--control);
  outline: none;
}

.custom-range-panel input:focus {
  border-color: rgba(8, 119, 111, 0.62);
  box-shadow: 0 0 0 3px rgba(8, 119, 111, 0.12);
}

:root[data-theme="dark"] .quick-actions {
  background: rgba(17, 23, 32, 0.82);
}

:root[data-theme="dark"] .custom-range-panel {
  background: var(--panel);
}

:root[data-theme="dark"] .quick-actions button {
  color: var(--muted);
  background: transparent;
}

:root[data-theme="dark"] .quick-actions button:hover {
  color: var(--text);
  background: rgba(98, 200, 181, 0.12);
}

:root[data-theme="dark"] .quick-actions button.active {
  color: #07120f;
  background: var(--accent);
  box-shadow: 0 4px 12px rgba(98, 200, 181, 0.20);
}

:root[data-theme="dark"] .quick-actions button.open:not(.active) {
  color: var(--accent-dark);
  background: rgba(98, 200, 181, 0.16);
  box-shadow: inset 0 0 0 1px rgba(98, 200, 181, 0.24);
}

@media (max-width: 960px) {
  .quick-actions {
    flex-wrap: wrap;
  }

  .range-control {
    width: 100%;
  }

  .custom-range-panel {
    grid-template-columns: 1fr 1fr;
  }
}








.required-field > span::after {
  content: " *";
  color: var(--danger);
}

.portfolio-operation-modal-panel {
  width: min(640px, 100%);
}

.portfolio-operations-table th:last-child,
.portfolio-operations-table td:last-child {
  min-width: 44px;
  text-align: center;
}

/* Portfolio polish */
#portfolio-view .page-head {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(21, 111, 104, 0.10), transparent 52%),
    var(--panel-glass);
  box-shadow: var(--shadow-sm);
}

#portfolio-view .page-head h1 {
  font-size: 24px;
}

#portfolio-view .page-head p {
  max-width: 760px;
  line-height: 1.45;
}

.portfolio-home {
  margin-top: 0;
}

.portfolio-home .portfolio-editor-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.portfolio-list {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.portfolio-add-card,
.portfolio-list-card,
.portfolio-card,
.portfolio-editor,
.portfolio-tab-panel {
  border-radius: 8px;
}

.portfolio-add-card {
  min-height: 142px;
  border-color: rgba(21, 111, 104, 0.42);
  background:
    linear-gradient(180deg, rgba(21, 111, 104, 0.10), rgba(21, 111, 104, 0.04)),
    var(--panel);
}

.portfolio-add-card strong {
  color: var(--accent-dark);
  font-size: 15px;
}

.portfolio-add-icon {
  width: 42px;
  height: 42px;
  font-size: 28px;
}

.portfolio-list-card {
  position: relative;
  min-height: 142px;
  padding: 14px;
  overflow: hidden;
  background: var(--panel);
}

.portfolio-list-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
  content: "";
}

.portfolio-card-main {
  gap: 10px;
  padding: 2px 4px 2px 8px;
}

.portfolio-card-main span {
  font-size: 17px;
  line-height: 1.2;
}

.portfolio-card-main strong {
  width: max-content;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 12px;
}

.portfolio-card-main small {
  font-size: 12px;
}

.portfolio-card-actions {
  position: relative;
  z-index: 1;
}

.portfolio-action-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--panel);
}

.portfolio-action-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.portfolio-action-button.danger {
  color: var(--red-3);
}

.portfolio-action-button.danger:hover {
  border-color: rgba(143, 45, 42, 0.34);
  color: var(--red-3);
  background: rgba(201, 83, 76, 0.09);
}

.portfolio-detail {
  display: grid;
  gap: 14px;
}

.portfolio-detail-head {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.portfolio-detail-head strong {
  font-size: 20px;
}

.portfolio-grid {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 0;
}

.portfolio-card {
  position: relative;
  min-height: 96px;
  padding: 16px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0)),
    var(--panel);
}

.portfolio-card::after {
  position: absolute;
  right: 14px;
  bottom: 12px;
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent-soft);
  content: "";
}

.portfolio-card span {
  font-size: 11px;
  letter-spacing: 0;
}

.portfolio-card strong {
  font-size: clamp(20px, 2vw, 26px);
  line-height: 1.15;
  word-break: break-word;
}

.portfolio-card .positive-text,
.positive-text {
  color: var(--green-3);
}

.portfolio-card .negative-text,
.negative-text {
  color: var(--red-3);
}

.portfolio-editor {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(185, 136, 50, 0.10), transparent 50%),
    var(--panel-glass);
}

.portfolio-editor-head {
  align-items: center;
  margin-bottom: 0;
}

.portfolio-editor-head h2 {
  font-size: 18px;
}

.portfolio-editor-head p {
  max-width: 820px;
  font-size: 13px;
  line-height: 1.45;
}

.portfolio-tabs {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  gap: 3px;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  box-shadow: var(--shadow-sm);
}

.portfolio-tabs .tab-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
  font-weight: 800;
}

.portfolio-tabs .tab-button.active {
  color: #ffffff;
  background: var(--accent);
}

.portfolio-tabs .tab-button:hover:not(.active) {
  color: var(--text);
  background: rgba(21, 111, 104, 0.08);
}

.tab-count {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel);
  font-size: 11px;
  font-weight: 900;
}

.portfolio-tabs .tab-button.active .tab-count {
  color: var(--accent-dark);
  background: #ffffff;
}

.portfolio-tab-panel {
  padding: 0;
  overflow: hidden;
  background: var(--panel);
}

.portfolio-tab-panel h2 {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 16px;
}

.compact-table-wrap {
  max-height: 540px;
  border: 0;
  border-radius: 0;
}

.portfolio-table {
  width: max-content;
  min-width: 820px;
}

.portfolio-table th,
.portfolio-table td {
  padding: 11px 12px;
}

.portfolio-table th:first-child,
.portfolio-table td:first-child {
  min-width: 220px;
}

.portfolio-position-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.portfolio-position-link {
  font-weight: 850;
}

.portfolio-profit strong {
  font-size: 14px;
}

.portfolio-profit small {
  font-weight: 800;
}

#portfolio-modal .modal-panel,
#portfolio-operation-modal .modal-panel,
#portfolio-confirm-modal .modal-panel {
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.48);
  background: var(--panel);
}

#portfolio-modal .modal-head,
#portfolio-operation-modal .modal-head,
#portfolio-confirm-modal .modal-head {
  align-items: flex-start;
  margin: 0;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
  background:
    linear-gradient(90deg, rgba(21, 111, 104, 0.10), transparent 58%),
    var(--panel);
}

#portfolio-modal .modal-head h2,
#portfolio-operation-modal .modal-head h2,
#portfolio-confirm-modal .modal-head h2 {
  font-size: 20px;
}

#portfolio-modal .modal-head p,
#portfolio-operation-modal .modal-head p,
#portfolio-confirm-modal .modal-head p {
  max-width: 560px;
  line-height: 1.4;
}

.portfolio-modal-form,
.portfolio-operation-modal-form {
  padding: 16px 18px 18px;
}

.portfolio-modal-form label,
.portfolio-operation-modal-form label,
.portfolio-operation-grid label {
  gap: 7px;
  font-size: 12px;
  font-weight: 800;
}

.portfolio-modal-form label span,
.portfolio-operation-modal-form label span,
.portfolio-operation-grid label span {
  color: var(--muted);
  text-transform: uppercase;
}

.portfolio-modal-form input,
.portfolio-modal-form select,
.portfolio-operation-modal-form input,
.portfolio-operation-modal-form select,
.portfolio-operation-grid input,
.portfolio-operation-grid select {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--control);
  outline: none;
}

.portfolio-modal-form input:focus,
.portfolio-modal-form select:focus,
.portfolio-operation-modal-form input:focus,
.portfolio-operation-modal-form select:focus,
.portfolio-operation-grid input:focus,
.portfolio-operation-grid select:focus {
  border-color: rgba(21, 111, 104, 0.62);
  box-shadow: 0 0 0 3px rgba(21, 111, 104, 0.12);
}

.portfolio-operation-modal-panel {
  width: min(720px, 100%);
}

.portfolio-operation-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.portfolio-operation-grid .wide {
  grid-column: span 2;
}

.portfolio-form-actions {
  padding-top: 4px;
}

.portfolio-confirm-panel {
  width: min(460px, 100%);
}

.portfolio-confirm-body {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 18px;
}

.portfolio-confirm-body p {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

.portfolio-confirm-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 999px;
  color: var(--red-3);
  background: rgba(201, 83, 76, 0.12);
  font-weight: 900;
}

#portfolio-confirm-modal .modal-actions {
  padding: 0 18px 18px;
}

.danger-button {
  border-color: var(--red-3);
  background: var(--red-3);
}

.danger-button:hover {
  background: var(--red-2);
}

:root[data-theme="dark"] #portfolio-view .page-head,
:root[data-theme="dark"] .portfolio-card,
:root[data-theme="dark"] .portfolio-editor,
:root[data-theme="dark"] .portfolio-tab-panel,
:root[data-theme="dark"] .portfolio-list-card,
:root[data-theme="dark"] .portfolio-detail-head {
  background:
    linear-gradient(90deg, rgba(98, 200, 181, 0.035), transparent 52%),
    var(--panel);
}

:root[data-theme="dark"] .portfolio-list-card::before {
  background: #3a7f76;
}

:root[data-theme="dark"] .portfolio-add-card {
  border-color: rgba(98, 200, 181, 0.22);
  background:
    linear-gradient(180deg, rgba(98, 200, 181, 0.055), rgba(98, 200, 181, 0.025)),
    var(--panel);
}

:root[data-theme="dark"] .portfolio-add-card strong {
  color: #b7d4cf;
}

:root[data-theme="dark"] .role-badge {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

:root[data-theme="dark"] .role-badge.role-moderator {
  border-color: rgba(61, 184, 217, 0.35);
  background: rgba(61, 184, 217, 0.14);
  color: #8bd8ee;
}

:root[data-theme="dark"] .role-badge.role-admin {
  color: #d8c6ff;
  background: #302252;
  border-color: #594584;
}

:root[data-theme="dark"] .portfolio-add-icon {
  background: #3a7f76;
}

:root[data-theme="dark"] .portfolio-card::after {
  background: rgba(98, 200, 181, 0.10);
}

:root[data-theme="dark"] .portfolio-card-main strong {
  color: #b7d4cf;
  background: rgba(98, 200, 181, 0.075);
}

:root[data-theme="dark"] .portfolio-tabs {
  background: var(--control);
}

:root[data-theme="dark"] .portfolio-tabs .tab-button.active {
  color: #eef3f6;
  background: #3a7f76;
}

:root[data-theme="dark"] .portfolio-tabs .tab-button.active .tab-count {
  color: #dbe8e5;
  background: rgba(13, 17, 23, 0.42);
}

:root[data-theme="dark"] #portfolio-modal .modal-head,
:root[data-theme="dark"] #portfolio-operation-modal .modal-head,
:root[data-theme="dark"] #portfolio-confirm-modal .modal-head {
  background:
    linear-gradient(90deg, rgba(98, 200, 181, 0.045), transparent 54%),
    var(--panel);
}

:root[data-theme="dark"] .portfolio-modal-form input,
:root[data-theme="dark"] .portfolio-modal-form select,
:root[data-theme="dark"] .portfolio-operation-modal-form input,
:root[data-theme="dark"] .portfolio-operation-modal-form select,
:root[data-theme="dark"] .portfolio-operation-grid input,
:root[data-theme="dark"] .portfolio-operation-grid select {
  background: var(--control);
}

@media (max-width: 1040px) {
  .portfolio-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 760px) {
  #portfolio-view .page-head,
  .portfolio-detail-head,
  .portfolio-editor-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .portfolio-tabs {
    width: 100%;
  }

  .portfolio-tabs .tab-button {
    flex: 1 1 0;
    justify-content: center;
  }

  .portfolio-operation-grid,
  .portfolio-operation-grid .wide {
    grid-template-columns: 1fr;
    grid-column: auto;
  }

  .portfolio-confirm-body {
    grid-template-columns: 1fr;
  }
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(18, 24, 32, 0.06), transparent 34%),
    linear-gradient(180deg, var(--body-wash), var(--body-wash-end)),
    linear-gradient(90deg, var(--body-grid-x) 1px, transparent 1px),
    linear-gradient(180deg, var(--body-grid-y) 1px, transparent 1px),
    var(--bg);
  background-size: auto, auto, 44px 44px, 44px 44px, auto;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 440px);
  width: min(980px, 100%);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-md);
}

.auth-hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 34px;
  color: #eef3f6;
  background:
    linear-gradient(145deg, rgba(185, 136, 50, 0.18), transparent 44%),
    linear-gradient(180deg, #171a1f, #101317);
}

.auth-hero .brand-mark {
  width: 50px;
  height: 46px;
}

.auth-hero h1 {
  margin: 8px 0 12px;
  color: #ffffff;
  font-size: 34px;
}

.auth-hero p {
  max-width: 440px;
  margin: 0;
  color: #b8c3cc;
  line-height: 1.55;
}

.auth-card {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 42px;
  background: var(--panel);
}

.auth-card-head {
  display: grid;
  gap: 8px;
  margin-bottom: 4px;
}

.auth-card h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.auth-card p,
.auth-kicker {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-kicker {
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-field {
  display: grid;
  gap: 7px;
}

.auth-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.auth-field input {
  width: 100%;
  height: 46px;
  border: 1px solid #b9c5d0;
  border-radius: 8px;
  padding: 0 13px;
  color: var(--text);
  background: #ffffff;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(18, 24, 32, 0.03);
}

.auth-field input::placeholder {
  color: #8b98a5;
}

.auth-field input:focus {
  border-color: rgba(21, 111, 104, 0.72);
  box-shadow: 0 0 0 3px rgba(21, 111, 104, 0.14);
}

.auth-actions {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.auth-actions .primary-button {
  min-height: 46px;
  font-weight: 850;
}

.auth-card .form-status {
  margin-top: 0;
}

:root[data-theme="dark"] .auth-layout {
  background: var(--panel);
  border-color: var(--line);
}

:root[data-theme="dark"] .auth-card {
  background: var(--panel);
}

:root[data-theme="dark"] .auth-field input {
  border-color: #43505d;
  color: var(--text);
  background: #0f151d;
}

:root[data-theme="dark"] .auth-field input:focus {
  border-color: #5da89e;
  box-shadow: 0 0 0 3px rgba(98, 200, 181, 0.12);
}

@media (max-width: 820px) {
  .auth-screen {
    padding: 18px;
  }

  .auth-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .auth-hero {
    padding: 24px;
  }

  .auth-hero h1 {
    font-size: 28px;
  }

  .auth-card {
    padding: 28px 24px 30px;
  }
}

.user-panel {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.user-panel span {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0;
  text-align: center;
}

.text-button:hover {
  text-decoration: underline;
}

@media (max-width: 960px) {
  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    width: 100%;
    height: auto;
    min-width: 0;
  }

  .sidebar .brand {
    min-width: 0;
  }

  .sidebar .nav {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    width: calc(100vw - 24px);
    min-width: 0;
    padding-bottom: 3px;
    overflow-x: auto;
  }

  .sidebar .nav-button {
    flex: 0 0 auto;
  }

  .sidebar .theme-control {
    grid-column: 1 / -1;
    grid-row: 3;
    width: min(180px, 100%);
  }

  .sidebar .user-panel {
    grid-column: 2;
    grid-row: 1;
    width: min(180px, 42vw);
    margin: 0;
    padding: 0;
    border: 0;
  }

  .content {
    width: 100%;
    padding: 20px;
  }
}

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

  .sidebar .user-panel,
  .sidebar .theme-control {
    grid-column: 1;
    width: 100%;
  }

  .sidebar .user-panel {
    grid-row: 4;
  }

  .content {
    padding: 16px;
  }
}
