@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Public+Sans:wght@400;500;600;700&display=swap');

:root{
  --ink:#142420; --paper:#eef1ec; --surface:#ffffff; --surface-2:#f6f8f5; --line:#d7ddd3;
  --accent:#1f6f5e; --accent-ink:#ffffff; --accent-2:#c97a2e;
  --stage-neu:#6b7a90; --stage-progress:#c98a2c; --stage-termin:#3b6ea5; --stage-won:#2f8f5b; --stage-lost:#b5484f;
  --shadow: 0 1px 2px rgba(20,36,32,.06), 0 8px 24px -12px rgba(20,36,32,.18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --ink:#e7ece6; --paper:#101512; --surface:#161d18; --surface-2:#1b231d; --line:#2b342c;
    --accent:#57b79c; --accent-ink:#0b1512; --accent-2:#e3a860;
    color-scheme: dark;
  }
}
*{box-sizing:border-box;}
html,body{height:100%;margin:0;}
body{background:var(--paper); color:var(--ink); font-family:'Public Sans', system-ui, sans-serif;}
h1,h2,h3,.brand{font-family:'Fraunces', Georgia, serif;}
button,input,select,textarea{font-family:inherit;}
a{color:var(--accent);}

/* ---------- Login ---------- */
.login-screen{min-height:100dvh; display:flex; align-items:center; justify-content:center; padding:24px;}
.login-card{background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:32px; width:100%; max-width:360px; box-shadow:var(--shadow);}
.login-card h1{font-size:22px; margin:0 0 4px;}
.login-card p.sub{font-size:13.5px; color:color-mix(in srgb, var(--ink) 60%, transparent); margin:0 0 22px;}
.field{margin-bottom:14px;}
.field label{font-size:12.5px; font-weight:600; display:block; margin-bottom:6px;}
.field input{width:100%; padding:10px 12px; border-radius:9px; border:1px solid var(--line); background:var(--surface); color:var(--ink); font-size:14px;}
.error-msg{color:var(--stage-lost); font-size:13px; margin:8px 0; min-height:18px;}
.btn{display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:11px 18px; border-radius:10px; border:none; background:var(--accent); color:var(--accent-ink); font-weight:700; font-size:13.5px; cursor:pointer; width:100%;}
.btn.secondary{background:transparent; border:1px solid var(--line); color:var(--ink); width:auto;}
.btn.small{padding:8px 14px; font-size:12.5px; width:auto;}
[hidden]{display:none!important;}

/* ---------- App shell ---------- */
.app{display:grid; grid-template-columns:220px 1fr; min-height:100dvh;}
@media (max-width:760px){ .app{grid-template-columns:1fr;} }
.sidebar{background:var(--surface); border-right:1px solid var(--line); display:flex; flex-direction:column; gap:4px; padding:20px 14px;}
@media (max-width:760px){
  .sidebar{position:fixed; bottom:0; left:0; right:0; top:auto; z-index:20; flex-direction:row;
    overflow-x:auto; padding:8px; border-right:none; border-top:1px solid var(--line); gap:2px;}
  .sidebar .brand-row{display:none;}
}
.brand-row{display:flex; align-items:center; gap:10px; padding:4px 8px 18px;}
.brand-mark{width:30px; height:30px; border-radius:8px; background:linear-gradient(155deg, var(--accent), var(--accent-2)); flex:none;}
.brand{font-size:18px; font-weight:600;}
.brand small{display:block; font-family:'Public Sans',sans-serif; font-weight:500; font-size:11px; text-transform:uppercase; color:color-mix(in srgb, var(--ink) 55%, transparent);}
.nav-item{display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:10px; border:none; background:transparent; color:var(--ink); font-size:14px; font-weight:500; cursor:pointer; text-align:left;}
.nav-item .ic{width:18px; text-align:center;}
.nav-item:hover{background:var(--surface-2);}
.nav-item[aria-current="page"]{background:var(--accent); color:var(--accent-ink);}
@media (max-width:760px){ .nav-item{flex-direction:column; gap:2px; font-size:9.5px; padding:6px 10px; flex:0 0 auto; width:auto; min-width:60px;} .nav-item .ic{font-size:17px;} }
.badge-row{margin-top:auto; padding:12px; border-top:1px solid var(--line); font-size:11.5px; color:color-mix(in srgb, var(--ink) 60%, transparent);}
@media (max-width:760px){ .badge-row{display:none;} }

main{padding:28px 32px 90px; max-width:1150px; width:100%;}
@media (max-width:760px){ main{padding:20px 16px 90px;} }
.topline{display:flex; align-items:baseline; justify-content:space-between; gap:16px; flex-wrap:wrap;}
.eyebrow{font-size:11.5px; font-weight:600; letter-spacing:.08em; text-transform:uppercase; color:var(--accent);}
h1{font-size:26px; margin:2px 0 0;}
.sub{color:color-mix(in srgb, var(--ink) 62%, transparent); font-size:14px; margin:6px 0 24px; max-width:64ch;}

.grid{display:grid; gap:16px;}
.kpis{grid-template-columns:repeat(4,1fr); margin-bottom:24px;}
@media (max-width:900px){ .kpis{grid-template-columns:repeat(2,1fr);} }
.card{background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:18px; box-shadow:var(--shadow);}
.kpi .label{font-size:12px; color:color-mix(in srgb, var(--ink) 60%, transparent); font-weight:600; text-transform:uppercase;}
.kpi .value{font-family:'Fraunces',serif; font-size:30px; font-weight:600; margin-top:6px;}
.cols2{grid-template-columns:1.3fr 1fr;}
@media (max-width:820px){ .cols2{grid-template-columns:1fr;} }
.card h3{font-size:14.5px; margin:0 0 14px; display:flex; align-items:center; justify-content:space-between;}

.rowline{display:flex; align-items:center; gap:12px; padding:9px 0; border-bottom:1px solid var(--line); cursor:pointer;}
.rowline:last-child{border-bottom:none;}
.rowline:hover{background:var(--surface-2);}
.avatar{width:32px; height:32px; border-radius:50%; background:var(--surface-2); display:flex; align-items:center; justify-content:center; font-size:12.5px; font-weight:700; color:var(--accent); flex:none; border:1px solid var(--line);}
.rmeta{flex:1; min-width:0;}
.rmeta .name{font-size:13.5px; font-weight:600;}
.rmeta .sub2{font-size:12px; color:color-mix(in srgb, var(--ink) 58%, transparent);}
.pill{font-size:11px; font-weight:700; padding:3px 9px; border-radius:99px; white-space:nowrap;}
.pill.neu{background:color-mix(in srgb, var(--stage-neu) 20%, transparent); color:var(--stage-neu);}
.pill.in_bearbeitung{background:color-mix(in srgb, var(--stage-progress) 20%, transparent); color:var(--stage-progress);}
.pill.termin{background:color-mix(in srgb, var(--stage-termin) 20%, transparent); color:var(--stage-termin);}
.pill.gewonnen{background:color-mix(in srgb, var(--stage-won) 20%, transparent); color:var(--stage-won);}
.pill.verloren{background:color-mix(in srgb, var(--stage-lost) 20%, transparent); color:var(--stage-lost);}

.toolbar{display:flex; gap:10px; flex-wrap:wrap; margin-bottom:16px; align-items:center;}
.search{flex:1; min-width:180px; padding:9px 13px; border-radius:10px; border:1px solid var(--line); background:var(--surface); color:var(--ink); font-size:13.5px;}
table{width:100%; border-collapse:collapse; font-size:13.5px;}
th{text-align:left; font-size:11.5px; text-transform:uppercase; color:color-mix(in srgb, var(--ink) 55%, transparent); padding:0 10px 10px; border-bottom:1px solid var(--line);}
td{padding:11px 10px; border-bottom:1px solid var(--line); vertical-align:middle;}
tbody tr{cursor:pointer;}
tbody tr:hover{background:var(--surface-2);}
.twrap{overflow-x:auto; background:var(--surface); border:1px solid var(--line); border-radius:14px; box-shadow:var(--shadow);}
.twrap table{min-width:640px;}
.tag{font-size:11px; font-weight:600; padding:2px 8px; border-radius:6px; background:var(--surface-2); border:1px solid var(--line);}

.kanban{display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:14px; align-items:start;}
@media (max-width:980px){ .kanban{grid-template-columns:1fr;} }
.kcol-head{display:flex; align-items:center; justify-content:space-between; font-size:12.5px; font-weight:700; padding:0 2px 8px;}
.kcard{background:var(--surface); border:1px solid var(--line); border-left:4px solid var(--stage-c,var(--accent)); border-radius:10px; padding:11px 12px; box-shadow:var(--shadow); font-size:13px; margin-bottom:10px;}
.kcard select{width:100%; font-size:12px; padding:5px 6px; border-radius:7px; border:1px solid var(--line); background:var(--surface-2); color:var(--ink); margin-top:6px;}

.form{display:grid; gap:14px; max-width:480px;}
label{font-size:12.5px; font-weight:600; display:block; margin-bottom:6px;}
select, input[type=text], input[type=date], textarea{width:100%; padding:9px 12px; border-radius:9px; border:1px solid var(--line); background:var(--surface); color:var(--ink); font-size:13.5px;}
.match-box{background:var(--surface-2); border:1px dashed var(--line); border-radius:12px; padding:14px 16px;}
.match-box .n{font-family:'Fraunces',serif; font-size:26px; font-weight:600;}

.prio-item{display:flex; align-items:center; gap:12px; padding:10px 4px; border-bottom:1px solid var(--line); border-left:3px solid var(--line); padding-left:12px; cursor:pointer;}
.prio-item:last-child{border-bottom:none;}
.prio-item.crit{border-left-color:var(--stage-lost);}
.prio-item.warn{border-left-color:var(--stage-progress);}
.prio-badge{font-size:10.5px; font-weight:700; text-transform:uppercase; padding:2px 7px; border-radius:6px; flex:none;}
.prio-badge.crit{background:color-mix(in srgb, var(--stage-lost) 18%, transparent); color:var(--stage-lost);}
.prio-badge.warn{background:color-mix(in srgb, var(--stage-progress) 18%, transparent); color:var(--stage-progress);}
.prio-text{flex:1; min-width:0; font-size:13.5px;}
.prio-text .t2{font-size:12px; color:color-mix(in srgb, var(--ink) 58%, transparent);}
.prio-empty{font-size:13.5px; color:color-mix(in srgb, var(--ink) 58%, transparent);}

.task-row{display:flex; align-items:center; gap:12px; background:var(--surface); border:1px solid var(--line); border-radius:10px; padding:11px 14px; margin-bottom:8px;}
.task-row.done{opacity:.55;}
.task-row.done .task-title{text-decoration:line-through;}
.task-check{width:19px; height:19px; border-radius:6px; border:1.5px solid var(--line); flex:none; cursor:pointer; display:flex; align-items:center; justify-content:center; background:var(--surface); font-size:12px;}
.task-check.checked{background:var(--accent); border-color:var(--accent); color:var(--accent-ink);}
.task-title{font-size:13.5px; font-weight:600; flex:1;}
.task-due{font-size:11.5px; font-weight:700; padding:3px 9px; border-radius:99px; white-space:nowrap;}
.task-due.overdue{background:color-mix(in srgb, var(--stage-lost) 18%, transparent); color:var(--stage-lost);}
.task-due.today{background:color-mix(in srgb, var(--stage-progress) 18%, transparent); color:var(--stage-progress);}
.task-due.future{background:var(--surface-2); color:color-mix(in srgb, var(--ink) 55%, transparent);}
.task-due.done{background:color-mix(in srgb, var(--stage-won) 18%, transparent); color:var(--stage-won);}
.task-add{display:flex; gap:8px; flex-wrap:wrap; margin-bottom:18px;}
.task-add input[type=text]{flex:2; min-width:180px;}

.err-row{display:flex; align-items:flex-start; gap:10px; padding:10px 0; border-bottom:1px solid var(--line);}
.err-row:last-child{border-bottom:none;}
.err-sev{font-size:10.5px; font-weight:700; text-transform:uppercase; padding:2px 7px; border-radius:6px; background:color-mix(in srgb, var(--stage-lost) 18%, transparent); color:var(--stage-lost); flex:none;}
.evt-row{font-size:12.5px; padding:7px 0; border-bottom:1px solid var(--line);}
.evt-row:last-child{border-bottom:none;}
.evt-row .t{color:color-mix(in srgb, var(--ink) 55%, transparent); font-size:11px;}

.panel-overlay{position:fixed; inset:0; background:rgba(10,15,12,.35); z-index:30; display:flex; justify-content:flex-end;}
.panel{background:var(--surface); width:min(420px,92vw); height:100%; padding:24px 20px; overflow-y:auto; position:relative;}
.panel-close{position:absolute; top:16px; right:16px; border:none; background:var(--surface-2); width:30px; height:30px; border-radius:50%; cursor:pointer;}
.kv{display:flex; justify-content:space-between; gap:12px; padding:9px 0; border-bottom:1px solid var(--line); font-size:13.5px;}
.kv .k{color:color-mix(in srgb, var(--ink) 58%, transparent);}
.kv .v{font-weight:600; text-align:right;}
.timeline{margin-top:14px; display:flex; flex-direction:column; gap:8px; max-height:200px; overflow-y:auto;}
.note-form{margin-top:18px; padding-top:16px; border-top:1px solid var(--line); display:flex; flex-direction:column; gap:10px;}

.toast{position:fixed; bottom:24px; left:50%; transform:translate(-50%,20px); background:var(--ink); color:var(--paper); padding:12px 18px; border-radius:10px; font-size:13.5px; font-weight:600; opacity:0; pointer-events:none; transition:all .2s ease; z-index:40; max-width:88vw; text-align:center;}
@media (max-width:760px){ .toast{bottom:74px;} }
.toast.show{opacity:1; transform:translate(-50%,0);}
.loading{padding:20px; color:color-mix(in srgb, var(--ink) 55%, transparent); font-size:13.5px;}
