:root {
  --primary: #f04b23;
  --secondary: #002677;
  --ink: #07143f;
  --muted: #5a668a;
  --line: #dfe5f0;
  --panel: #ffffff;
  --soft: #f6f8fc;
  --green: #088a29;
  --blue: #1267e8;
  --purple: #7552e8;
  --cyan: #0f9db5;
  --amber: #d58600;
  --danger: #b42318;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--soft);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

a {
  color: var(--blue);
}

.app-shell {
  min-height: 100vh;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(320px, 460px) 1fr;
  background: #fff;
}

.login-panel {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  border-right: 1px solid var(--line);
  padding: 48px;
}

.login-visual {
  display: grid;
  place-items: center;
  padding: 44px;
  background: linear-gradient(135deg, #ffffff 0%, #f5f9ff 54%, #fff4ef 100%);
}

.login-visual img {
  width: min(760px, 92%);
  height: auto;
  filter: drop-shadow(0 20px 48px rgba(7, 20, 63, 0.12));
}

.brand-logo {
  width: 130px;
  height: auto;
}

.login-title {
  margin: 0;
  color: var(--secondary);
  font-size: 32px;
  line-height: 1.1;
}

.login-subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.login-form,
.stack {
  display: grid;
  gap: 14px;
}

.hint-box {
  display: grid;
  gap: 6px;
  border: 1px solid #ffd3c5;
  border-radius: 8px;
  padding: 12px;
  background: #fff7f3;
  color: #7a2c18;
  font-size: 13px;
}

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

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

.field input,
.field select,
.field textarea,
.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(18, 103, 232, 0.14);
}

.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--secondary);
  padding: 9px 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.btn.secondary {
  border-color: #d3dcf8;
  background: #eef4ff;
  color: var(--blue);
}

.btn.danger {
  border-color: #ffd1cb;
  background: #fff2f0;
  color: var(--danger);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.icon {
  width: 38px;
  min-height: 38px;
  padding: 0;
}

.layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 28px 22px;
}

.side-logo {
  width: 118px;
  height: auto;
}

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

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--secondary);
  padding: 12px;
  text-align: left;
  font-weight: 800;
}

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

.nav .nav-icon,
.icon-box {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #eef4ff;
  color: var(--blue);
  font-weight: 900;
}

.nav button.active .nav-icon {
  background: var(--primary);
  color: #fff;
}

.side-help {
  margin-top: auto;
  border: 1px solid #ffd3c5;
  border-radius: 8px;
  padding: 16px;
  background: #fff7f3;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  padding: 18px 30px;
  backdrop-filter: blur(10px);
}

.judge-shell .topbar {
  position: relative;
}

.page-title {
  margin: 0;
  color: var(--secondary);
  font-size: 26px;
  line-height: 1.2;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.top-actions,
.user-chip,
.row-actions,
.toolbar,
.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.avatar {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #eef4ff;
  color: var(--secondary);
  font-weight: 900;
}

.content {
  display: grid;
  gap: 18px;
  padding: 26px 30px 40px;
}

.panel,
.stat-card,
.table-shell,
.form-shell,
.summary-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(7, 20, 63, 0.05);
}

.panel,
.form-shell,
.summary-panel {
  padding: 18px;
}

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

.panel-title {
  margin: 0;
  color: var(--secondary);
  font-size: 18px;
}

.panel-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 14px;
}

.stat-card {
  display: grid;
  gap: 10px;
  min-height: 118px;
  padding: 16px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat-value {
  color: var(--secondary);
  font-size: 28px;
  font-weight: 900;
}

.stat-note {
  color: var(--muted);
  font-size: 12px;
}

.kpi-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #eef4ff;
  color: var(--blue);
  font-weight: 900;
}

.kpi-icon.orange {
  background: #fff4ef;
  color: var(--primary);
}

.kpi-icon.green {
  background: #eaf8ee;
  color: var(--green);
}

.kpi-icon.purple {
  background: #f1edff;
  color: var(--purple);
}

.table-shell {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 850px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--secondary);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  color: #172653;
}

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

.title-cell {
  min-width: 240px;
}

.title-cell strong,
.title-cell span {
  display: block;
}

.title-cell span {
  margin-top: 4px;
}

td.row-actions {
  display: table-cell;
  white-space: nowrap;
}

td.row-actions .btn + .btn {
  margin-left: 8px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 10px;
  background: #eef4ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.badge.green {
  background: #e8f7ed;
  color: var(--green);
}

.badge.gray {
  background: #f0f2f6;
  color: var(--muted);
}

.badge.orange {
  background: #fff1e6;
  color: #a94d00;
}

.badge.purple {
  background: #f1edff;
  color: var(--purple);
}

.badge.red {
  background: #fff2f0;
  color: var(--danger);
}

.progress {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  min-width: 126px;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e6ebf3;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(56px, 1fr));
  gap: 12px;
  align-items: end;
  min-height: 210px;
}

.bar-column {
  display: grid;
  gap: 8px;
  align-items: end;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.bar-column strong {
  color: var(--secondary);
}

.bar-v {
  width: 100%;
  min-height: 8px;
  border-radius: 8px 8px 0 0;
  background: var(--primary);
}

.list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

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

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

.form-grid.compact .field {
  grid-column: span 2;
}

.form-grid.compact .field.wide {
  grid-column: span 3;
}

.form-grid .wide {
  grid-column: span 2;
}

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

.switches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.check-row.emphasis {
  border-color: #ffd3c5;
  background: #fff7f3;
  color: var(--secondary);
  font-weight: 800;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

input[type="color"] {
  height: 40px;
  padding: 4px;
}

.settings-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.settings-status-card {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px 16px;
}

.settings-status-card strong {
  color: var(--secondary);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(440px, 0.98fr);
  gap: 16px;
  align-items: start;
}

.settings-card {
  display: grid;
  gap: 16px;
}

.settings-section {
  display: grid;
  gap: 12px;
}

.settings-section h3 {
  margin: 0;
  color: var(--secondary);
  font-size: 14px;
}

.switches.polished {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.switches.polished .check-row {
  min-height: 48px;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.splash-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: stretch;
}

.splash-preview {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.splash-preview.color {
  background: var(--preview-bg, #fff);
}

.preview-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}

.preview-topline strong {
  color: var(--secondary);
}

.preview-stage {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
}

.preview-stage img {
  width: min(220px, 100%);
  height: auto;
}

.preview-stage p {
  margin: 0;
  color: var(--secondary);
  font-weight: 900;
}

.judge-shell {
  min-height: 100vh;
}

.judge-main {
  display: grid;
  gap: 20px;
}

.hero-strip {
  display: grid;
  grid-template-columns: 1.8fr repeat(4, minmax(140px, 1fr));
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.hero-item {
  display: grid;
  gap: 6px;
  border-left: 1px solid var(--line);
  padding-left: 20px;
}

.hero-item:first-child {
  border-left: 0;
  padding-left: 0;
}

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

.criteria-list {
  display: grid;
  gap: 12px;
}

.criterion-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) minmax(240px, 1fr) minmax(260px, 1.2fr);
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.criterion-title {
  display: flex;
  gap: 10px;
}

.criterion-index {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.score-control {
  display: grid;
  grid-template-columns: 40px 70px 40px;
  gap: 8px;
  align-items: center;
}

.range-wrap {
  grid-column: 1 / -1;
  display: grid;
  gap: 4px;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.score-number {
  text-align: center;
  font-size: 18px;
  font-weight: 900;
}

.ai-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 40;
  width: min(720px, 100vw);
  overflow: auto;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: -18px 0 40px rgba(7, 20, 63, 0.18);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(7, 20, 63, 0.18);
}

.drawer-body {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 12px 14px;
  font-weight: 900;
}

.tabs button.active {
  border-color: var(--purple);
  color: var(--purple);
}

.suggestion {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.suggestion strong {
  color: var(--secondary);
}

.chat-log {
  display: grid;
  max-height: 320px;
  gap: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f9fbff;
}

.chat-msg {
  max-width: 82%;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

.chat-msg.user {
  justify-self: end;
  background: #eef4ff;
}

.splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #fff;
}

.splash-overlay.color {
  background: var(--splash-bg, #fff);
}

.splash-content {
  display: grid;
  justify-items: center;
  gap: 22px;
  padding: 24px;
  text-align: center;
}

.splash-content img {
  width: min(760px, 88vw);
  height: auto;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.025);
  }
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}

.dot.ok {
  background: var(--green);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 110;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(7, 20, 63, 0.18);
  color: var(--secondary);
  padding: 12px 14px;
  font-weight: 800;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .stats-grid,
  .grid.four {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .score-layout,
  .grid.two,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .hero-strip {
    grid-template-columns: 1fr 1fr;
  }

  .hero-item {
    border-left: 0;
    padding-left: 0;
  }
}

@media (max-width: 860px) {
  .login-screen,
  .layout {
    grid-template-columns: 1fr;
  }

  .login-panel {
    min-height: auto;
    border-right: 0;
    padding: 28px;
  }

  .login-visual {
    display: none;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

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

  .side-help {
    display: none;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .content {
    padding: 18px;
  }

  .stats-grid,
  .grid.three,
  .grid.four,
  .form-grid,
  .form-grid.compact,
  .switches,
  .settings-status,
  .switches.polished,
  .splash-editor {
    grid-template-columns: 1fr;
  }

  .form-grid .wide,
  .form-grid .full,
  .form-grid.compact .field,
  .form-grid.compact .field.wide {
    grid-column: auto;
  }

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

  .hero-strip {
    grid-template-columns: 1fr;
  }
}
