:root {
  --bg: #f3f3f3;
  --card: #ffffff;
  --text: #1f1f1f;
  --muted: #555;
  --primary: #005a9c;
  --good: #166534;
  --bad: #991b1b;
  --border: #d0d0d0;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Cairo", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  width: min(920px, 92%);
  margin: 2rem auto 3rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem;
  box-shadow: var(--shadow);
}

.header-card {
  padding-top: 0.7rem;
  padding-bottom: 0.6rem;
}

h1,
h2 {
  margin: 0;
}

.home-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.17rem;
}

.home-link:hover {
  text-decoration: none;
}

.brand-icon {
  width: 45px;
  height: 45px;
  object-fit: contain;
}

.header-card p {
  margin:-1rem 0 0;
  color: var(--muted);
}

.scope-box {
  margin-top: 0.35rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid #b9d6ef;
  background: #eef7ff;
  color: #1f4d7a;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 700;
}

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

.city-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

label {
  display: grid;
  gap: 0.15rem;
  font-weight: 700;
  color: #222;
}

.small-field-label span {
  font-size: 0.86rem;
}

select,
input,
button {
  font: inherit;
}

textarea {
  font: inherit;
}

select,
input {
  width: 100%;
  border: 1px solid #bcbcbc;
  background: #fff;
  border-radius: 4px;
  padding: 0.2rem 0.72rem;
  font-size: 0.9rem;
  min-height: 38px;
  color: var(--text);
}

textarea {
  width: 100%;
  border: 1px solid #bcbcbc;
  background: #fff;
  border-radius: 4px;
  padding: 0.55rem 0.72rem;
  font-size: 0.9rem;
  min-height: 110px;
  color: var(--text);
  resize: vertical;
}

select:focus,
input:focus,
textarea:focus {
  outline: 1px solid #7aa7cc;
  border-color: #2f6e9e;
}

.hint {
  margin: 0.8rem 0;
  font-size: 0.95rem;
  color: var(--muted);
}

#sourceNotice {
  color: #b00020;
  font-weight: 700;
}

#cabinNotice {
  color: #7a5600;
  font-weight: 700;
}

.warning-note {
  margin: 0.8rem 0;
  padding: 0.6rem 0.7rem;
  border: 1px solid #f1cc7a;
  background: #fff9e8;
  color: #7a5600;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.9rem;
}

button {
  border: 1px solid #00497d;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  width: 200px;
  padding: 0.4rem 0;
  cursor: pointer;
}

button:hover {
  background: #004b82;
}

.submit-row {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.light-btn {
  width: auto;
  padding: 0.4rem 0.9rem;
  background: #fff;
  color: #00497d;
}

.light-btn:hover {
  background: #f2f8ff;
}

.quick-verdict {
  width: auto;
  flex: 1;
  min-height: 38px;
  border-radius: 4px;
  border: 1px solid #b7dfbf;
  background: #eef9f0;
  color: #166534;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.5rem;
  text-align: center;
  white-space: nowrap;
  overflow-x: auto;
}

.quick-verdict.bad {
  border-color: #e1b3b3;
  background: #fff1f1;
  color: #991b1b;
}

.quick-verdict.neutral {
  border-color: #c9d5e3;
  background: #f5f8fc;
  color: #334155;
}

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


.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.formula-box {
  margin-top: 0.7rem;
  padding: 0.6rem 0.7rem;
  border: 1px dashed #b8c6d6;
  border-radius: 6px;
  background: #fafcff;
  font-size: 0.88rem;
  line-height: 1.6;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.72rem;
  background: #fff;
}

.stat.best {
  border-color: #8ec5a0;
  background: #f3fbf5;
}

.stat .label {
  color: var(--muted);
  font-size: 0.94rem;
}

.stat .value {
  margin-top: 0.2rem;
  font-size: 1.05rem;
  font-weight: 800;
}

.verdict {
  margin-top: 1rem;
  border-radius: 6px;
  padding: 0.8rem;
  font-weight: 700;
}

.verdict.good {
  background: #eef9f0;
  color: var(--good);
  border: 1px solid #b7dfbf;
}

.verdict.bad {
  background: #fff1f1;
  color: var(--bad);
  border: 1px solid #e1b3b3;
}

.management-card {
  display: grid;
  gap: 0.9rem;
}

.auth-card {
  max-width: 420px;
  margin-inline: auto;
}

.management-intro {
  margin: 0;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 0.8rem;
}

.management-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  align-items: end;
}

.management-actions {
  display: flex;
  align-items: end;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  align-items: end;
}

.source-list {
  display: grid;
  gap: 0.55rem;
}

.source-row,
.route-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafcff;
}

.source-details {
  display: grid;
  gap: 0.2rem;
}

.source-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.source-tag {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 0.7rem;
  border-radius: 999px;
  background: #eef7ff;
  color: #1f4d7a;
  font-size: 0.86rem;
  font-weight: 700;
}

.panel-head,
.inline-actions,
.row-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.danger-btn {
  border-color: #b42318;
  color: #b42318;
}

.danger-btn:hover {
  background: #fff1f1;
}

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

  button {
    width: 100%;
  }

  .light-btn {
    width: 100%;
  }

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

  .quick-verdict {
    width: 100%;
  }

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

  .container {
    margin-top: 1rem;
  }

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

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

  .source-row,
  .route-row {
    align-items: start;
    flex-direction: column;
  }
}
