:root {
  color-scheme: light;
  --bg: #e7eef7;
  --surface: #ffffff;
  --surface-soft: #071426;
  --text: #0c1b2f;
  --muted: #52647c;
  --line: #d1ddea;
  --line-strong: #aebfd2;
  --primary: #1f6fff;
  --primary-dark: #164fb8;
  --primary-soft: #e6f0ff;
  --navy: #020817;
  --navy-2: #06172b;
  --blue-ink: #0b3b87;
  --good: #07805d;
  --warn: #b86b00;
  --bad: #c83232;
  --na: #526174;
  --shadow: 0 18px 42px rgba(5, 17, 34, 0.13);
  --section-shadow: 0 24px 54px rgba(5, 17, 34, 0.17);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(5, 22, 45, 0.1) 0, rgba(5, 22, 45, 0) 320px),
    linear-gradient(180deg, #dce8f6 0, var(--bg) 340px);
  color: var(--text);
  font-family: Arial, "Malgun Gothic", sans-serif;
  line-height: 1.45;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 98px;
  padding: 22px 38px;
  background:
    linear-gradient(135deg, rgba(31, 111, 255, 0.18) 0%, rgba(31, 111, 255, 0) 42%),
    linear-gradient(135deg, #020817 0%, #06172b 50%, #0b2b55 100%);
  border-bottom: 1px solid rgba(160, 195, 255, 0.2);
  box-shadow: 0 20px 48px rgba(2, 8, 23, 0.38);
}

.brand,
.save-state,
.panel-header,
.actions,
.form-actions,
.row-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0d5cff 0%, #41a4ff 58%, #a8d8ff 100%);
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 14px 28px rgba(31, 111, 255, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  color: #ffffff;
  font-size: 28px;
  line-height: 1.25;
}

.brand p {
  margin-top: 5px;
  color: #c8dcf8;
  font-size: 14px;
}

.toolbar p,
.panel-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.save-state {
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid rgba(190, 210, 232, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #d6e4f5;
  font-size: 14px;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2ee6a6;
  box-shadow: 0 0 0 5px rgba(46, 230, 166, 0.14);
}

.layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: calc(100vh - 98px);
}

.sidebar {
  padding: 30px 20px;
  background:
    linear-gradient(180deg, rgba(31, 111, 255, 0.12) 0%, rgba(31, 111, 255, 0) 36%),
    linear-gradient(180deg, #020817 0%, #071426 100%);
  border-right: 1px solid rgba(160, 195, 255, 0.14);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04), 16px 0 34px rgba(5, 17, 34, 0.1);
}

.nav-item {
  width: 100%;
  margin-bottom: 10px;
  padding: 14px 15px;
  border: 1px solid rgba(191, 209, 232, 0.1);
  border-radius: 8px;
  background: transparent;
  color: #b9cbe4;
  text-align: left;
  cursor: pointer;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  background: linear-gradient(135deg, rgba(31, 111, 255, 0.28), rgba(65, 164, 255, 0.12));
  border-color: rgba(114, 183, 255, 0.55);
  color: #ffffff;
  box-shadow: inset 4px 0 0 #41a4ff, 0 14px 24px rgba(0, 0, 0, 0.22);
}

.workspace {
  width: 100%;
  max-width: none;
  padding: 36px 50px 56px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: -36px -50px 30px;
  padding: 20px 50px;
  background: rgba(232, 240, 249, 0.9);
  border-bottom: 1px solid rgba(143, 173, 208, 0.7);
  box-shadow: 0 16px 34px rgba(5, 17, 34, 0.14);
  backdrop-filter: blur(14px);
}

.toolbar h2 {
  color: #071426;
  font-size: 32px;
  line-height: 1.2;
}

.actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.primary-action,
.secondary-action {
  border-radius: 8px;
  min-height: 42px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 800;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.primary-action {
  border: 0;
  background: linear-gradient(135deg, #0d5cff 0%, #1f6fff 55%, #41a4ff 100%);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(31, 111, 255, 0.34);
}

.primary-action:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.secondary-action {
  border: 1px solid #b8cbe0;
  background: linear-gradient(180deg, #ffffff 0%, #f6faff 100%);
  color: #102a47;
  box-shadow: 0 1px 0 rgba(9, 24, 45, 0.04);
}

.secondary-action:hover {
  border-color: #1f6fff;
  background: #edf5ff;
}

.danger-action {
  border-color: #f4b5b0;
  color: var(--bad);
}

.danger-action:hover {
  border-color: var(--bad);
  background: #fff7f6;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 28px;
}

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  position: relative;
  min-height: 158px;
  padding: 28px 28px 25px;
  border-color: #b9cde4;
  background:
    linear-gradient(135deg, rgba(31, 111, 255, 0.08) 0%, rgba(31, 111, 255, 0) 48%),
    #ffffff;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, #0d5cff, #41a4ff);
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -42px;
  top: -42px;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: rgba(31, 111, 255, 0.08);
}

.metric-card span {
  display: block;
  color: #425773;
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  color: #06172b;
  font-size: 40px;
  line-height: 1.2;
}

.metric-card em {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
}

.panel {
  margin-bottom: 28px;
  padding: 24px;
  border-color: #b9cde4;
  box-shadow: var(--section-shadow);
}

.panel-header {
  justify-content: space-between;
  gap: 16px;
  margin: -24px -24px 22px;
  padding: 19px 24px 17px;
  border-bottom: 1px solid #c8d8e9;
  background:
    linear-gradient(90deg, rgba(31, 111, 255, 0.12), rgba(31, 111, 255, 0) 42%),
    linear-gradient(180deg, #f8fbff 0%, #edf5ff 100%);
  border-radius: 8px 8px 0 0;
}

.panel-header h3 {
  color: #071426;
  font-size: 18px;
  line-height: 1.25;
}

.settings-panel {
  display: block;
  margin-bottom: 16px;
  border: 1px solid #b9cde4;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(9, 24, 45, 0.06);
  overflow: hidden;
}

.settings-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 13px 16px;
  background:
    linear-gradient(90deg, rgba(31, 111, 255, 0.12), rgba(31, 111, 255, 0) 48%),
    #f5f9ff;
  color: #071426;
  cursor: pointer;
  font-size: 15px;
  font-weight: 900;
  list-style: none;
}

.settings-panel > summary::-webkit-details-marker {
  display: none;
}

.settings-panel > summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e6f0ff;
  color: #0f4bb8;
  font-weight: 900;
}

.settings-panel[open] > summary {
  border-bottom: 1px solid #d3dfeb;
}

.settings-panel[open] > summary::after {
  content: "-";
}

.settings-panel > .stock-form,
.settings-panel > .csv-import-header,
.settings-panel > .field,
.settings-panel > .csv-preview-status,
.settings-panel > .table-wrap,
.settings-panel > .score-list,
.settings-panel > .source-list,
.settings-panel > .settings-actions {
  margin: 16px;
}

.settings-panel .panel-header {
  margin: 16px 16px 0;
  padding: 0 0 14px;
  border-bottom: 1px solid #d3dfeb;
  border-radius: 0;
  background: transparent;
}

.settings-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #adc2da;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

table {
  width: 100%;
  min-width: 1780px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

th,
td {
  padding: 15px 17px;
  border-bottom: 1px solid #dce6f1;
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
  word-break: keep-all;
  overflow-wrap: normal;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #eff6ff;
  background: linear-gradient(180deg, #102a47 0%, #07182d 100%);
  font-weight: 800;
  white-space: nowrap;
}

th[data-sort-key] {
  cursor: pointer;
  user-select: none;
}

th[data-sort-key]:hover,
th.sorted {
  background: linear-gradient(180deg, #16416f 0%, #09213d 100%);
  color: #ffffff;
}

th:nth-child(1),
td:nth-child(1) {
  width: 210px;
  min-width: 210px;
}

th:nth-child(12),
td:nth-child(12) {
  width: 300px;
  min-width: 300px;
}

td:nth-child(12) {
  white-space: normal;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: break-word;
}

tbody tr {
  background: #ffffff;
}

tbody tr:nth-child(even) {
  background: #f1f6fc;
}

tbody tr:hover {
  background: #e5f0ff;
}

tbody tr.selected-row {
  background: #dbeafe;
  box-shadow: inset 4px 0 0 #1f6fff;
}

tr:last-child td {
  border-bottom: 0;
}

.cell-title {
  display: block;
  font-weight: 800;
  color: #0d2747;
  word-break: keep-all;
  overflow-wrap: normal;
}

.cell-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  word-break: keep-all;
}

.numeric-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty-table-cell {
  padding: 28px 18px;
  color: #52647c;
  text-align: center;
  font-weight: 800;
}

.badge {
  display: inline-block;
  min-width: 78px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.badge.complete {
  background: linear-gradient(135deg, #047857, #10a37f);
  border-color: #047857;
  color: #ffffff;
}

.badge.partial {
  background: linear-gradient(135deg, #b76100, #f59e0b);
  border-color: #d97706;
  color: #ffffff;
}

.badge.risk {
  background: linear-gradient(135deg, #b42318, #ef4444);
  border-color: #dc2626;
  color: #ffffff;
}

.badge.na {
  background: linear-gradient(135deg, #475467, #6b7a90);
  border-color: #536174;
  color: #ffffff;
}

.score-list,
.source-list,
.summary-box {
  display: grid;
  gap: 14px;
}

.stock-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(170px, 1fr) minmax(120px, 0.7fr) minmax(160px, 1fr) minmax(170px, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #c8d8e9;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff 0%, #f1f7ff 100%);
}

.csv-import {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
  padding: 18px;
  border: 1px solid #b9cde4;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(31, 111, 255, 0.08), rgba(31, 111, 255, 0) 42%),
    #ffffff;
  box-shadow: 0 10px 22px rgba(9, 24, 45, 0.06);
}

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

.csv-actions {
  flex: 0 0 auto;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  white-space: nowrap;
}

.csv-actions .primary-action,
.csv-actions .secondary-action {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.2;
}

.csv-import h4 {
  margin: 0;
  color: #071426;
  font-size: 16px;
  line-height: 1.25;
}

.csv-import p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.csv-import textarea {
  min-height: 92px;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.45;
}

.settings-panel.csv-import {
  display: block;
  padding: 0;
}

.csv-preview-status {
  padding: 10px 12px;
  border: 1px solid #d3dfeb;
  border-radius: 8px;
  background: #f7fbff;
  color: #425773;
  font-size: 13px;
  font-weight: 800;
}

.csv-preview-wrap {
  max-height: 280px;
}

.csv-preview-table {
  min-width: 760px;
}

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

.csv-invalid-row {
  background: #fff5f5 !important;
}

.form-actions,
.row-actions {
  gap: 8px;
}

.inline-row-actions {
  margin-top: 8px;
  flex-wrap: wrap;
}

.form-actions {
  justify-content: flex-end;
}

.text-action {
  border: 1px solid #b8cbe0;
  border-radius: 8px;
  min-height: 34px;
  padding: 7px 11px;
  background: #ffffff;
  color: #0f4bb8;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.text-action:hover {
  border-color: #1f6fff;
  background: #eaf3ff;
}

.text-action.active {
  border-color: #1f6fff;
  background: #e0edff;
  color: #0b3b87;
}

.text-action.danger {
  color: var(--bad);
}

.text-action.danger:hover {
  border-color: var(--bad);
  background: #fff7f6;
}

.text-action.danger.active {
  border-color: var(--bad);
  background: #fee2e2;
  color: var(--bad);
}

.editor-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(220px, 1fr) minmax(180px, 0.8fr);
  gap: 14px;
  align-items: start;
  padding: 16px;
  border: 1px solid #d3dfeb;
  border-radius: 8px;
  background: #fbfdff;
  box-shadow: 0 6px 16px rgba(9, 24, 45, 0.04);
}

.score-editor-row {
  grid-template-columns: minmax(170px, 0.52fr) minmax(520px, 1.7fr) minmax(160px, 0.55fr);
  gap: 12px;
  padding: 12px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(72px, 1fr)) minmax(66px, 0.7fr);
  gap: 8px;
}

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: #465a73;
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid #b9cde4;
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(9, 24, 45, 0.04);
  color: var(--text);
}

.field textarea {
  min-height: 44px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(29, 95, 209, 0.18);
  outline-offset: 2px;
  border-color: var(--primary);
}

.score-input {
  max-width: none;
  min-height: 34px;
  padding: 7px 8px;
  font-weight: 800;
}

.na-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding-top: 18px;
  color: var(--text);
  font-weight: 800;
}

.summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 15px;
  border: 1px solid #d3dfeb;
  border-radius: 8px;
  background: #fbfdff;
}

.summary-item strong {
  font-size: 19px;
}

.stock-detail-card {
  margin-top: 20px;
  padding: 22px;
  border: 1px solid #adc2da;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(31, 111, 255, 0.08), rgba(31, 111, 255, 0) 44%),
    #ffffff;
  box-shadow: var(--section-shadow);
}

.stock-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid #d3dfeb;
}

.detail-eyebrow {
  display: block;
  color: #1f6fff;
  font-size: 12px;
  font-weight: 900;
}

.stock-detail-card h4,
.stock-detail-card h5,
.stock-detail-card p {
  margin: 0;
}

.stock-detail-card h4 {
  margin-top: 4px;
  color: #071426;
  font-size: 22px;
  line-height: 1.25;
}

.stock-detail-card h5 {
  margin-bottom: 10px;
  color: #102a47;
  font-size: 14px;
}

.stock-detail-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.detail-section,
.detail-opinion {
  padding: 15px;
  border: 1px solid #d3dfeb;
  border-radius: 8px;
  background: #fbfdff;
}

.detail-list {
  display: grid;
  gap: 8px;
}

.detail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #e4edf6;
}

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

.detail-item span {
  color: #52647c;
  font-size: 12px;
  font-weight: 800;
  word-break: keep-all;
}

.detail-item strong {
  color: #071426;
  font-size: 13px;
  text-align: right;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.checklist-section {
  margin-top: 14px;
}

.criteria-checklist {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.check-item {
  display: flex;
  gap: 10px;
  min-height: 74px;
  padding: 12px;
  border: 1px solid #d3dfeb;
  border-radius: 8px;
  background: #ffffff;
}

.check-item.passed {
  border-color: #9ad7c2;
  background: #f0fbf7;
}

.check-item.pending {
  border-color: #f0c4c4;
  background: #fff7f7;
}

.check-dot {
  display: grid;
  flex: 0 0 24px;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #526174;
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
}

.check-item.passed .check-dot {
  background: #047857;
}

.check-item.pending .check-dot {
  background: #dc2626;
}

.check-item strong {
  display: block;
  color: #102a47;
  font-size: 13px;
}

.check-item em {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.detail-opinion {
  margin-top: 14px;
  background: linear-gradient(135deg, #f8fbff, #eef6ff);
}

.detail-opinion p {
  color: #0c1b2f;
  font-size: 15px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: break-word;
}

@media (max-width: 980px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-row {
    grid-template-columns: 1fr;
  }

  .stock-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .csv-import-header {
    flex-direction: column;
  }

  .csv-actions {
    justify-content: flex-start;
  }

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

  .detail-grid,
  .criteria-checklist {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    margin: -20px -20px 22px;
    padding: 16px 20px;
  }

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

  .sidebar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    white-space: nowrap;
  }

  .workspace {
    padding: 20px;
  }

  .toolbar h2 {
    font-size: 25px;
  }

  .actions {
    justify-content: flex-start;
  }

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

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

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

  .metric-card {
    min-height: 120px;
  }

  .stock-detail-header {
    flex-direction: column;
  }

  .detail-grid,
  .criteria-checklist {
    grid-template-columns: 1fr;
  }

  .form-actions {
    justify-content: flex-start;
  }
}
