:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #1a1d23;
  --muted: #5c6573;
  --line: #e2e5ea;
  --line-strong: #cfd4dc;
  --primary: #1f4e8c;
  --primary-hover: #173d6e;
  --primary-soft: #eef3f9;
  --focus: rgba(31, 78, 140, 0.18);
  --red: #9f2b2b;
  --red-soft: #f8eeee;
  --yellow: #8a5a12;
  --yellow-soft: #f8f3e8;
  --green: #1f6b43;
  --green-soft: #eaf5ef;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.04);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 72px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 700;
}

.brand-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-tag {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.lang-toggle {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.lang-option {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
}

.lang-option.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.intro {
  margin: 32px 0 28px;
}

.intro h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.intro p {
  margin: 10px 0 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 0.98rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel,
.results-box,
.mini-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel-header {
  margin-bottom: 12px;
}

.panel-header h2,
.results-header h2,
.mini-panel h4,
.card-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.upload-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 104px;
  margin-bottom: 12px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: #fafbfc;
  cursor: pointer;
}

.upload-dropzone.is-dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.upload-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

.drop-caption {
  margin: 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

input[type='file'] {
  display: none;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 12px 14px;
  font-size: 0.92rem;
  line-height: 1.6;
}

textarea::placeholder {
  color: #8a93a0;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
}

.cta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 28px;
}

.primary-btn,
.secondary-btn {
  border-radius: 8px;
  padding: 0.65rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

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

.primary-btn:hover:not(:disabled) {
  background: var(--primary-hover);
}

.primary-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.secondary-btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
}

.secondary-btn:hover {
  background: #f3f4f6;
}

.results-box {
  padding: 20px;
}

.results-header {
  margin-bottom: 12px;
}

.summary-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
  padding: 14px 16px;
  line-height: 1.65;
  font-size: 0.94rem;
  color: var(--muted);
}

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

.priority-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  min-height: 140px;
}

.red-card {
  background: var(--red-soft);
  border-color: #ebd6d6;
}

.yellow-card {
  background: var(--yellow-soft);
  border-color: #eadfca;
}

.green-card {
  background: var(--green-soft);
  border-color: #d4e7dc;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.card-head span {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
}

.red-card .card-head h3 { color: var(--red); }
.yellow-card .card-head h3 { color: var(--yellow); }
.green-card .card-head h3 { color: var(--green); }

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-card,
.plan-item,
.rank-item,
.empty-state {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.empty-state {
  color: var(--muted);
  font-size: 0.85rem;
}

.result-card strong,
.rank-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.result-card p,
.plan-item p,
.rank-item p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted);
}

.result-card p + p {
  margin-top: 6px;
}

.confidence-pill,
.rank-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
  background: var(--primary-soft);
  color: var(--primary);
}

.pill-red { background: #f4e4e4; color: var(--red); }
.pill-yellow { background: #f3ead8; color: var(--yellow); }
.pill-green { background: #dceee4; color: var(--green); }

.side-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.mini-panel {
  padding: 16px;
}

.mini-panel h4 {
  margin-bottom: 12px;
}

.plan-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.plan-index {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
}

.rank-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.hidden {
  display: none;
}

.loader {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

@media (max-width: 860px) {
  .tool-grid,
  .dashboard-grid,
  .side-panels {
    grid-template-columns: 1fr;
  }
}
