/* Työpari App — saavutettava, kontrastiturvallinen teema (WCAG AA). */
:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --ink: #1a2733;
  --muted: #5a6b7a;
  --primary: #0b3d5c;
  --primary-contrast: #ffffff;
  --accent: #c2541b;
  --accent-contrast: #ffffff;
  --ok: #1e7d3c;
  --warn-bg: #fff3d6;
  --warn-ink: #6b4d00;
  --danger: #b3261e;
  --border: #c6d0d9;
  --focus: #0a7abf;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(10, 30, 50, .15);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--primary);
  color: #fff; padding: .6rem 1rem; z-index: 100; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.topbar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  background: var(--primary); color: #fff; padding: .6rem 1rem;
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 1.15rem; }
.topbar-right { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.layout { display: flex; min-height: calc(100vh - 52px); }
.sidebar {
  width: 240px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 1rem .5rem; flex-shrink: 0;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.nav-item {
  display: block; width: 100%; text-align: left; padding: .65rem .9rem;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  color: var(--ink); cursor: pointer; font-weight: 600;
}
.nav-item:hover { background: #e8eef3; }
.nav-item.active { background: var(--primary); color: var(--primary-contrast); }

.content { flex: 1; padding: 1.25rem; min-width: 0; }
.view { max-width: 1100px; }

.banner { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.banner-warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid #e3c15a; }
.banner-error { background: #fdecea; color: var(--danger); border: 1px solid #f2b8b5; }
.banner-ok { background: #e7f6ec; color: var(--ok); border: 1px solid #b5e0c4; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1rem;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); cursor: pointer; font-weight: 600; text-decoration: none;
}
.btn-primary { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }
.btn-accent { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn-ghost { background: transparent; color: inherit; border-color: transparent; }
.btn-reject { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 .5rem; font-size: 1.05rem; }
.card p { margin: .25rem 0; }
.muted { color: var(--muted); font-size: .9rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.col { flex: 1 1 320px; min-width: 0; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field input, .field select, .field textarea, .search-form input {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: #fff;
}
.field-error { color: var(--danger); margin: .3rem 0 0; font-size: .9rem; }
[aria-invalid="true"] { border-color: var(--danger) !important; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.panel {
  position: fixed; right: 1rem; top: 4rem; width: min(560px, 92vw); max-height: 70vh;
  overflow: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.2); padding: 1rem; z-index: 40;
}
.search-form { display: flex; gap: .5rem; }
.search-results { margin-top: .75rem; }
.search-group h4 { margin: .8rem 0 .3rem; color: var(--primary); }
.search-group a { display: block; padding: .3rem 0; color: var(--primary); }

dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem;
  width: min(640px, 94vw); background: var(--surface);
}
dialog::backdrop { background: rgba(10, 30, 50, .45); }
.dialog-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.context-preview {
  background: #eef3f7; border: 1px solid var(--border); border-radius: var(--radius);
  padding: .7rem; margin-bottom: 1rem; font-size: .9rem; max-height: 160px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: .55rem .65rem; border-bottom: 1px solid var(--border); }
th { background: #eef3f7; }
.status-pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.status-ok { background: #e7f6ec; color: var(--ok); }
.status-warn { background: var(--warn-bg); color: var(--warn-ink); }
.status-err { background: #fdecea; color: var(--danger); }

.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button {
  border: none; background: transparent; padding: .6rem 1rem; cursor: pointer;
  font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.spinner { border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%;
           width: 28px; height: 28px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-card { max-width: 420px; margin: 10vh auto; background: var(--surface);
              border: 1px solid var(--border); border-radius: 12px; padding: 2rem; box-shadow: var(--shadow); }
.login-card h1 { margin-top: 0; }
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 52px; bottom: 0; z-index: 30;
             transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .layout { display: block; }
  .content { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
