/* ============================================================
   Ajopäiväkirja v1.0 — quiet premium production UI
   Softer dark slate refresh
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #101725;
  --bg-deep: #0c1220;
  --panel: rgba(31, 42, 59, 0.72);
  --panel-strong: rgba(36, 49, 69, 0.86);
  --field: rgba(18, 26, 41, 0.58);
  --line: rgba(196, 210, 232, 0.14);
  --line-strong: rgba(210, 222, 242, 0.24);
  --text: rgba(255,255,255,0.95);
  --muted: rgba(218,228,244,0.66);
  --faint: rgba(218,228,244,0.38);
  --green: #43c979;
  --green-strong: #38b86b;
  --green-soft: #2f8f6f;
  --green-soft-2: #277a68;
  --green-bg: rgba(67,201,121,0.13);
  --green-line: rgba(86,220,143,0.30);
  --amber: #e6b450;
  --amber-bg: rgba(230,180,80,0.14);
  --amber-line: rgba(230,180,80,0.26);
  --red: #e36b72;
  --red-bg: rgba(227,107,114,0.10);
  --red-line: rgba(227,107,114,0.36);
  --radius: 24px;
  --radius-sm: 16px;
  --max-w: 390px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html {
  min-height: 100%;
  background: var(--bg-deep);
}

body {
  min-height: 100vh;
  color: var(--text);
  font-family: inherit;
  background:
    radial-gradient(circle at 50% -12%, rgba(68, 96, 132, 0.34), transparent 38%),
    linear-gradient(180deg, #142033 0%, #101725 42%, #0c1220 100%);
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
.is-disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen-body {
  width: 100%;
  max-width: var(--max-w);
  padding: 28px 21px 46px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.top-bar {
  width: 100%;
  max-width: var(--max-w);
  min-height: 72px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(196, 210, 232, 0.10);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(10, 16, 27, 0.14);
}

.brand-title {
  color: var(--muted);
  font-size: 15px;
  font-weight: 640;
  letter-spacing: -0.015em;
}

.landing-title {
  font-size: 30px;
  font-weight: 760;
  letter-spacing: -0.04em;
}

.brand-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.page-intro {
  padding: 16px 2px 2px;
}

.page-intro h1 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 36px;
  line-height: 1.05;
  font-weight: 780;
  letter-spacing: -0.055em;
}

.page-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.42;
  letter-spacing: -0.02em;
}

.landing-wrap {
  width: 100%;
  max-width: var(--max-w);
  min-height: 100vh;
  padding: 44px 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  text-align: center;
}

.landing-msg {
  min-height: 1.4em;
  color: var(--amber);
  font-size: 14px;
  line-height: 1.45;
}

.app-version {
  position: fixed;
  right: 16px;
  bottom: 12px;
  color: rgba(255,255,255,0.30);
  font-size: 10px;
  letter-spacing: 0.03em;
  pointer-events: none;
}

.btn-pill {
  color: rgba(238,244,255,0.82);
  border: 1px solid rgba(210,222,242,0.18);
  border-radius: 999px;
  background: rgba(31,42,59,0.58);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 620;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.blocked-msg {
  width: 100%;
  max-width: var(--max-w);
  min-height: 0;
  padding: 6px 21px 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.state-strip {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,0.035);
  color: var(--muted);
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 620;
}

.state-strip-amber {
  color: var(--amber);
  background: var(--amber-bg);
  border-color: var(--amber-line);
}

.state-strip-green {
  color: var(--green);
  background: var(--green-bg);
  border-color: var(--green-line);
}

.state-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: currentColor;
  flex: 0 0 auto;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(42, 56, 78, 0.78), rgba(27, 38, 55, 0.76));
  padding: 22px;
  box-shadow:
    0 22px 54px rgba(0,0,0,0.23),
    inset 0 1px 0 rgba(255,255,255,0.04);
}

.card-title {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 720;
  letter-spacing: -0.025em;
}

.field {
  margin-bottom: 17px;
  display: flex;
  flex-direction: column;
}

.field:last-child {
  margin-bottom: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 15px;
}

.field-row .field {
  margin-bottom: 0;
}

.field-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-transform: none;
  letter-spacing: -0.01em;
}

select,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea.comment-field {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--text);
  padding: 0 14px;
  outline: none;
  font-size: 16px;
  font-weight: 540;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
}

textarea.comment-field {
  min-height: 76px;
  padding: 14px;
  resize: none;
  line-height: 1.45;
}

select {
  appearance: none;
}

select option {
  background: #1b2637;
  color: var(--text);
}

input[type="date"],
input[type="time"] {
  color-scheme: dark;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--line-strong);
  background: rgba(18, 26, 41, 0.78);
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  display: none;
}

.uppercase {
  text-transform: uppercase;
}

.mono {
  font-variant-numeric: tabular-nums;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  min-height: 54px;
  width: 100%;
  border-radius: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 16px;
  font-weight: 740;
  letter-spacing: -0.018em;
}

.btn-primary {
  background: linear-gradient(180deg, var(--green) 0%, var(--green-strong) 100%);
  color: #06120b;
  box-shadow:
    0 12px 26px rgba(35, 167, 92, 0.23),
    inset 0 1px 0 rgba(255,255,255,0.18);
}

.btn-secondary {
  border: 1px solid rgba(86,220,143,0.24);
  background: linear-gradient(180deg, rgba(47,143,111,0.92), rgba(39,122,104,0.92));
  color: rgba(255,255,255,0.92);
  box-shadow:
    0 10px 24px rgba(18, 84, 70, 0.18),
    inset 0 1px 0 rgba(255,255,255,0.10);
}

.btn-danger {
  border: 1px solid var(--red-line);
  background: var(--red-bg);
  color: var(--red);
}

.btn-flush,
.btn-calc {
  width: 100%;
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-top: 3px;
}

.notice,
.alert-warn {
  border: 1px solid var(--amber-line);
  border-radius: var(--radius-sm);
  background: var(--amber-bg);
  color: var(--amber);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 15px;
}

.queue-panel {
  margin-bottom: 18px;
}

.queue-title {
  margin-bottom: 12px;
  color: var(--amber);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.driver-badge {
  min-height: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.34; }
}

.recording-card {
  border: 1px solid var(--green-line);
  border-radius: 28px;
  background: var(--green-bg);
  padding: 30px 22px;
  text-align: center;
}

.recording-status {
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 720;
  margin-bottom: 28px;
}

.recording-dot {
  width: 12px;
  height: 12px;
  border-radius: 99px;
  background: currentColor;
  animation: pulse 1.8s ease-in-out infinite;
}

.recording-plate {
  min-height: 39px;
  font-size: 39px;
  line-height: 1;
  font-weight: 760;
  letter-spacing: -0.055em;
  margin-bottom: 8px;
}

.recording-job {
  min-height: 22px;
  color: rgba(255,255,255,0.72);
  font-size: 17px;
  margin-bottom: 28px;
}

.recording-time {
  display: flex;
  justify-content: center;
  gap: 22px;
  color: var(--muted);
  font-size: 14px;
}

.time-label {
  color: var(--muted);
  font-size: 14px;
}

.time-value {
  display: block;
  color: var(--text);
  font-size: 17px;
  font-weight: 670;
  margin-top: 4px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.summary-row {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.summary-row:last-child {
  border-bottom: 0;
}

.summary-row span:first-child {
  color: var(--muted);
}

.summary-row span:last-child {
  font-weight: 640;
  text-align: right;
}

.manual-top-title,
.step-indicator {
  color: var(--muted);
  font-size: 14px;
}

.manual-title {
  width: 100%;
  max-width: var(--max-w);
  padding: 21px 21px 0;
  font-size: 22px;
  font-weight: 720;
  letter-spacing: -0.035em;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(3,4,10,0.72);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-card {
  width: 100%;
  max-width: 340px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(31,42,59,0.97);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 28px 80px rgba(0,0,0,0.50);
}

.modal-title {
  color: var(--amber);
  text-align: center;
  font-size: 18px;
  font-weight: 720;
  letter-spacing: -0.025em;
}

.modal-info {
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  width: calc(100% - 40px);
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-strong);
  color: var(--text);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 300;
  text-align: center;
  pointer-events: none;
  line-height: 1.4;
}

.toast.toast-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.toast-ok {
  border-color: var(--green-line);
  background: var(--green-bg);
  color: var(--green);
}

.toast.toast-warn {
  border-color: var(--amber-line);
  background: var(--amber-bg);
  color: var(--amber);
}

input.field-offline { border-color: var(--amber); }
input.field-valid { border-color: var(--green); }
input.field-invalid { border-color: var(--red); }

.waypoint-row {
  display: flex;
  align-items: center;
  width: 100%;
  margin-bottom: 8px;
}

.waypoint-row input[type="text"] {
  flex: 1;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important;
  margin: 0 !important;
}

.waypoint-remove {
  flex: 0 0 46px;
  height: 52px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--red-bg);
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-add-waypoint {
  width: 100%;
  background: transparent;
  color: var(--green);
  font-size: 13px;
  padding: 4px 0;
  text-align: left;
  text-decoration: underline;
}

@media (max-width: 420px) {
  :root { --max-w: 100%; }

  .screen-body,
  .top-bar,
  .manual-title,
  .landing-wrap {
    max-width: none;
  }
}
