:root {
  --brand-blue: #59afff;
  --brand-blue-dark: #0a5aa4;
  --brand-navy: #28355f;
  --brand-pink: #ba4458;
  --brand-red: #d5384d;
  --brand-yellow: #fab600;
  --brand-gradient: linear-gradient(90deg, #59afff 0%, #fab600 52%, #ba4458 100%);

  --bg: #f7fbff;
  --bg-soft: #e2edf8;
  --surface: #ffffff;
  --text: #28355f;
  --text-body: #495561;
  --muted: #748597;
  --border: #cae5ff;
  --border-strong: #a5bbd1;

  --primary: var(--brand-blue-dark);
  --primary-hover: #084a8a;
  --accent: var(--brand-blue);
  --warning: #b45309;
  --danger: var(--brand-red);
  --success: #157a3b;

  --shadow-sm: 0 4px 16px rgba(40, 53, 95, 0.06);
  --shadow: 0 12px 40px rgba(40, 53, 95, 0.08);
  --radius: 16px;
  --radius-sm: 10px;

  --font-display: "Finlandica", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-body);
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, rgba(89, 175, 255, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 0% 0%, rgba(250, 182, 0, 0.06), transparent 50%),
    var(--bg);
  line-height: 1.55;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text);
  font-weight: 600;
}

.header {
  position: relative;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px 28px;
  box-shadow: var(--shadow-sm);
}

.header__bar {
  height: 4px;
  background: var(--brand-gradient);
  margin: 0 -20px 24px;
}

.header__inner {
  max-width: 1140px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.header__brand {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.header__logo {
  display: inline-flex;
  line-height: 0;
}

.header__logo img {
  display: block;
  height: 22px;
  width: auto;
}

.eyebrow {
  margin: 0 0 4px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-blue-dark);
}

.header h1 {
  margin: 0;
  font-size: clamp(26px, 3.5vw, 34px);
  line-height: 1.15;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  max-width: 520px;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.sync-status {
  font-size: 13px;
  color: var(--muted);
  max-width: 320px;
  line-height: 1.4;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.search-panel,
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.search-panel {
  padding: 24px 24px 20px;
  margin-bottom: 28px;
}

.search-panel__title {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--bg-soft);
}

.search-panel__title h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.search-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.search-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.search-field--grow { flex: 1; }

input[type="search"],
select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-body);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="search"]:hover,
select:hover {
  border-color: var(--brand-blue);
}

input[type="search"]:focus,
select:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(89, 175, 255, 0.22);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-blue-dark);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 18px;
  align-items: end;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
  padding-top: 22px;
  color: var(--text-body) !important;
  font-weight: 400 !important;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--brand-blue-dark);
  color: #fff;
  box-shadow: 0 4px 14px rgba(10, 90, 164, 0.28);
}

.btn--primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 18px rgba(10, 90, 164, 0.32);
}

.btn--ghost {
  background: var(--surface);
  color: var(--brand-blue-dark);
  border: 1px solid var(--border-strong);
}

.btn--ghost:hover {
  background: var(--bg);
  border-color: var(--brand-blue);
}

.btn--link {
  background: rgba(89, 175, 255, 0.12);
  color: var(--brand-blue-dark);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.btn--link:hover {
  background: rgba(89, 175, 255, 0.22);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.results-header h2 {
  margin: 0;
  font-size: 20px;
}

.muted {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

.results {
  display: grid;
  gap: 16px;
}

.card {
  position: relative;
  overflow: hidden;
  padding: 20px 22px 18px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  border-color: var(--brand-blue);
  box-shadow: var(--shadow);
}

.card__accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--brand-gradient);
}

.card__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.card__customer {
  margin: 10px 0 4px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.card__title-line {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.card__story {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.story-block {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--bg-soft);
  border-left: 3px solid var(--brand-blue);
}

.story-block:nth-child(2) { border-left-color: var(--brand-yellow); }
.story-block:nth-child(3) { border-left-color: var(--brand-pink); }

.story-block__title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--brand-blue-dark);
}

.story-block:nth-child(2) .story-block__title { color: #9a7200; }
.story-block:nth-child(3) .story-block__title { color: var(--brand-pink); }

.story-block__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-body);
}

.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(89, 175, 255, 0.14);
  color: var(--brand-blue-dark);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge--source {
  background: var(--bg-soft);
  color: var(--text-body);
  margin-left: 8px;
}

.card__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-body);
  border: 1px solid transparent;
}

.chip--tech {
  background: rgba(89, 175, 255, 0.1);
  color: var(--brand-blue-dark);
  border-color: rgba(89, 175, 255, 0.25);
}

.chip--task-group {
  background: rgba(40, 53, 95, 0.07);
  color: var(--brand-navy);
  font-weight: 600;
}

.chip--warn {
  background: rgba(250, 182, 0, 0.14);
  color: #8a6500;
}

.chip--danger {
  background: rgba(213, 56, 77, 0.1);
  color: var(--brand-red);
}

.chip--ok {
  background: rgba(21, 122, 59, 0.1);
  color: var(--success);
}

.card__details {
  margin-top: 16px;
  border-top: 1px solid var(--bg-soft);
  padding-top: 12px;
}

.card__details summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--brand-blue-dark);
  list-style: none;
}

.card__details summary::-webkit-details-marker { display: none; }

.card__details summary::before {
  content: "▸ ";
  color: var(--brand-blue);
}

.card__details[open] summary::before {
  content: "▾ ";
}

.details-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  margin: 14px 0 0;
}

.details-grid dt {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.details-grid dd {
  margin: 0;
  font-size: 14px;
  color: var(--text-body);
}

.details-grid a {
  color: var(--brand-blue-dark);
  word-break: break-all;
}

.empty, .error {
  text-align: center;
  padding: 48px 24px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border-strong);
}

.empty h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.error {
  color: var(--brand-red);
  border-color: rgba(213, 56, 77, 0.35);
  background: rgba(213, 56, 77, 0.04);
}

.hidden { display: none !important; }

.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 20px;
  margin-top: auto;
}

.footer__inner {
  max-width: 1140px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}

.footer__inner p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.footer__inner img {
  opacity: 0.85;
  height: 14px;
  width: auto;
}

@media (max-width: 720px) {
  .search-row { flex-direction: column; align-items: stretch; }
  .card__head { flex-direction: column; }
  .card__actions { align-items: flex-start; }
  .details-grid { grid-template-columns: 1fr; }
  .header__actions { width: 100%; }
  .footer__inner { flex-direction: column; align-items: flex-start; }
}
