/*
File guide:
- Role: shared browser styling used by the FastAPI-rendered UI templates.
- Relies on: selectors/classes emitted by Jinja templates and browser CSS support.
- Relied on by: UI templates and workflow tests that assert usable screens.
- AADE/myDATA context: supports compliant operator review of invoices, myDATA marks, delivery notes, reports, and evidence.
*/

:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #5c6b7a;
  --border: #d8dee6;
  --primary: #0b5fff;
  --success: #0f7b3a;
  --error: #b42318;
  --surface-subtle: #f7f9fc;
  --accent: #6d5ce7;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fff;
  color: #0b3d91;
  border: 2px solid currentColor;
  border-radius: 6px;
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); }

:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 3px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: #0f1724;
  color: #fff;
}
.topbar a { color: #fff; }
.brand a { font-weight: 700; }
.topbar-right { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.nav { display: flex; gap: 0.5rem 1rem; align-items: center; flex-wrap: wrap; }
.nav > a { display: inline-flex; min-height: 44px; align-items: center; }
.lang-switch {
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  overflow: hidden;
}
.lang-btn {
  padding: 0.2rem 0.55rem;
  color: #fff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lang-btn:hover { background: rgba(255, 255, 255, 0.12); text-decoration: none; }
.lang-btn.active { background: var(--primary); }
.link-button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.container { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.card.narrow { max-width: 480px; margin: 2rem auto; }
.stack > * + * { margin-top: 0.75rem; }
.grid.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.grid.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; }
.summary-grid > div { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; background: #f9fbfd; }
.summary-grid span { display: block; color: var(--muted); font-size: 0.85rem; }
.summary-grid strong { display: block; margin-top: 0.25rem; font-size: 1.05rem; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.workspace-header { align-items: flex-start; margin: 1rem 0 1.5rem; }
.workspace-header h1 { margin: 0.15rem 0 0.35rem; font-size: clamp(1.8rem, 4vw, 2.7rem); line-height: 1.1; }
.eyebrow { margin: 0; color: var(--accent); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.lede { max-width: 68ch; color: var(--muted); font-size: 1.05rem; }
.breadcrumbs { display: flex; gap: 0.5rem; align-items: center; color: var(--muted); font-size: 0.9rem; }
.workspace-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; }
.metric-card { margin: 0; }
.metric-card span { display: block; color: var(--muted); font-size: 0.8rem; }
.metric-card strong { display: block; margin-top: 0.35rem; }
.badge-safe { background: #e7f7ed; color: var(--success); white-space: nowrap; }
.empty-state { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: start; margin-top: 1rem; padding: 1.5rem; }
.empty-state-mark { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 12px; background: #eeeafd; color: var(--accent); font-weight: 900; }
.empty-state h2 { margin-top: 0; }
.disclosure summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.tool-family { margin: 2rem 0; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0.8rem; }
.tool-card { position: relative; display: flex; flex-direction: column; min-height: 190px; padding: 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.tool-card h3 { margin: 0; }
.tool-card p { flex: 1; color: var(--muted); }
.stretched-link::after { position: absolute; inset: 0; content: ""; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.choice-card { border-top: 4px solid var(--border); }
.choice-card.recommended { border-top-color: var(--accent); }
.install-steps code { display: block; margin: 0.35rem 0 0.8rem; overflow-wrap: anywhere; }
.voice-launcher { position: fixed; z-index: 20; right: 1rem; bottom: 1rem; color: #fff; background: var(--accent); border-color: var(--accent); box-shadow: 0 8px 24px rgba(30, 35, 60, 0.22); }
.voice-launcher-unavailable { position: fixed; z-index: 20; right: 1rem; bottom: 1rem; }
.voice-launcher-unavailable .voice-launcher { position: static; cursor: not-allowed; opacity: .68; }
.voice-launcher-unavailable [role="tooltip"] { position: absolute; right: 0; bottom: calc(100% + .6rem); width: min(22rem, calc(100vw - 2rem)); padding: .65rem .75rem; border-radius: 8px; color: #fff; background: #172033; box-shadow: 0 8px 24px rgba(30, 35, 60, 0.25); opacity: 0; pointer-events: none; transform: translateY(.25rem); transition: opacity .15s ease, transform .15s ease; }
.voice-launcher-unavailable:hover [role="tooltip"], .voice-launcher-unavailable:focus [role="tooltip"], .voice-launcher-unavailable:focus-within [role="tooltip"] { opacity: 1; transform: translateY(0); }
.voice-launcher-unavailable:focus { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.voice-dialog { width: min(680px, calc(100% - 2rem)); max-height: 90vh; overflow: auto; border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; color: var(--text); }
.voice-dialog::backdrop { background: rgba(15, 23, 36, 0.72); }
.voice-dialog fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 1rem 0; }
.voice-dialog fieldset label { padding: 0.5rem; }
.voice-boundary { padding: 0.75rem; border-left: 4px solid var(--accent); background: var(--surface-subtle); }
.voice-context { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin: 1rem 0; }
.voice-context div { min-width: 0; padding: .75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-subtle); }
.voice-context dt { color: var(--muted); font-size: .8rem; }
.voice-context dd { margin: .15rem 0 0; overflow-wrap: anywhere; font-weight: 700; }
.voice-settings { margin: 1rem 0; border: 1px solid var(--border); border-radius: 8px; }
.voice-settings summary { min-height: 44px; padding: .65rem .75rem; cursor: pointer; font-weight: 700; }
.voice-settings[open] { padding: 0 .75rem .75rem; }
.voice-recorder { padding: 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-subtle); }
.voice-recording-indicator { margin-bottom: .75rem; color: var(--error); font-weight: 800; }
.voice-recording-indicator span { display: inline-block; width: .75rem; height: .75rem; margin-right: .35rem; border-radius: 50%; background: currentColor; animation: voice-pulse 1.4s ease-in-out infinite; }
.voice-level-label { display: grid; grid-template-columns: auto minmax(8rem, 1fr); align-items: center; gap: .75rem; }
.voice-level-label meter { width: 100%; height: 1.1rem; }
.voice-capture-guidance { color: var(--muted); font-size: .9rem; }
.voice-dialog [data-voice-draft] { margin-top: 1rem; }
.voice-dialog [data-voice-result] { width: 100%; }
@keyframes voice-pulse { 50% { opacity: .35; transform: scale(.8); } }
.voice-cloud-consent { padding: 0.75rem; border: 1px solid #b54708; border-radius: 8px; background: #fffaeb; }
.voice-error { color: var(--error); font-weight: 700; }
.voice-accuracy-setup textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.voice-calibration dl, [data-voice-accuracy-report] { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .75rem; }
.voice-calibration dl div, [data-voice-accuracy-report] div { border: 1px solid var(--border); border-radius: .5rem; padding: .75rem; }
.voice-calibration dt, [data-voice-accuracy-report] dt { font-size: .8rem; color: var(--muted); }
.voice-calibration dd, [data-voice-accuracy-report] dd { margin: .25rem 0 0; font-weight: 700; }
[data-voice-suggestion-list] { padding-left: 1.25rem; }
.dialog-close { float: right; min-width: 44px; font-size: 1.5rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

label { display: block; font-size: 0.9rem; margin-bottom: 0.75rem; }
input, select, textarea, button {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 44px;
}
button, .button {
  display: inline-block;
  background: #eef2f7;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}
button.primary, .button.primary, .primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.inline { display: inline; }
.inline-filters { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; }
.pager { display: flex; gap: 0.75rem; align-items: center; margin-top: 1rem; }

table { width: 100%; border-collapse: collapse; background: var(--card); }
caption { text-align: left; font-weight: 600; padding: 0.5rem 0; }
th, td { border-bottom: 1px solid var(--border); padding: 0.55rem 0.6rem; text-align: left; vertical-align: top; }
.muted { color: var(--muted); }
.badge {
  display: inline-block;
  background: #e8f1ff;
  color: #0b3d91;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.85rem;
}
.status { font-weight: 600; text-transform: capitalize; }
.facts { display: grid; grid-template-columns: 140px 1fr; gap: 0.35rem 1rem; }
.facts dt { color: var(--muted); }
.wrap { word-break: break-all; }
.list { list-style: none; padding: 0; }
.list li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.compact { margin: 0; padding-left: 1rem; }
.flash-list { list-style: none; padding: 0; }
.flash { padding: 0.6rem 0.8rem; border-radius: 6px; margin-bottom: 0.75rem; }
.flash-success { background: #e7f7ed; color: var(--success); }
.flash-error { background: #fdecea; color: var(--error); }
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  .topbar { align-items: flex-start; padding: 0.75rem; }
  .topbar, .topbar-right { flex-direction: column; width: 100%; }
  .container { width: 100%; padding: 0.75rem; overflow-wrap: anywhere; }
  .grid.three { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
  .workspace-grid { grid-template-columns: 1fr; }
  .empty-state { grid-template-columns: 1fr; }
  .choice-grid { grid-template-columns: 1fr; }
  table { font-size: 0.875rem; }
  th, td { padding: 0.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
