:root {
  --bg-1: #07121f;
  --bg-2: #0f2036;
  --card: #13253f;
  --line: #234367;
  --text: #e9f2ff;
  --muted: #a5bdda;
  --ok: #3ecf8e;
  --warn: #f7b955;
  --err: #ff6b6b;
  --action: #58d3f7;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  background:
    radial-gradient(1000px 600px at 5% -10%, #1b3f69 0%, transparent 60%),
    radial-gradient(900px 700px at 110% 0%, #12345a 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  font-family: "Segoe UI", "Noto Sans", sans-serif;
}

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 16px 56px;
}

.page-wide {
  max-width: min(1760px, 98vw);
}

.page-narrow {
  max-width: 520px;
  min-height: 100vh;
  display: flex;
  align-items: center;
}

.hero h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 0.2px;
}

.hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(165, 189, 218, 0.25);
  border-radius: 999px;
  background: rgba(7, 20, 34, 0.6);
  color: #d9ebff;
  font-size: 13px;
  font-weight: 600;
}

.hero p {
  margin: 10px 0 24px;
  color: var(--muted);
}

.card {
  background: linear-gradient(180deg, rgba(19, 37, 63, 0.96), rgba(14, 30, 53, 0.92));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.25);
}

.label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

input[type="file"],
input[type="password"],
input[type="text"] {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0d1d33;
  color: var(--text);
  padding: 10px 12px;
}

.hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

button {
  margin-top: 14px;
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  background: linear-gradient(90deg, #43b8ff, var(--action));
  color: #072132;
  font-weight: 700;
  cursor: pointer;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.form-actions button {
  margin-top: 0;
}

.button-secondary {
  margin-top: 0;
  background: rgba(165, 189, 218, 0.12);
  color: #dcecff;
  border: 1px solid rgba(165, 189, 218, 0.26);
}

.button-danger {
  margin-top: 0;
  background: linear-gradient(180deg, rgba(255, 107, 107, 0.92), rgba(219, 67, 67, 0.92));
  color: #fff3f3;
  border: 1px solid rgba(255, 140, 140, 0.55);
}

.button-danger:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(255, 122, 122, 0.96), rgba(228, 77, 77, 0.96));
}

.mistakes-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 14px;
}

.button-export {
  margin-top: 0;
  min-height: 46px;
  padding: 12px 24px;
  border-radius: 12px;
  border: 1px solid rgba(40, 190, 88, 0.95);
  background: linear-gradient(180deg, #55e786 0%, #2bc05c 100%);
  color: #042010;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
  box-shadow: 0 10px 22px rgba(43, 192, 92, 0.32);
}

.button-export:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(43, 192, 92, 0.4);
}

.export-status {
  flex: 1 1 320px;
  min-height: 18px;
  color: #c6d9ef;
  font-size: 13px;
  line-height: 1.35;
}

button:disabled {
  opacity: 0.65;
  cursor: default;
}

.status {
  margin-top: 14px;
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(7, 18, 31, 0.7);
}

.status.running {
  border-color: #3a7fc5;
  color: #cde9ff;
}

.status.ok {
  border-color: rgba(62, 207, 142, 0.6);
  color: #b9f5d8;
}

.status.error {
  border-color: rgba(255, 107, 107, 0.7);
  color: #ffd0d0;
}

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

.login-title {
  margin: 0 0 6px;
  font-size: 28px;
}

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

.run-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-family: Consolas, "Courier New", monospace;
  min-height: 18px;
}

#result-content {
  color: var(--muted);
  line-height: 1.45;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.metric {
  border: 1px solid rgba(165, 189, 218, 0.22);
  border-radius: 10px;
  background: rgba(7, 20, 34, 0.55);
  padding: 10px 12px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.metric-value {
  color: #e8f3ff;
  font-size: 19px;
  font-weight: 700;
}

.metric-negative {
  color: #ffd0d0;
}

.links {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.links a {
  color: var(--action);
  text-decoration: none;
}

.links a:hover {
  text-decoration: underline;
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 13px;
}

.table th,
.table td {
  border-bottom: 1px solid rgba(165, 189, 218, 0.18);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}

.table th {
  color: #d6e8ff;
  font-weight: 700;
}

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

.table-errors th,
.table-errors td {
  white-space: normal;
  word-break: break-word;
}

.filters-empty {
  color: var(--muted) !important;
  text-align: center !important;
  font-style: italic;
}

.th-sort-btn {
  margin: 0;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(88, 211, 247, 0.35);
  background: rgba(88, 211, 247, 0.08);
  color: #dff6ff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.1;
}

.th-sort-btn:hover {
  color: #ffffff;
  border-color: rgba(88, 211, 247, 0.75);
  background: rgba(88, 211, 247, 0.18);
}

.th-sort-btn.active {
  border-color: rgba(88, 211, 247, 0.95);
  background: rgba(88, 211, 247, 0.24);
}

.sort-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(88, 211, 247, 0.55);
  background: rgba(9, 26, 45, 0.65);
  color: #9de6ff;
  font-size: 13px;
  font-weight: 900;
}

.mistakes-table th,
.mistakes-table td {
  vertical-align: top;
}

.mistakes-table td {
  padding-top: 7px;
  padding-bottom: 7px;
}

.cards-inline {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: max-content;
}

.action-pill {
  display: inline-block;
  min-width: 56px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: lowercase;
}

.action-hero {
  color: #ffd3d3;
  background: rgba(255, 107, 107, 0.15);
  border: 1px solid rgba(255, 107, 107, 0.7);
}

.action-solver {
  color: #c9f8df;
  background: rgba(62, 207, 142, 0.14);
  border: 1px solid rgba(62, 207, 142, 0.7);
}

.ev-loss-cell {
  color: #ffd0d0 !important;
  font-weight: 700;
}

.row-remove-btn {
  margin: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid rgba(255, 122, 122, 0.55);
  background: rgba(255, 107, 107, 0.14);
  color: #ffd2d2;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.row-remove-btn:hover:not(:disabled) {
  background: rgba(255, 107, 107, 0.24);
}

.mistake-meta-cell {
  min-width: 240px;
  white-space: normal !important;
  color: var(--muted) !important;
}

.mistake-meta-cell .meta-line {
  font-size: 11px;
  line-height: 1.25;
  margin: 0 0 2px;
}

.mistakes-table tbody tr:hover {
  background: rgba(96, 186, 255, 0.06);
}

.cards-empty {
  color: var(--muted);
  font-size: 12px;
}

.card-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 46px;
  border: 1px solid rgba(185, 198, 219, 0.8);
  border-radius: 7px;
  background: linear-gradient(180deg, #fbfdff, #f0f5fc);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px) scale(0.94);
  animation: card-deal-in 320ms ease-out forwards;
  animation-delay: var(--deal-delay, 0ms);
}

.card-chip-mini {
  width: 24px;
  height: 32px;
  border-radius: 5px;
}

.card-chip-mini .card-rank {
  font-size: 14px;
}

.card-chip-invalid {
  color: #6b7d95;
  font-weight: 500;
  width: auto;
  min-width: 34px;
  padding: 0 7px;
}

.card-rank {
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0.3px;
}

.card-chip.suit-h .card-rank {
  color: #df3348;
}

.card-chip.suit-s .card-rank {
  color: #1e2732;
}

.card-chip.suit-c .card-rank {
  color: #1f9a5e;
}

.card-chip.suit-d .card-rank {
  color: #2f6cff;
}

.card-chip:hover {
  transform: translateY(-2px) scale(1.02);
  transition: transform 120ms ease-out;
}

@keyframes card-deal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
