:root{
  --bg:#f5f7fb;
  --surface:#ffffff;
  --surface-soft:#fbfcfe;
  --border:#dbe3ee;
  --border-strong:#c9d6e6;
  --text:#101828;
  --muted:#667085;
  --green:#0f7a4c;
  --green-soft:#edf8f2;
  --gold:#f2b705;
  --danger:#b42318;
  --danger-soft:#fff1f1;
  --shadow:0 18px 40px rgba(16,24,40,.07);
  --shadow-soft:0 8px 20px rgba(16,24,40,.05);
  --radius-xl:24px;
  --radius-lg:18px;
  --radius-md:14px;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  min-height:100vh;
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at top left, rgba(242,183,5,.10), transparent 18%),
    radial-gradient(circle at bottom right, rgba(15,122,76,.10), transparent 22%),
    linear-gradient(180deg,#f7f9fc 0%,#eef3f8 100%);
}
button,input,select,textarea{font:inherit}
button{cursor:pointer}
a{text-decoration:none;color:inherit}
.hidden{display:none !important}
h1,h2,h3,h4,p{margin:0}
h1{font-size:clamp(1.8rem,2.7vw,2.7rem);line-height:1.05;font-weight:900}
h2{font-size:1.6rem;font-weight:800;line-height:1.1}
h3{font-size:1.12rem;font-weight:800;line-height:1.2}
.eyebrow{margin:0 0 .35rem;font-size:.72rem;font-weight:900;letter-spacing:.26em;color:var(--green);text-transform:uppercase}
.muted{color:var(--muted)}
.small{font-size:.9rem}
.help-text{display:block;margin-top:.45rem;color:var(--muted);font-size:.85rem}
.form-message,.modal-error{min-height:1.2rem;font-size:.95rem}
.card{background:rgba(255,255,255,.86);border:1px solid rgba(219,227,238,.95);border-radius:var(--radius-xl);box-shadow:var(--shadow);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px)}
.page-glow{position:fixed;pointer-events:none;filter:blur(50px);opacity:.45;z-index:0}
.glow-a{top:-80px;left:-20px;width:280px;height:280px;border-radius:999px;background:rgba(242,183,5,.18)}
.glow-b{right:-30px;bottom:-70px;width:320px;height:320px;border-radius:999px;background:rgba(15,122,76,.14)}

.login-shell{position:relative;z-index:1;min-height:100vh;padding:2rem;display:grid;grid-template-columns:1.1fr .9fr;gap:2rem;align-items:center}
.login-panel,.login-form-card{padding:2rem}
.login-brand{display:flex;gap:1.2rem;align-items:flex-start;margin-bottom:1.5rem}
.brand-logo{width:88px;height:auto;object-fit:contain;filter:drop-shadow(0 10px 18px rgba(16,24,40,.12))}
.brand-logo.small{width:54px}
.lead{font-size:1rem;line-height:1.6;color:var(--muted)}
.feature-grid{display:grid;gap:.9rem}
.feature-tile{padding:1rem 1.1rem;border:1px solid var(--border);border-radius:18px;background:var(--surface-soft)}
.feature-tile strong{display:block;margin-bottom:.3rem}
.form-stack{display:flex;flex-direction:column;gap:1rem}
label,.input-with-label{display:block}
label span,.input-with-label span{display:block;font-size:.9rem;font-weight:700;color:#344054;margin-bottom:.45rem}
input,select,textarea{width:100%;padding:.9rem 1rem;border:1px solid var(--border-strong);border-radius:15px;background:#fff;outline:none;transition:border-color .18s ease, box-shadow .18s ease}
textarea{resize:vertical;min-height:120px}
input:focus,select:focus,textarea:focus{border-color:rgba(15,122,76,.55);box-shadow:0 0 0 4px rgba(15,122,76,.12)}

.btn{border:none;border-radius:999px;padding:.86rem 1.08rem;font-weight:800;line-height:1;transition:transform .16s ease, box-shadow .16s ease, background .16s ease}
.btn:hover{transform:translateY(-1px)}
.btn:disabled{opacity:.7;cursor:not-allowed;transform:none}
.btn-block{width:100%}
.btn-primary{background:linear-gradient(135deg,var(--green),#16a363);color:#fff;box-shadow:0 12px 26px rgba(15,122,76,.18)}
.btn-secondary{background:#fff;color:var(--text);border:1px solid var(--border)}
.btn-danger{background:var(--danger-soft);color:var(--danger);border:1px solid #f3cccc}
.btn-small{padding:.65rem .88rem;font-size:.86rem}
.icon-btn{width:40px;height:40px;border-radius:999px;border:1px solid var(--border);background:#fff;color:var(--text);font-size:1.45rem;line-height:1}
.icon-btn.small{width:32px;height:32px;font-size:1rem}

.app-shell{position:relative;z-index:1;min-height:100vh;padding:1.3rem;display:grid;grid-template-columns:320px 1fr;gap:1rem}
.sidebar{padding:1.1rem;display:flex;flex-direction:column;gap:1rem;align-self:start;position:sticky;top:1.3rem}
.brand-row{display:flex;align-items:center;gap:.9rem}
.sidebar-title{font-size:1.35rem}
.identity-card{padding:1rem;border:1px solid var(--border);border-radius:18px;background:linear-gradient(180deg,#fff,#f8fbfd)}
.identity-label{font-size:.76rem;text-transform:uppercase;letter-spacing:.12em;color:var(--muted);margin-bottom:.25rem}
.sidebar-section{display:flex;flex-direction:column;gap:.8rem}
.stack-list{display:flex;flex-direction:column;gap:.65rem}
.project-item{width:100%;text-align:left;border:1px solid var(--border);background:linear-gradient(180deg,#fff 0%,#fbfdff 100%);border-radius:18px;padding:.9rem;transition:transform .16s ease, box-shadow .16s ease, border-color .16s ease}
.project-item:hover{transform:translateY(-1px);box-shadow:var(--shadow-soft)}
.project-item.active{border-color:rgba(15,122,76,.42);box-shadow:0 0 0 4px rgba(15,122,76,.10)}
.project-item-top{display:flex;justify-content:space-between;gap:.6rem;align-items:flex-start}
.project-name{font-size:.98rem;font-weight:800;margin-bottom:.15rem}
.project-desc{font-size:.85rem;color:var(--muted);line-height:1.4}
.project-foot{margin-top:.55rem;font-size:.82rem;color:var(--muted)}

.content-shell{display:flex;flex-direction:column;gap:1rem;min-width:0}
.topbar{padding:1.25rem 1.35rem;display:flex;justify-content:space-between;gap:1rem;align-items:flex-start}
.action-bar{display:flex;flex-wrap:wrap;gap:.65rem;justify-content:flex-end}
.project-strip{padding:1rem 1.2rem;display:flex;justify-content:space-between;gap:1rem;align-items:flex-end;flex-wrap:wrap}
.project-strip-left{display:flex;flex-direction:column;gap:.7rem}
.toolbar-inline{display:flex;gap:.8rem;align-items:flex-end;flex:1;justify-content:flex-end;min-width:340px}
.toolbar-inline .grow{flex:1;min-width:220px}
.toolbar-inline .narrow{width:220px}
.section-head{display:flex;justify-content:space-between;gap:1rem;align-items:flex-start;margin-bottom:.9rem}
.section-head.compact{align-items:center;margin-bottom:.8rem}
.section-head.align-start{align-items:flex-start}
.header-inline-actions{display:flex;align-items:center;gap:.6rem}
.count-pill{display:inline-flex;align-items:center;justify-content:center;min-width:36px;height:36px;padding:0 .68rem;border-radius:999px;background:var(--green-soft);color:var(--green);font-size:.84rem;font-weight:900;border:1px solid rgba(15,122,76,.12)}
.neutral-pill{background:#eef2f6;color:#475467;border-color:#d7dee6}
.status-badge{display:inline-flex;align-items:center;justify-content:center;padding:.48rem .76rem;border-radius:999px;font-size:.82rem;font-weight:800;border:1px solid transparent}
.status-badge.aktiv{background:var(--green-soft);color:var(--green);border-color:rgba(15,122,76,.15)}
.status-badge.planung{background:#fff7e8;color:#9a6700;border-color:#eed49b}
.status-badge.archiv{background:#eef2f6;color:#475467;border-color:#d7dee6}
.status-badge.neutral{background:#f5f7fa;color:#667085;border-color:#dde3ea}
.meta-row{display:flex;flex-wrap:wrap;gap:.55rem}
.meta-chip{display:inline-flex;align-items:center;gap:.45rem;border:1px solid var(--border);border-radius:999px;background:#f8fafc;padding:.48rem .72rem;font-size:.83rem;font-weight:700;color:#344054}

.workspace-grid.clean-layout{display:grid;grid-template-columns:280px minmax(480px,1fr) minmax(360px,1fr);gap:1rem;align-items:start}
.panel{padding:1.1rem;min-height:420px}
.folder-tree{display:flex;flex-direction:column;gap:.45rem}
.folder-row{display:flex;align-items:center;justify-content:space-between;gap:.6rem;padding:.7rem .8rem;border:1px solid var(--border);border-radius:16px;background:#fff;transition:background .16s ease,border-color .16s ease,box-shadow .16s ease}
.folder-row:hover{box-shadow:var(--shadow-soft)}
.folder-row.active{border-color:rgba(15,122,76,.42);box-shadow:0 0 0 4px rgba(15,122,76,.10);background:#fcfffd}
.folder-main{display:flex;align-items:center;gap:.6rem;min-width:0;flex:1}
.folder-label{display:flex;flex-direction:column;min-width:0}
.folder-name{font-weight:800;font-size:.95rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.folder-size{font-size:.82rem;color:var(--muted)}
.folder-indent{display:inline-block;width:16px;flex:none}
.folder-toggle{font-size:.92rem;color:var(--muted)}
.folder-actions{display:flex;gap:.35rem;align-items:center}

.bulk-bar{margin-bottom:.8rem;padding:.75rem .9rem;border-radius:16px;background:#f8fafc;border:1px solid var(--border);display:flex;justify-content:space-between;gap:1rem;align-items:center;flex-wrap:wrap}
.file-table{border:1px solid var(--border);border-radius:18px;overflow:hidden;background:#fff}
.file-table-head,.file-row{display:grid;grid-template-columns:50px minmax(180px,2fr) minmax(120px,1.3fr) 110px 110px minmax(190px,1.6fr);gap:.8rem;align-items:center}
.file-table-head{padding:.85rem 1rem;background:#f8fafc;border-bottom:1px solid var(--border);font-size:.84rem;font-weight:800;color:#475467}
.file-row{padding:.9rem 1rem;border-bottom:1px solid #eef2f6;cursor:pointer}
.file-row:last-child{border-bottom:none}
.file-row:hover{background:#fbfdff}
.file-row.active{background:#f7fbf8}
.file-name{font-weight:800;font-size:.95rem;word-break:break-word}
.file-sub{font-size:.84rem;color:var(--muted);word-break:break-word;margin-top:.18rem}
.file-folder-path{font-size:.88rem;color:#344054;word-break:break-word}
.file-actions{display:flex;flex-wrap:wrap;gap:.45rem;justify-content:flex-end}
.file-actions .btn{white-space:nowrap}
.file-empty{padding:1rem}
.tag{display:inline-flex;align-items:center;border-radius:999px;padding:.3rem .6rem;background:#f8fafc;border:1px solid var(--border);font-size:.76rem;font-weight:700;color:#475467}

.preview-panel{display:flex;flex-direction:column}
.preview-meta{margin-top:-.3rem;margin-bottom:.8rem}
.inline-preview{flex:1;min-height:560px;border:1px solid var(--border);border-radius:18px;background:#f8fafc;overflow:hidden;display:flex}
.inline-preview.empty{display:grid;place-items:center;background:linear-gradient(180deg,#fbfdff,#f6f9fc)}
.preview-placeholder{text-align:center;padding:2rem;max-width:310px}
.preview-placeholder-icon{font-size:3rem;margin-bottom:.9rem}
.inline-preview iframe{width:100%;height:100%;border:none;background:#fff}
.preview-fallback{display:grid;place-items:center;width:100%;padding:2rem;text-align:center}
.preview-fallback .btn{display:inline-flex;margin-top:1rem}

.empty-state{padding:1rem;border-radius:18px;border:1px dashed var(--border-strong);background:linear-gradient(180deg,#fcfdff,#f7fafc)}
.empty-state strong{display:block;margin-bottom:.35rem}
.modal-dialog{border:none;padding:0;background:transparent}
.modal-dialog::backdrop{background:rgba(16,24,40,.45);backdrop-filter:blur(3px)}
.modal-card{width:min(760px,92vw);overflow:hidden}
.modal-head,.modal-actions{padding:1.1rem 1.25rem;display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}
.modal-head{border-bottom:1px solid var(--border)}
.modal-body{padding:1.25rem;display:flex;flex-direction:column;gap:1rem}
.modal-actions{border-top:1px solid var(--border);justify-content:flex-end;align-items:center}
.modal-error{padding:0 1.25rem;color:var(--danger)}
.grid-two{display:grid;grid-template-columns:1fr 1fr;gap:1rem}

@media (max-width: 1380px){
  .workspace-grid.clean-layout{grid-template-columns:260px 1fr}
  .preview-panel{grid-column:1 / -1}
  .inline-preview{min-height:480px}
}
@media (max-width: 1160px){
  .app-shell{grid-template-columns:1fr}
  .sidebar{position:relative;top:0}
}
@media (max-width: 960px){
  .login-shell{grid-template-columns:1fr;padding:1rem}
  .topbar,.project-strip{flex-direction:column;align-items:flex-start}
  .toolbar-inline{width:100%;min-width:0;justify-content:stretch;flex-direction:column}
  .toolbar-inline .narrow,.toolbar-inline .grow{width:100%;min-width:0}
  .workspace-grid.clean-layout{grid-template-columns:1fr}
}
@media (max-width: 820px){
  .file-table-head{display:none}
  .file-row{grid-template-columns:34px 1fr;gap:.75rem}
  .file-row > .file-col-folder,.file-row > .file-col-size,.file-row > .file-col-date,.file-row > .file-col-actions{grid-column:2}
  .file-actions{justify-content:flex-start;margin-top:.5rem}
}
@media (max-width: 720px){
  .app-shell{padding:1rem}
  .action-bar{width:100%;justify-content:stretch}
  .action-bar .btn{flex:1 1 calc(50% - .5rem)}
  .grid-two{grid-template-columns:1fr}
}
@media (max-width: 520px){
  .login-panel,.login-form-card,.sidebar,.topbar,.project-strip,.panel{padding:1rem}
  .action-bar .btn{flex:1 1 100%}
  .file-actions .btn{flex:1 1 100%}
  .modal-head,.modal-body,.modal-actions{padding:1rem}
}

/* v6: saubere Dateiliste, volle Vorschau und keine abgeschnittenen Spalten */
.workspace-grid.clean-layout{
  grid-template-columns:280px minmax(0,1fr) !important;
  align-items:start;
}
.preview-panel{
  grid-column:1 / -1 !important;
}
.inline-preview{
  min-height:720px !important;
}
.file-table{
  overflow:visible !important;
}
.file-table-head,
.file-row{
  grid-template-columns:42px minmax(240px,2.4fr) minmax(160px,1.15fr) 95px 105px minmax(270px,1.55fr) !important;
  gap:.85rem !important;
}
.file-table-head > div,
.file-row > div{
  min-width:0;
}
.file-table-head{
  position:sticky;
  top:0;
  z-index:1;
}
.file-row{
  min-height:86px;
}
.file-name{
  word-break:normal !important;
  overflow-wrap:anywhere;
  line-height:1.25;
}
.file-sub{
  overflow-wrap:anywhere;
  line-height:1.35;
}
.file-folder-path{
  overflow-wrap:anywhere;
  line-height:1.35;
}
.file-col-size,.file-col-date{
  white-space:nowrap;
  color:#475467;
  font-weight:700;
  font-size:.9rem;
}
.file-actions{
  justify-content:flex-start !important;
  flex-wrap:wrap;
}
.file-actions .btn{
  padding:.62rem .78rem;
}
.file-empty{
  padding:1rem !important;
}
.file-empty .empty-state{
  width:100%;
}
@media (max-width: 1280px){
  .workspace-grid.clean-layout{grid-template-columns:1fr !important;}
  .preview-panel{grid-column:1 !important;}
}
@media (max-width: 920px){
  .file-table-head{display:none !important;}
  .file-row{grid-template-columns:34px minmax(0,1fr) !important;align-items:start;}
  .file-row > div:not(.file-col-check):not(.file-col-name){grid-column:2;}
  .file-col-folder::before{content:'Ordner: ';font-weight:800;color:#344054;}
  .file-col-size::before{content:'Größe: ';font-weight:800;color:#344054;}
  .file-col-date::before{content:'Datum: ';font-weight:800;color:#344054;}
  .file-actions{margin-top:.3rem;}
}

/* V7: echte PDF-Canvas-Vorschau statt Browser-iframe */
.preview-panel{
  min-height:calc(100vh - 180px);
}
.inline-preview{
  min-height:calc(100vh - 285px) !important;
  height:calc(100vh - 285px) !important;
  background:#eef2f6;
}
.pdf-render-shell{
  width:100%;
  height:100%;
  display:flex;
  flex-direction:column;
  background:#eef2f6;
}
.pdf-render-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
  padding:.75rem 1rem;
  border-bottom:1px solid var(--border);
  background:#fff;
  flex:0 0 auto;
}
.pdf-pages{
  flex:1;
  overflow:auto;
  padding:1.25rem;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:1.25rem;
  background:#dfe5ec;
}
.pdf-page-box{
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:.5rem;
}
.pdf-page-label{
  align-self:flex-start;
  color:#475467;
  font-size:.82rem;
  font-weight:800;
  background:#fff;
  border:1px solid var(--border);
  border-radius:999px;
  padding:.35rem .65rem;
}
.pdf-page-box canvas{
  display:block;
  max-width:100%;
  height:auto !important;
  background:#fff;
  box-shadow:0 10px 28px rgba(16,24,40,.18);
}
.image-preview-wrap{
  width:100%;
  height:100%;
  overflow:auto;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding:1rem;
  background:#eef2f6;
}
.image-preview-wrap img{
  max-width:100%;
  height:auto;
  background:#fff;
  box-shadow:0 10px 28px rgba(16,24,40,.16);
}
@media (max-width: 960px){
  .inline-preview{
    height:70vh !important;
    min-height:520px !important;
  }
}

/* V8: Upload-Fortschritt, begrenzte Strukturhöhe und Doppelklick-Vorschau */
.folders-panel{
  max-height:calc(100vh - 210px);
  overflow:auto;
}
.folder-tree{
  padding-right:.2rem;
}
.upload-progress{
  margin-top:.35rem;
  padding:1rem;
  border:1px solid var(--border);
  border-radius:18px;
  background:#f8fafc;
}
.upload-progress-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
  margin-bottom:.65rem;
}
.upload-progress-track{
  height:12px;
  border-radius:999px;
  background:#e4eaf2;
  overflow:hidden;
  border:1px solid #d5dee9;
}
.upload-progress-bar{
  width:0%;
  height:100%;
  border-radius:999px;
  background:linear-gradient(135deg,var(--green),#16a363);
  transition:width .18s ease;
}
#uploadProgressText{
  margin-top:.55rem;
}
.file-row{
  user-select:none;
}
.file-row::after{
  content:'Doppelklick öffnet Vorschau';
  display:none;
  grid-column:2 / -1;
  color:var(--muted);
  font-size:.78rem;
  margin-top:-.25rem;
}
.file-row:hover::after{
  display:block;
}
.preview-panel{
  scroll-margin-top:1rem;
}
@media (max-width: 1380px){
  .folders-panel{max-height:420px;}
}
@media (max-width: 960px){
  .folders-panel{max-height:360px;}
}

/* V9: PDF-Vorschau mit Scrollbereich und Zoom +/- */
.pdf-render-toolbar{
  flex-wrap:wrap;
  gap:.75rem;
}
.pdf-toolbar-actions{
  display:flex;
  align-items:center;
  gap:.45rem;
  flex-wrap:wrap;
}
.pdf-zoom-label{
  min-width:58px;
  text-align:center;
  font-weight:900;
  color:#344054;
  padding:.55rem .65rem;
  border:1px solid var(--border);
  border-radius:999px;
  background:#f8fafc;
}
.pdf-pages{
  overflow:auto !important;
  align-items:flex-start !important;
  padding:1rem !important;
}
.pdf-page-box{
  min-width:100%;
  width:max-content;
  align-items:center;
}
.pdf-page-box canvas{
  max-width:none !important;
  margin:0 auto;
}
.pdf-loading{
  margin:1rem;
  font-weight:800;
  color:#344054;
}
.inline-preview{
  height:calc(100vh - 255px) !important;
  min-height:640px !important;
}
@media (max-width: 960px){
  .inline-preview{
    height:72vh !important;
    min-height:520px !important;
  }
  .pdf-render-toolbar{
    align-items:flex-start;
  }
}
