:root{
  --bg:#f4f7fb;
  --panel:#ffffff;
  --ink:#13202e;
  --muted:#607086;
  --line:#dbe4ef;
  --brand:#097c86;
  --brand-2:#c6372f;
  --soft:#edf8f9;
  --sidebar-width:260px;
  --content-pad:26px;
  --library-sticky-top:154px;
}
*{box-sizing:border-box}
html,body{height:100%}
body{min-height:100vh;margin:0;font-family:Arial,Helvetica,sans-serif;background:var(--bg);color:var(--ink);overflow:hidden}
button,input,select,textarea{font:inherit}
button{border:0;border-radius:6px;background:var(--brand);color:#fff;padding:11px 14px;font-weight:700;cursor:pointer}
button:hover{filter:brightness(.96)}
input,select,textarea{width:100%;border:1px solid var(--line);border-radius:6px;padding:11px 12px;background:#fff;color:var(--ink)}
textarea{min-height:86px;resize:vertical}
h1,h2,h3,p{margin-top:0}
h1{font-size:32px;margin-bottom:18px}
h2{font-size:24px;margin-bottom:6px}
h3{font-size:18px;margin-bottom:14px}
p{color:var(--muted)}
.hidden{display:none!important}
.stack{display:grid;gap:12px}
.login-shell{min-height:100vh;display:grid;place-items:center;padding:24px;background:linear-gradient(135deg,#0c2434,#0c5e66 55%,#f5f7f9)}
.login-panel{width:min(380px,100%);background:#fff;border-radius:8px;padding:34px;box-shadow:0 24px 70px rgba(3,22,31,.24)}
.brand-logo{width:190px;max-width:100%;height:auto;margin-bottom:20px;object-fit:contain}
.brand-logo.small{width:92px;margin:0;max-height:48px;object-fit:contain}
.brand-logos{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.message{min-height:18px;color:var(--brand-2);font-size:13px;margin:0}
.login-hint{font-size:12px;line-height:1.35;margin:-4px 0 0;color:var(--muted)}
.copyright-text{font-size:11px;line-height:1.35;color:var(--muted);margin:16px 0 0}
.sidebar-copy{margin:0;color:#91a9b9}
.app-shell{height:100vh;min-height:100vh;display:grid;grid-template-columns:var(--sidebar-width) 1fr;overflow:hidden}
.sidebar{position:fixed;left:0;top:0;bottom:0;width:var(--sidebar-width);background:#102333;color:#fff;padding:22px;display:flex;flex-direction:column;gap:24px;z-index:30;overflow:auto}
.brand-block{display:flex;align-items:center;gap:12px;min-height:56px}
.brand-block span{display:block;color:#a9bdcc;font-size:12px;margin-top:4px}
nav{display:grid;gap:8px}
.nav-btn,.ghost-btn{background:transparent;color:#d7e5ee;text-align:left;border:1px solid transparent}
.nav-btn.active{background:#17384c;border-color:#28586c}
.ghost-btn{border-color:#31566b;text-align:center}
nav + .sidebar-copy{margin-top:auto}
.content{grid-column:2;padding:var(--content-pad);min-width:0;height:100vh;overflow:auto}
.content.library-mode{overflow:hidden}
.library-sticky-head{position:sticky;top:0;z-index:20;background:var(--bg);padding:var(--content-pad) var(--content-pad) 6px;margin:calc(var(--content-pad) * -1) calc(var(--content-pad) * -1) 18px}
.toolbar{display:flex;align-items:end;justify-content:space-between;gap:16px;margin-bottom:18px}
.toolbar-title{min-width:0}
.library-tools{display:grid;grid-template-columns:minmax(260px,320px) auto auto;grid-template-areas:"search logo logo" "search create upload";gap:8px 10px;align-items:center;justify-content:end}
.library-tools input{grid-area:search;width:320px;max-width:42vw}
.library-company-logo{grid-area:logo;justify-self:end;max-width:150px;max-height:42px;object-fit:contain}
#libraryCreateFolderBtn{grid-area:create}
#libraryUploadBtn{grid-area:upload}
.drop-zone{border:1px dashed #8bcfd5;background:#eefafa;color:#075d66;border-radius:8px;padding:18px;margin:-6px 0 0;display:flex;align-items:center;justify-content:center;gap:10px}
.drop-zone span{color:var(--muted)}
.drop-zone.drag-over,.folder-row-wrap.drag-over{border-color:var(--brand);background:#dff7f8}
.library-layout{display:grid;grid-template-columns:260px 1fr;gap:18px;align-items:start;height:calc(100vh - var(--library-sticky-top) - 44px);min-height:0;overflow:hidden}
.folder-panel,.panel{background:var(--panel);border:1px solid var(--line);border-radius:8px;padding:16px}
.folder-panel{position:static;align-self:start;z-index:10;max-height:100%;overflow:auto}
.folder-tree-item{position:relative}
.folder-tree-item.depth-1{margin-left:22px}
.folder-tree-item.depth-2{margin-left:38px}
.folder-tree-item.depth-3{margin-left:54px}
.folder-tree-item.depth-4{margin-left:70px}
.folder-tree-item.depth-1::before,
.folder-tree-item.depth-2::before,
.folder-tree-item.depth-3::before,
.folder-tree-item.depth-4::before{content:"";position:absolute;left:-12px;top:-8px;bottom:8px;border-left:1px solid #c9d8e6}
.folder-tree-item.depth-1>.folder-row-wrap::before,
.folder-tree-item.depth-2>.folder-row-wrap::before,
.folder-tree-item.depth-3>.folder-row-wrap::before,
.folder-tree-item.depth-4>.folder-row-wrap::before{content:"";position:absolute;left:-12px;top:50%;width:12px;border-top:1px solid #c9d8e6}
.folder-row-wrap{position:relative;border:1px solid var(--line);border-radius:6px;margin-bottom:8px;background:#fff}
.folder-row-wrap.is-child{background:#fbfdff;border-color:#d7e3ee}
.folder-row{display:block;width:100%;background:#fff;color:var(--ink);border:0;text-align:left;font-weight:700;padding-right:46px}
.folder-row-wrap.is-child .folder-row{font-size:14px;padding-top:9px;padding-bottom:9px;background:#fbfdff}
.folder-row.active{background:var(--soft);border-color:#7bc4ca;color:#065c64}
.folder-row-wrap.is-child .folder-row.active{background:#eefafa}
.folder-menu-btn{position:absolute;right:6px;top:6px}
.document-table-wrap{min-width:0;max-height:100%;background:#fff;border:1px solid var(--line);border-radius:8px;overflow:auto}
.document-browser-bar{position:sticky;top:0;z-index:14;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 12px;border-bottom:1px solid var(--line);background:#f8fbfe;border-radius:8px 8px 0 0}
.browser-nav-group,.selection-tools{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.selection-tools{justify-content:flex-end}
.select-all{display:inline-flex;align-items:center;gap:6px;font-size:13px;font-weight:700;color:var(--muted)}
.select-all input,.select-cell input{width:auto}
.selection-count{font-size:12px;color:var(--muted);white-space:nowrap}
.select-cell{width:42px;text-align:center}
.doc-nav-btn{width:36px;height:32px;padding:0;background:#fff;color:var(--ink);border:1px solid var(--line);font-size:18px;line-height:1}
button:disabled,.doc-nav-btn:disabled{opacity:.42;cursor:not-allowed;filter:none}
.document-table{width:100%;border-collapse:separate;border-spacing:0}
.document-table thead th{position:sticky;top:53px;z-index:13}
.document-table th{font-size:12px;text-transform:uppercase;color:var(--muted);letter-spacing:.04em;text-align:left;background:#f8fbfe;border-bottom:1px solid var(--line);padding:12px}
.document-table td{border-bottom:1px solid var(--line);padding:12px;vertical-align:middle}
.document-table tr:last-child td{border-bottom:0}
.document-row[draggable="true"]{cursor:grab}
.document-open-row{cursor:pointer}
.document-row:hover td{background:#f9fcff}
.folder-content-row{cursor:pointer}
.file-name{font-weight:800;color:var(--ink);overflow-wrap:anywhere}
.folder-name-cell{display:flex;align-items:center;gap:9px}
.folder-icon{display:inline-flex;align-items:center;border:1px solid #b9e0e4;background:#edf8f9;color:#075d66;border-radius:5px;padding:3px 7px;font-size:11px;font-weight:800}
.file-description{font-size:12px;color:var(--muted);margin-top:4px;overflow-wrap:anywhere}
.empty-list{padding:16px}
.actions-cell{position:relative;width:54px;text-align:right}
.row-menu-btn{background:#fff;color:var(--ink);border:1px solid var(--line);border-radius:999px;padding:5px 9px;line-height:1;font-size:18px;font-weight:800}
.row-menu{position:absolute;right:8px;top:38px;min-width:170px;background:#fff;border:1px solid var(--line);border-radius:8px;box-shadow:0 14px 36px rgba(15,35,50,.18);padding:6px;z-index:10;text-align:left}
.folder-row-wrap .row-menu{top:36px}
.row-menu button,.row-menu a{display:block;width:100%;background:#fff;color:var(--ink);border:0;border-radius:6px;padding:9px 10px;text-decoration:none;text-align:left;font-weight:700;font-size:13px}
.row-menu button:hover,.row-menu a:hover{background:#edf8f9}
.danger{background:var(--brand-2)}
.modal-overlay{position:fixed;inset:0;background:rgba(10,24,34,.62);display:grid;place-items:center;padding:20px;z-index:20}
.modal-panel{width:min(520px,100%);background:#fff;border-radius:8px;border:1px solid var(--line);padding:18px;box-shadow:0 24px 70px rgba(0,0,0,.24)}
.modal-head{display:flex;align-items:center;justify-content:space-between;gap:12px}
.modal-head h3{margin:0}
.modal-head p{margin:5px 0 0}
.field-label{display:grid;gap:7px;font-size:13px;font-weight:700;color:var(--muted)}
.modal-actions{display:flex;justify-content:flex-end;gap:10px}
.icon-btn,.ghost-light{background:#fff;color:var(--ink);border:1px solid var(--line)}
.button-link{display:inline-flex;align-items:center;justify-content:center;border-radius:6px;background:var(--brand);color:#fff;padding:11px 14px;font-weight:700;text-decoration:none}
.preview-panel{width:min(980px,94vw);height:min(760px,90vh);display:grid;grid-template-rows:auto 1fr auto;gap:14px}
.preview-frame{width:100%;height:100%;border:1px solid var(--line);border-radius:8px;background:#fff}
.preview-empty{display:grid;place-items:center;align-content:center;gap:8px;border:1px solid var(--line);border-radius:8px;background:#f8fbfe;color:var(--muted);text-align:center;padding:30px}
.floating-upload{position:fixed;right:24px;bottom:24px;z-index:12;border-radius:999px;padding:14px 18px;box-shadow:0 14px 36px rgba(9,124,134,.28)}
.admin-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin-bottom:16px}
.table-list{display:grid;gap:8px}
.table-row{display:grid;grid-template-columns:minmax(180px,1fr) auto auto auto auto auto auto auto;gap:10px;align-items:center;padding:10px 0;border-top:1px solid var(--line)}
.company-row{grid-template-columns:minmax(220px,1fr) minmax(160px,auto) auto auto auto auto auto}
.logo-strip{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:12px}
.logo-strip img{width:52px;height:34px;object-fit:contain;border:1px solid var(--line);border-radius:6px;background:#fff;padding:3px}
.table-row:first-child{border-top:0}
.role-chip{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:4px 8px;font-size:12px;color:var(--muted)}
.tiny-action{background:#edf8f9;color:#075d66;border:1px solid #b9e0e4;border-radius:6px;padding:7px 10px;font-size:12px}
.danger-lite{background:#fff4f3;color:#a62b25;border-color:#efc5c1}
.permission-list{display:grid;gap:8px;max-height:58vh;overflow:auto;padding-right:4px}
.permission-bulk{display:grid;grid-template-columns:1fr 1fr 150px auto;gap:8px;align-items:center}
.permission-row{display:grid;grid-template-columns:1fr 150px;gap:10px;align-items:center;border:1px solid var(--line);border-radius:6px;padding:10px}
.permission-row select{padding:8px 10px}
.log-panel{padding:0;overflow-x:auto}
.log-table{min-width:920px}
.log-table td{font-size:13px}
.narrow{max-width:520px}
.toast{position:fixed;right:22px;bottom:22px;background:#102333;color:#fff;border-radius:8px;padding:13px 16px;box-shadow:0 14px 40px rgba(0,0,0,.22)}
@media(max-width:980px){
  :root{--library-sticky-top:0px}
  .app-shell{grid-template-columns:1fr}
  .sidebar{position:static;width:auto;max-height:none}
  .content{grid-column:1;padding:18px}
  .library-sticky-head{position:static;margin:0 0 18px;padding:0;background:transparent}
  .library-layout,.admin-grid{grid-template-columns:1fr}
  .folder-panel{position:static;max-height:none}
  .toolbar{display:grid;align-items:start}
  .library-tools{display:grid;width:100%;grid-template-columns:1fr;grid-template-areas:"logo" "search" "create" "upload";justify-content:stretch}
  .library-tools input{width:100%;max-width:none}
  .library-company-logo{justify-self:start}
  .floating-upload{right:14px;bottom:14px}
  .document-table-wrap{overflow-x:auto}
  .document-table{min-width:720px}
  .document-browser-bar{position:static;align-items:flex-start;display:grid}
  .selection-tools{justify-content:flex-start}
  .permission-bulk{grid-template-columns:1fr}
}
