/* onkohub – Prototyp · Design-System
   Petrol/Teal klinisch · Amber = Aufmerksamkeit · Grün = freigegeben
   Space Grotesk (Display) · Inter (UI) · IBM Plex Mono (klinische Daten) */

:root {
  --paper:      #F4F6F5;
  --surface:    #FFFFFF;
  --surface-2:  #FBFCFB;
  --ink:        #15242B;
  --subtle:     #5A6B6B;
  --faint:      #859796;
  --mist:       #E2E8E6;
  --mist-2:     #EDF1EF;

  --petrol:     #0C5C57;
  --petrol-700: #094844;
  --petrol-050: #E6F0EE;
  --petrol-100: #D2E5E2;

  --amber:      #B45309;
  --amber-bg:   #FBF0E2;
  --green:      #1A7A48;
  --green-bg:   #E7F2EB;
  --blue:       #0E6F9C;
  --blue-bg:    #E5F0F6;
  --violet:     #5B53B5;
  --violet-bg:  #ECEAF7;
  --red:        #B3261E;
  --red-bg:     #F8E9E8;
  --slate:      #5C6B7A;
  --slate-bg:   #EDF0F2;

  --shadow-sm: 0 1px 2px rgba(20,40,45,.05), 0 1px 1px rgba(20,40,45,.04);
  --shadow-md: 0 4px 16px rgba(12,55,52,.08), 0 1px 3px rgba(12,55,52,.06);

  --r-sm: 7px;
  --r-md: 11px;
  --r-lg: 16px;

  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', var(--sans);
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --maxw: 1080px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: -0.01em; }

.mono { font-family: var(--mono); font-feature-settings: 'tnum' 1; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--ink); color: #fff; padding: 8px 14px; border-radius: var(--r-sm);
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

/* ---------- App bar ---------- */
.appbar {
  display: flex; align-items: center; gap: 18px;
  height: 60px; padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--mist);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand__mark { display: inline-flex; }
.brand__word {
  font-family: var(--display); font-weight: 700; font-size: 21px;
  letter-spacing: -0.02em; color: var(--ink);
}

.tabs { display: flex; gap: 2px; margin-left: 6px; }
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--subtle);
  padding: 8px 13px; border-radius: var(--r-sm); line-height: 1;
}
.tab:hover { background: var(--mist-2); color: var(--ink); }
.tab--active { background: var(--petrol-050); color: var(--petrol-700); font-weight: 600; }

.appbar__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.roleswitch {
  display: flex; background: var(--mist-2); border: 1px solid var(--mist);
  border-radius: 9px; padding: 3px; gap: 2px;
}
.role {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500; color: var(--subtle);
  padding: 6px 11px; border-radius: 6px; white-space: nowrap; line-height: 1.1;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
}
.role small { font-size: 10px; color: var(--faint); font-weight: 500; }
.role:hover { color: var(--ink); }
.role--active { background: var(--surface); color: var(--petrol-700); box-shadow: var(--shadow-sm); font-weight: 600; }
.role--active small { color: var(--petrol); }

/* ---------- Ribbon ---------- */
.ribbon {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  background: linear-gradient(180deg, #F8EFE0, #FAF4EA);
  border-bottom: 1px solid #EFE0C8;
  color: #7A5414; font-size: 12px; letter-spacing: 0.01em;
  padding: 6px 16px; font-family: var(--mono);
}
.ribbon strong { font-weight: 600; }
.ribbon__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); flex-shrink: 0; }
@media (prefers-reduced-motion: no-preference) {
  .ribbon__dot { animation: pulse 2.4s ease-in-out infinite; }
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Layout ---------- */
.main { max-width: var(--maxw); margin: 0 auto; padding: 28px 20px 64px; outline: none; }
@media (prefers-reduced-motion: no-preference) {
  .view { animation: rise .28s cubic-bezier(.2,.7,.3,1); }
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.pagehead__titles { display: flex; flex-direction: column; gap: 4px; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--petrol); font-weight: 500; }
.pagehead h1 { font-size: 26px; }
.pagehead .sub { color: var(--subtle); font-size: 14px; }

.backlink {
  display: inline-flex; align-items: center; gap: 6px; color: var(--subtle);
  background: none; border: 0; cursor: pointer; font-family: var(--sans); font-size: 13px;
  padding: 4px 0; margin-bottom: 14px;
}
.backlink:hover { color: var(--petrol-700); }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; cursor: pointer; font-family: var(--sans); font-weight: 600;
  font-size: 14px; line-height: 1; border-radius: var(--r-sm);
  padding: 10px 16px; border: 1px solid transparent; display: inline-flex; align-items: center; gap: 8px;
  transition: background .14s ease, border-color .14s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--primary { background: var(--petrol); color: #fff; }
.btn--primary:hover { background: var(--petrol-700); }
.btn--approve { background: var(--green); color: #fff; }
.btn--approve:hover { filter: brightness(.93); }
.btn--send { background: var(--amber); color: #fff; }
.btn--send:hover { filter: brightness(.93); }
.btn--outline { background: var(--surface); border-color: var(--mist); color: var(--ink); }
.btn--outline:hover { border-color: var(--petrol-100); background: var(--surface-2); }
.btn--ghost { background: transparent; color: var(--subtle); }
.btn--ghost:hover { background: var(--mist-2); color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .tab:focus-visible, .role:focus-visible, .backlink:focus-visible,
.row:focus-visible, a:focus-visible { outline: 2px solid var(--petrol); outline-offset: 2px; }

/* ---------- Status chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500;
  padding: 3px 9px 3px 7px; border-radius: 999px; white-space: nowrap;
}
.chip__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.chip[data-s="vorbereitet"]   { color: var(--slate);  background: var(--slate-bg); }
.chip[data-s="zur_freigabe"]  { color: var(--amber);  background: var(--amber-bg); }
.chip[data-s="freigegeben"]   { color: var(--green);  background: var(--green-bg); }
.chip[data-s="bestellt"]      { color: var(--blue);   background: var(--blue-bg); }
.chip[data-s="in_herstellung"]{ color: var(--violet); background: var(--violet-bg); }
.chip[data-s="geliefert"]     { color: var(--petrol); background: var(--petrol-050); }
.chip[data-s="gabe_erfolgt"]  { color: var(--green);  background: var(--green-bg); }
.chip[data-s="storniert"]     { color: var(--red);    background: var(--red-bg); }

.tag {
  display: inline-flex; align-items: center; font-size: 11px; font-family: var(--mono);
  letter-spacing: .03em; padding: 2px 7px; border-radius: 5px;
  background: var(--mist-2); color: var(--subtle);
}
.tag--warn { background: var(--amber-bg); color: var(--amber); }

/* ---------- Cards / surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--mist); border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

.section-label { font-family: var(--mono); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); margin: 0 0 10px; }

/* ---------- Freigabeliste / order rows ---------- */
.listcard { padding: 6px; }
.list__group-title { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--ink); }
.list__group-title .count { font-family: var(--mono); font-size: 12px; color: var(--subtle); background: var(--mist-2); border-radius: 999px; padding: 1px 8px; }

.row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; align-items: center;
  width: 100%; text-align: left; background: transparent; border: 0; cursor: pointer;
  padding: 13px 12px; border-radius: var(--r-sm); font-family: var(--sans);
}
.row + .row { border-top: 1px solid var(--mist-2); }
.row:hover { background: var(--surface-2); }
.row__main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.row__name { font-weight: 600; font-size: 15px; color: var(--ink); }
.row__meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--subtle); font-size: 13px; }
.row__meta .mono { font-size: 12.5px; color: var(--subtle); }
.row__right { display: flex; align-items: center; gap: 14px; justify-self: end; }
.row__chev { color: var(--faint); font-size: 18px; }

/* ---------- Cycle rhythm (signature) ---------- */
.cycle { display: flex; flex-direction: column; gap: 8px; }
.cycle__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cycle__no { font-family: var(--mono); font-weight: 500; font-size: 13px; color: var(--ink); }
.cycle__next { font-size: 12.5px; color: var(--amber); font-weight: 500; }
.cycle__track { display: flex; align-items: center; gap: 0; }
.cycle__node { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.cycle__dot {
  width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--mist);
  background: var(--surface); flex-shrink: 0;
}
.cycle__dot--done { background: var(--petrol-100); border-color: var(--petrol-100); }
.cycle__dot--now  { background: var(--petrol); border-color: var(--petrol); box-shadow: 0 0 0 4px var(--petrol-050); }
.cycle__day { font-family: var(--mono); font-size: 10.5px; color: var(--subtle); }
.cycle__seg { height: 2px; width: 26px; background: var(--mist); margin: 0 2px; align-self: flex-start; margin-top: 6px; }
.cycle__seg--done { background: var(--petrol-100); }
.cycle--mini .cycle__dot { width: 9px; height: 9px; border-width: 1.5px; }
.cycle--mini .cycle__seg { width: 14px; }
.cycle--mini .cycle__day { display: none; }

/* ---------- Data fields ---------- */
.fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--mist-2); border-radius: var(--r-sm); overflow: hidden; }
.field { background: var(--surface); padding: 12px 14px; }
.field__label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); margin-bottom: 3px; }
.field__value { font-family: var(--mono); font-size: 14px; color: var(--ink); font-weight: 500; }
.field__value.txt { font-family: var(--sans); }

.cardpad { padding: 18px; }
.cardpad + .cardpad { border-top: 1px solid var(--mist); }

/* protocol drug lines */
.drugs { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.drugs th { text-align: left; font-family: var(--mono); font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); font-weight: 500; padding: 0 10px 8px; }
.drugs td { padding: 9px 10px; border-top: 1px solid var(--mist-2); vertical-align: middle; }
.drugs .sub { font-weight: 600; }
.drugs .mono { color: var(--subtle); }

.callout { display: flex; gap: 10px; align-items: flex-start; background: var(--amber-bg); border: 1px solid #EFD9B8; border-radius: var(--r-sm); padding: 11px 13px; font-size: 13px; color: #7A5414; }
.callout--info { background: var(--petrol-050); border-color: var(--petrol-100); color: var(--petrol-700); }
.callout b { font-weight: 600; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* ---------- Pharmacy access / QR ---------- */
.qrbox { display: flex; gap: 16px; align-items: center; }
.qr { width: 132px; height: 132px; border-radius: var(--r-sm); border: 1px solid var(--mist); background: #fff; padding: 6px; flex-shrink: 0; }
.qr img { width: 100%; height: 100%; display: block; }
.qr__fallback { font-family: var(--mono); font-size: 10px; color: var(--subtle); padding: 8px; word-break: break-all; }
.access-opts { display: flex; flex-direction: column; gap: 8px; }
.access-opt { display: flex; gap: 9px; align-items: baseline; font-size: 13px; color: var(--subtle); }
.access-opt b { color: var(--ink); font-weight: 600; }

/* ---------- Tagesplan (document) ---------- */
.doc { background: #fff; border: 1px solid var(--mist); border-radius: var(--r-md); box-shadow: var(--shadow-md); max-width: 760px; margin: 0 auto; padding: 38px 44px; }
.doc__head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 20px; }
.doc__title { font-family: var(--display); font-size: 21px; font-weight: 600; }
.doc__org { text-align: right; font-size: 12.5px; color: var(--subtle); line-height: 1.45; }
.doc h4 { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin: 22px 0 8px; font-weight: 500; }
.doc__meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 24px; font-size: 13.5px; }
.doc__meta div { display: flex; justify-content: space-between; border-bottom: 1px dotted var(--mist); padding: 4px 0; }
.doc__meta span:first-child { color: var(--subtle); }
.doc__meta span:last-child { font-family: var(--mono); }
.doc__foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--mist); font-size: 12px; color: var(--faint); display: flex; justify-content: space-between; gap: 12px; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--subtle); }
.empty__title { font-family: var(--display); font-weight: 600; color: var(--ink); font-size: 17px; margin-bottom: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--r-sm);
  box-shadow: var(--shadow-md); font-size: 14px; z-index: 60; max-width: 90vw;
  display: flex; align-items: center; gap: 10px; opacity: 0; transition: opacity .2s ease, transform .2s ease;
}
.toast[data-show="1"] { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .appbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .tabs { order: 3; width: 100%; }
  .appbar__right { width: 100%; justify-content: space-between; }
  .role small { display: none; }
  .pagehead h1 { font-size: 22px; }
  .doc { padding: 24px 20px; }
  .doc__head { flex-direction: column; gap: 10px; }
  .doc__org { text-align: left; }
}

/* ---------- Print (Tagesplan) ---------- */
@media print {
  .appbar, .ribbon, .backlink, .toolbar, .toast { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; max-width: none; }
  .doc { border: 0; box-shadow: none; max-width: none; padding: 0; }
}
