@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --brand: #0dbf6f;
  --brand-dark: #09965a;
  --ink: #0b1f17;
  --ink-soft: #3d5249;
  --surface: #f3f7f4;
  --white: #ffffff;
  --warn: #e07b00;
  --danger: #d64045;
  --shadow: 0 18px 50px rgba(11, 31, 23, 0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--surface);
  color: var(--ink);
  min-height: 100vh;
}

h1, h2, .brand {
  font-family: 'Syne', sans-serif;
  letter-spacing: -0.03em;
}

#app {
  min-height: 100vh;
}

.screen {
  display: none;
  min-height: 100vh;
}

.screen.active { display: grid; }

/* --- Login --- */
#login-screen {
  place-items: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(13, 191, 111, 0.18), transparent 60%),
    linear-gradient(165deg, #e8f5ee 0%, #f3f7f4 45%, #dceee4 100%);
}

.login-card {
  width: min(420px, 92vw);
  background: var(--white);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
}

.brand {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--brand);
  margin-bottom: 0.25rem;
}

.login-card p {
  color: var(--ink-soft);
  margin-bottom: 1.75rem;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--ink-soft);
}

input, select {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1.5px solid #d5e3db;
  border-radius: 10px;
  font: inherit;
  margin-bottom: 1rem;
  background: #fafcfb;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.8rem 1.2rem;
  border: none;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--brand);
  color: white;
  width: 100%;
}

.btn-primary:hover { background: var(--brand-dark); }

.btn-secondary {
  background: #e8f2ec;
  color: var(--ink);
}

.btn-danger { background: var(--danger); color: white; }

.hint {
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* --- App layout --- */
#app-screen {
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  background: var(--ink);
  color: white;
}

.topbar .brand { font-size: 1.5rem; color: var(--brand); }

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
}

.role-badge {
  background: rgba(13, 191, 111, 0.2);
  color: var(--brand);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
}

.main-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: calc(100vh - 56px);
}

.panel {
  background: var(--white);
  border-right: 1px solid #dde8e2;
  padding: 1.25rem;
  overflow-y: auto;
}

.panel h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.panel section + section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e8f0eb;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 400px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.stat {
  background: var(--surface);
  border-radius: 12px;
  padding: 0.9rem;
}

.stat strong {
  display: block;
  font-family: 'Syne', sans-serif;
  font-size: 1.6rem;
  color: var(--brand);
}

.stat span {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.trip-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.trip-card strong { display: block; margin-bottom: 0.35rem; }

.trip-status {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: #dff5ea;
  color: var(--brand-dark);
  margin-bottom: 0.5rem;
}

.trip-card .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.trip-card .btn { font-size: 0.8rem; padding: 0.55rem 0.8rem; }

.log {
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.5;
  max-height: 140px;
  overflow-y: auto;
  background: #f7faf8;
  border-radius: 8px;
  padding: 0.75rem;
}

.subsection-title {
  font-size: 0.92rem;
  margin: 1rem 0 0.5rem;
  color: var(--ink-soft);
}

.muted {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.alert-list {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.alert {
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 500;
}

.alert-warning {
  background: #fff4e8;
  color: #9a5b00;
}

.alert-critical {
  background: #fdebec;
  color: #9f1f24;
}

.alert-ok {
  font-size: 0.82rem;
  color: var(--brand-dark);
  margin-bottom: 0.5rem;
}

.series-chart {
  background: var(--surface);
  border-radius: 12px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.series-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  min-height: 110px;
}

.series-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  min-width: 0;
}

.series-bar-fill {
  width: 100%;
  max-width: 18px;
  background: linear-gradient(180deg, #3ad98f 0%, var(--brand) 100%);
  border-radius: 4px 4px 2px 2px;
}

.series-bar span {
  font-size: 0.62rem;
  color: var(--ink-soft);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid #e3ece7;
}

.data-table th {
  color: var(--ink-soft);
  font-weight: 600;
}

.trip-offer-meta {
  display: grid;
  gap: 0.2rem;
  margin: 0.5rem 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.offer-timer {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--warn);
  margin-bottom: 0.35rem;
}

.offer-timer-urgent {
  color: var(--danger);
}

.btn-sos {
  background: var(--danger);
  color: #fff;
  border: none;
  font-weight: 700;
}

.btn-sos:hover {
  filter: brightness(0.95);
}

.emergency-list {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.push-list {
  margin-bottom: 0.75rem;
}

.push-status {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.push-sent,
.push-simulated {
  background: #e8f7ee;
  color: #1f6b3f;
}

.push-failed,
.push-skipped {
  background: #fff0f0;
  color: #9b1c1c;
}

.push-pending {
  background: #eef2ff;
  color: #3730a3;
}

.emergency-card {
  background: #fff5f5;
  border: 1px solid #f3c6c8;
  border-radius: 12px;
  padding: 0.8rem;
  font-size: 0.82rem;
}

.emergency-card strong {
  display: block;
  margin-bottom: 0.25rem;
  color: #8f1d22;
}

.trip-quote {
  display: grid;
  gap: 0.2rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--surface);
  border-radius: 12px;
  font-size: 0.82rem;
}

.trip-quote strong {
  font-family: 'Syne', sans-serif;
  font-size: 1.2rem;
  color: var(--brand);
}

.surge-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #9a5b00;
  background: #fff4e8;
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
}

.negotiation-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 0.5rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.negotiation-box {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.35rem;
}

.negotiation-box input {
  flex: 1;
  min-width: 0;
}

.counter-offers {
  margin-top: 0.75rem;
}

.hidden { display: none !important; }

@media (max-width: 800px) {
  .main-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .panel { border-right: none; border-bottom: 1px solid #dde8e2; max-height: 45vh; }
}
