/* App shell, built on base.css palette */
body{min-height:100vh}
.appbar{display:flex;align-items:center;justify-content:space-between;padding:12px 24px;background:#fff;border-bottom:1px solid var(--line);position:sticky;top:0;z-index:20}
.brand{display:flex;align-items:center;gap:12px}
.logo{width:36px;height:36px;border-radius:10px;background:var(--green);color:#fff;display:grid;place-items:center;font-weight:700;font-size:18px}
.brand-name{font:700 18px/1.1 Georgia,serif;color:var(--green-dark)}
.brand-sub{font-size:12px;color:var(--muted)}
.pill{display:inline-flex;align-items:center;gap:8px;padding:6px 12px;border-radius:999px;font-size:12px;font-weight:600;background:var(--soft)}
.pill i{width:8px;height:8px;border-radius:50%;background:#bbb}
.pill.ok i{background:#2e9e6b}.pill.bad{background:#fdecea;color:#b3261e;border-color:#f3c5c0}.pill.bad i{background:#b3261e}
main{max-width:none;padding:20px 24px 40px}
button.primary{background:var(--green);border-color:var(--green);color:#fff}
button.primary:hover:not(:disabled){background:var(--green-dark);border-color:var(--green-dark)}
button.ghost{background:transparent;border-color:transparent;color:var(--muted)}
button.ghost:hover:not(:disabled){background:var(--soft);color:var(--ink)}
button.danger:hover:not(:disabled){background:#fdecea;color:#b3261e}
button:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.home-grid{display:grid;grid-template-columns:minmax(300px,420px) 1fr;gap:16px;align-items:start}
@media(max-width:860px){.home-grid{grid-template-columns:1fr}main{padding:14px}}
.panel-head{display:flex;justify-content:space-between;align-items:center}
.dropzone{margin-top:14px;border:2px dashed #c7d6cd;border-radius:14px;padding:34px 20px;text-align:center;cursor:pointer;background:#fafcfa;transition:all .15s}
.dropzone:hover,.dropzone.drag{border-color:var(--focus);background:var(--soft)}
.dropzone strong{display:block;font-size:15px;word-break:break-all}
.dropzone span{color:var(--muted);font-size:12px}
.drop-icon{font-size:30px;color:var(--green);margin-bottom:6px}
.drop-actions{display:flex;gap:8px;justify-content:center;margin-top:14px;flex-wrap:wrap}
.upload-list{display:flex;flex-direction:column;gap:10px;margin-top:12px}
.upload-card{display:flex;justify-content:space-between;align-items:center;gap:16px;border:1px solid var(--line);border-radius:12px;padding:14px 16px;background:#fff;transition:border-color .15s,box-shadow .15s}
.upload-card:hover{border-color:#c7d6cd;box-shadow:0 2px 8px rgba(20,40,30,.06)}
.upload-main{min-width:0;flex:1}
.upload-name{font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.upload-meta,.upload-pct{font-size:12px;color:var(--muted)}
.mini-progress{height:6px;background:var(--soft);border-radius:999px;overflow:hidden;margin:8px 0 4px}
.mini-fill{height:100%;background:var(--focus);border-radius:999px;transition:width .4s}
.upload-actions{display:flex;gap:6px;flex:none}
.empty{padding:28px;text-align:center;color:var(--muted);border:1px dashed var(--line);border-radius:12px}
.empty.error{color:#b3261e;border-color:#f3c5c0;background:#fdf5f4}
.work-head{display:flex;align-items:center;gap:16px;flex-wrap:wrap;margin-bottom:14px}
.work-title{flex:1;min-width:200px}
.work-title h1{font-size:22px;margin:0;word-break:break-all}
.work-actions{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.work-actions select{padding:9px 10px;border:1px solid var(--line);border-radius:8px;background:#fff;font-size:13px}
.progress-panel{padding:14px 20px}
.progress-label{font-weight:700;font-size:13px;margin-bottom:8px}
.progressbar{height:10px;background:var(--soft);border-radius:999px;overflow:hidden}
.progressfill,.inline-progressfill{height:100%;background:var(--focus);border-radius:999px;transition:width .4s ease}
.table-panel{padding:14px 16px}
.filterbar{display:flex;gap:12px;align-items:center;flex-wrap:wrap}
.search{padding:9px 12px;border:1px solid var(--line);border-radius:8px;font-size:13px;min-width:240px}
.seg{display:inline-flex;border:1px solid var(--line);border-radius:8px;overflow:hidden}
.seg button{border:none;border-radius:0;padding:8px 14px;background:#fff}
.seg button+button{border-left:1px solid var(--line)}
.seg button.active{background:var(--green);color:#fff}
.filterbar .status{margin-left:auto;max-width:46%;text-align:right}
.tablewrap{max-height:calc(100vh - 330px);min-height:240px}
.busy{position:fixed;inset:0;background:rgba(243,246,243,.8);backdrop-filter:blur(2px);display:flex;flex-direction:column;gap:14px;align-items:center;justify-content:center;z-index:50;font-weight:600;color:var(--green-dark)}
.spinner{width:38px;height:38px;border:4px solid var(--line);border-top-color:var(--green);border-radius:50%;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.toasts{position:fixed;right:20px;bottom:20px;display:flex;flex-direction:column;gap:8px;z-index:60}
.toast{background:#1c2622;color:#fff;padding:11px 16px;border-radius:10px;font-size:13px;max-width:380px;box-shadow:0 6px 20px rgba(0,0,0,.2);animation:toastin .2s ease;transition:opacity .3s}
.toast.error{background:#b3261e}.toast.ok{background:var(--green)}.toast.out{opacity:0}
@keyframes toastin{from{transform:translateY(8px);opacity:0}}
.modal{position:fixed;inset:0;background:rgba(20,30,25,.45);display:grid;place-items:center;z-index:40;padding:16px}
.modal[hidden],.busy[hidden],[hidden]{display:none!important}
.modal-card{background:#fff;border-radius:16px;padding:22px;width:min(720px,100%);max-height:90vh;overflow:auto}
.modal-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}
.modal-head h2{margin:0}
.stat-cards{display:flex;gap:12px;flex-wrap:wrap;margin-bottom:18px}
.stat{flex:1;min-width:130px;border:1px solid var(--line);border-radius:12px;padding:14px}
.stat-l{font-size:11px;font-weight:700;text-transform:uppercase;color:var(--muted);letter-spacing:.03em}
.stat-v{font-size:28px;font-weight:700;color:var(--green-dark)}
.bigprogress{margin-bottom:20px}.bigprogress .progressbar{margin-top:8px;height:14px}
.modal h3{font:700 15px Georgia,serif;color:var(--green-dark)}
.bars{display:flex;align-items:flex-end;gap:10px;overflow-x:auto;padding:6px 0;min-height:190px}
.bar{display:flex;flex-direction:column;align-items:center;justify-content:flex-end;min-width:44px;font-size:11px;color:var(--muted)}
.bar-n{color:var(--ink);margin-bottom:4px}.bar-fill{width:30px;background:var(--focus);border-radius:4px 4px 0 0}.bar-d{margin-top:6px;white-space:nowrap}
.error-text{color:#b3261e}
/* mapped rows get a subtle accent */
tbody tr:has(.din a){background:#fbfdfb}
/* Mapping column widths (last 7 columns: ingredient, strength, company, form, route, DIN, product) */
th:nth-last-child(7),td:nth-last-child(7){width:230px}
th:nth-last-child(6),td:nth-last-child(6){width:140px}
th:nth-last-child(5),td:nth-last-child(5){width:230px}
th:nth-last-child(4),td:nth-last-child(4){width:200px}
th:nth-last-child(3),td:nth-last-child(3){width:140px}
th:nth-last-child(2),td:nth-last-child(2){width:160px}
th:last-child,td:last-child{width:220px}
table{min-width:1700px}
/* Auth */
.appbar-right{display:flex;align-items:center;gap:14px}
.usermenu{display:flex;align-items:center;gap:10px;padding-left:14px;border-left:1px solid var(--line)}
.avatar{width:32px;height:32px;border-radius:50%;background:var(--green);color:#fff;display:grid;place-items:center;font-weight:700;font-size:13px}
.uname{font-size:13px;font-weight:600;line-height:1.2}.urole{font-size:11px;color:var(--muted);text-transform:capitalize}
@media(max-width:700px){.userinfo,.brand-sub{display:none}}
.auth{min-height:calc(100vh - 62px);display:grid;place-items:center;padding:24px}
.auth-card{width:min(400px,100%);background:#fff;border:1px solid var(--line);border-radius:16px;padding:32px 28px;box-shadow:0 8px 30px rgba(20,40,30,.08)}
.auth-logo{width:44px;height:44px;border-radius:12px;background:var(--green);color:#fff;display:grid;place-items:center;font-size:22px;font-weight:700;margin-bottom:14px}
.auth-card h1{font-size:26px;margin-bottom:4px}
.auth-card .hint{margin-bottom:18px}
.auth-card .field{margin-bottom:14px}
.auth-card .field label{margin-bottom:6px}
.auth-card input{width:100%;padding:11px 12px;border:1px solid var(--line);border-radius:8px;font-size:14px;background:#fff;color:var(--ink)}
.auth-card input:focus{outline:none;border-color:var(--focus);box-shadow:0 0 0 3px rgba(47,143,111,.15)}
.pwwrap{position:relative}.pwwrap input{padding-right:64px}
.pwwrap button{position:absolute;right:4px;top:4px;bottom:4px;padding:0 10px;font-size:12px}
.auth-error{background:#fdecea;color:#b3261e;border:1px solid #f3c5c0;border-radius:8px;padding:10px 12px;font-size:13px;margin-bottom:14px}
button.wide{width:100%;padding:12px}
.auth-switch{margin-top:18px;text-align:center;font-size:13px;color:var(--muted)}
.auth-switch a{color:var(--green);font-weight:600;text-decoration:none}.auth-switch a:hover{text-decoration:underline}
/* Admin */
.usertable{min-width:760px!important;table-layout:auto!important}
.usertable th,.usertable td{width:auto!important;white-space:nowrap}
.usertable td:nth-child(2){color:var(--muted)}
.usertable .acts{display:flex;gap:4px}
.usertable .acts button{padding:5px 10px;font-size:12px}
.rolebadge{display:inline-block;font-size:11px;font-weight:700;padding:3px 9px;border-radius:999px;background:var(--soft);color:var(--green-dark);text-transform:capitalize}
.rolebadge.admin{background:var(--green);color:#fff}
.you{font-size:11px;color:var(--muted);margin-left:6px}
.form-grid{display:flex;flex-direction:column;gap:12px}
.form-grid label{display:block;font-size:11px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.03em;margin-bottom:5px}
.form-grid input,.form-grid select{width:100%;padding:10px 12px;border:1px solid var(--line);border-radius:8px;font-size:14px;background:#fff;color:var(--ink)}
.form-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:6px}
