/* FileShare UI · css/theme.css · Modern theme: header, tenant chip, dashboard, charts, tenants, work tasks, QR, watermark, AI tables. Loaded in the order listed in index.html. */
/* =====================================================================
   FileShare 2026 theme: modern surfaces, gradients, soft depth
   ===================================================================== */
:root {
  --tenant: var(--brand);
  --grad: linear-gradient(120deg, #0B4F6C 0%, #0E7C86 45%, #3A5BA8 100%);
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-md: 0 6px 18px rgba(16,24,40,.08), 0 2px 6px rgba(16,24,40,.05);
  --shadow-lg: 0 24px 48px rgba(16,24,40,.18);
  --radius: 12px;
}
body { background: #F4F6FA; }

/* header */
.appbar { background: #fff; box-shadow: var(--shadow-sm); border-bottom: 0; position: relative; z-index: 5; }
.appbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 3px; background: var(--grad); opacity: .9; }
.logo-text b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-action { border-radius: 10px; transition: background .15s, transform .15s; }
.top-action:hover { background: #EEF4F8; transform: translateY(-1px); }
.quick-search input { border-radius: 22px !important; background: #F4F6FA; border: 1px solid #E3E8EE !important; transition: box-shadow .2s, background .2s; }
.quick-search input:focus { background: #fff; box-shadow: 0 0 0 4px rgba(var(--brand-rgb),.15); outline: none; }
.welcome { background: linear-gradient(90deg, #FFF7D6, #FFFBEA) !important; border-bottom: 1px solid #F3E6A8; }

/* department chip */
.tenant-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid #E3E8EE; background: #fff; border-radius: 20px; padding: 6px 14px 6px 10px;
  font: 500 13px Roboto, sans-serif; color: var(--ink); cursor: default; box-shadow: var(--shadow-sm); white-space: nowrap; max-width: 240px; }
.tenant-chip.switchable { cursor: pointer; } .tenant-chip.switchable:hover { border-color: var(--tenant); }
.tenant-chip #tenant-name { overflow: hidden; text-overflow: ellipsis; }
.tdot2 { width: 10px; height: 10px; border-radius: 50%; background: var(--tenant); display: inline-block; flex: none; box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
.menu .menu-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 12px 2px; }
.menu button.current { font-weight: 600; background: #F1F7F8; }
.menu button .tdot2 { margin-right: 8px; }

/* panels, grids, buttons */
.btn { border-radius: 8px; transition: transform .12s, box-shadow .12s, background .12s; }
.btn-primary { background: var(--grad) !important; border-color: transparent !important; box-shadow: 0 4px 12px rgba(var(--brand-rgb),.25); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(var(--brand-rgb),.3); }
.grid thead th { background: #F1F4F8; color: #44505C; font-weight: 600; }
.grid tbody tr { transition: background .1s; }
.win-head, .dialog > header, .dialog .dialog-head { background: var(--grad) !important; }
dialog { border-radius: 14px; box-shadow: var(--shadow-lg); border: 0; }
dialog::backdrop { background: rgba(15,23,42,.45); backdrop-filter: blur(3px); }
.rail-btn[aria-current="true"] { background: linear-gradient(180deg, #FFF6C9, #FFE98A) !important; border-radius: 10px; }
.badge { background: linear-gradient(135deg, #FF5A4E, #E0463A) !important; box-shadow: 0 2px 6px rgba(224,70,58,.4); }

/* login */
.login-story { background: var(--grad) !important; position: relative; overflow: hidden; }
.login-story::after { content: ""; position: absolute; width: 520px; height: 520px; right: -160px; bottom: -180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.18), transparent 65%); animation: floaty 9s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translate(-30px, -24px) scale(1.06); } }
.login-panel { background: #fff; }
.login-form { background: #fff; border-radius: 18px; box-shadow: var(--shadow-md); padding: 34px 32px !important; }
.login-btn { background: var(--grad) !important; border-radius: 10px !important; box-shadow: 0 8px 20px rgba(var(--brand-rgb),.3); }

/* ---------------- dashboard */
.dash { width: min(1360px, 96vw); max-width: none; height: 92vh; padding: 0; background: #F4F6FA; }
.dash-wrap { height: 100%; overflow: auto; }
.dash-body { padding: 0 22px 22px; }
.dash-loading { padding: 80px; text-align: center; color: var(--muted); display: flex; gap: 10px; justify-content: center; align-items: center; }
.dash-hero { margin: 0 -22px 18px; padding: 26px 30px 54px; background: var(--grad); color: #fff; display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  border-radius: 14px 14px 0 0; position: relative; overflow: hidden; }
.dash-hero::after { content: ""; position: absolute; right: -80px; top: -120px; width: 380px; height: 380px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.16), transparent 60%); }
.dash-hello { font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.dash-sub { opacity: .9; margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.dash-sub .tdot2 { box-shadow: 0 0 0 3px rgba(255,255,255,.35); background: #fff !important; }
.dash-quick { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; }
.qbtn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.14); color: #fff;
  border-radius: 10px; padding: 9px 14px; font: 500 13.5px Roboto, sans-serif; cursor: pointer; backdrop-filter: blur(4px); transition: background .15s, transform .15s; }
.qbtn:hover { background: rgba(255,255,255,.26); transform: translateY(-1px); }
.qbtn .ic { width: 17px; height: 17px; color: #fff; }
.qbtn.ai { background: #fff; color: #3B2E6E; } .qbtn.ai .ic { color: #7B5CC4; }
.qbtn.ghost { padding: 9px 12px; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-top: -48px; position: relative; z-index: 2; }
.kpi { background: #fff; border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow-md);
  transition: transform .15s, box-shadow .15s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi b { display: block; font-size: 22px; line-height: 1.1; color: #101828; }
.kpi span { display: block; font-size: 12.5px; color: #475467; font-weight: 500; }
.kpi small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.kpi-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.kpi-ic .ic { width: 22px; height: 22px; color: #fff; }
.k1 .kpi-ic { background: linear-gradient(135deg, var(--brand), #22A8B3); } .k2 .kpi-ic { background: linear-gradient(135deg, #2F7FD0, #5CA4EE); }
.k3 .kpi-ic { background: linear-gradient(135deg, #1EA672, #45C792); } .k4 .kpi-ic { background: linear-gradient(135deg, #7B5CC4, #A387E8); }
.k5 .kpi-ic { background: linear-gradient(135deg, #E0463A, #FF7A6E); } .k6 .kpi-ic { background: linear-gradient(135deg, #E08A1E, #F5B451); }
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.card { background: #fff; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); border: 1px solid #EDF0F4; min-width: 0; }
.card.span2 { grid-column: span 2; }
.card > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.card h3 { margin: 0; font-size: 14.5px; font-weight: 600; color: #1D2939; flex: 1; }
.chart { width: 100%; height: auto; }
.chart .gl { stroke: #EEF1F5; } .chart .bv { font-size: 11px; text-anchor: middle; fill: #344054; font-weight: 600; }
.chart .bl { font-size: 10.5px; text-anchor: middle; fill: #98A2B3; }
.chart rect { transition: opacity .15s; } .chart rect:hover { opacity: .8; }
.donut { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 10px; position: relative; }
.donut svg { width: 150px; height: 150px; }
.donut-mid { position: absolute; left: 0; width: 150px; text-align: center; pointer-events: none; }
.donut-mid b { display: block; font-size: 22px; } .donut-mid span { font-size: 11.5px; color: var(--muted); }
.donut ul { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.donut li { display: flex; align-items: center; gap: 8px; padding: 3px 0; } .donut li span { width: 10px; height: 10px; border-radius: 3px; }
.donut li b { margin-left: auto; font-weight: 600; }
.perf { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 10px; }
.perf-col { background: #F6F8FB; border-radius: 10px; padding: 9px 10px; text-align: center; }
.perf-col span { display: block; font-size: 11.5px; color: var(--muted); } .perf-col b { font-size: 21px; }
.perf-col.due { background: #EAF4FF; } .perf-col.due b { color: #2F7FD0; }
.perf-col.over { background: #FDECEA; } .perf-col.over b { color: #D92D20; }
.perf-col.done { background: #E9F7EF; } .perf-col.done b { color: #1EA672; }
.tlist, .dlist, .alist { list-style: none; margin: 0; padding: 0; }
.tlist li, .dlist li, .alist li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; }
.tlist li + li, .dlist li + li, .alist li + li { border-top: 1px solid #F1F3F6; }
.dlist li[data-doc], .dlist li[data-folder] { cursor: pointer; } .dlist li[data-doc]:hover, .dlist li[data-folder]:hover { background: #F6F9FC; }
.tlist li > div, .dlist li > div, .alist li > div { min-width: 0; flex: 1; }
.tlist b, .dlist b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tlist small, .dlist small, .alist small { display: block; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tlist li.over b { color: #B42318; } .tlist li.done { opacity: .5; text-decoration: line-through; }
.tlist input { width: 17px; height: 17px; accent-color: #1EA672; }
.li-empty, .tlist .empty, .dlist .empty, .alist .empty { color: var(--muted); justify-content: center; padding: 18px; }
.dlist .ic { width: 22px; height: 22px; flex: none; }
.av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: #fff; font-weight: 600; font-size: 13px; flex: none; }
.prio { font-size: 11px; padding: 2px 8px; border-radius: 10px; text-transform: capitalize; background: #EEF1F5; color: #475467; white-space: nowrap; }
.prio.high { background: #FFF1E0; color: #B54708; } .prio.urgent { background: #FDECEA; color: #B42318; } .prio.low { background: #EEF6FF; color: #175CD3; }
.tagcloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tagc { border: 0; background: #F1F7F8; color: var(--tenant); border-radius: 14px; padding: 3px 10px; cursor: pointer; }
.tagc small { margin-left: 5px; color: var(--muted); font-size: 10.5px; } .tagc:hover { background: #E1F0F2; }
.dash-start { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; color: var(--muted); font-size: 12.5px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } .dash-grid { grid-template-columns: 1fr 1fr; } .perf { grid-template-columns: repeat(3, 1fr); } }

/* statistics charts */
.stat-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.sbars { display: grid; gap: 10px; padding-top: 6px; }
.sbar { display: grid; grid-template-columns: 130px 1fr 90px; align-items: center; gap: 10px; font-size: 13px; }
.sbar > div { height: 12px; background: #EEF1F5; border-radius: 6px; overflow: hidden; }
.sbar i { display: block; height: 100%; background: var(--grad); border-radius: 6px; } .sbar b { text-align: right; }

/* departments */
.dep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; padding: 16px; overflow: auto; }
.dep-card { background: #fff; border-radius: 14px; padding: 16px; box-shadow: var(--shadow-sm); border: 1px solid #EDF0F4; border-top: 4px solid var(--c);
  display: flex; flex-direction: column; gap: 8px; transition: transform .15s, box-shadow .15s; }
.dep-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dep-card.off { opacity: .55; }
.dep-top { display: flex; gap: 12px; align-items: center; } .dep-top small { display: block; color: var(--muted); }
.dep-badge { width: 42px; height: 42px; border-radius: 12px; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 700; }
.dep-card p { margin: 0; color: #475467; font-size: 13px; min-height: 18px; }
.dep-stats { display: flex; gap: 8px; } .dep-stats span { flex: 1; background: #F6F8FB; border-radius: 8px; padding: 6px; text-align: center; font-size: 11.5px; color: var(--muted); }
.dep-stats b { display: block; font-size: 16px; color: #101828; }
.dep-actions { display: flex; gap: 8px; justify-content: flex-end; }
.dep-members { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { background: #F1F4F8; border-radius: 14px; padding: 4px 10px; font-size: 12.5px; } .chip small { color: var(--muted); margin-left: 4px; }
.swatches { display: flex; gap: 8px; margin-top: 6px; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #D0D5DD; cursor: pointer; }
.sw.on { box-shadow: 0 0 0 2px #101828; }
#gdialog .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } #gdialog .form-grid label { display: grid; gap: 4px; font-size: 13px; }
#gdialog .form-grid .span2 { grid-column: span 2; } #gdialog .form-grid .lbl { font-size: 13px; }

/* work tasks */
.task-board { overflow: auto; height: 100%; }
.tgrid td { vertical-align: middle; } .tgrid tr.overdue td:first-child { box-shadow: inset 3px 0 0 #D92D20; }
.tgrid tr.is-done td { opacity: .55; }
.over-tag { background: #FDECEA; color: #B42318; border-radius: 8px; padding: 1px 6px; font-size: 11px; }
.small { font-size: 12px; }

/* QR */
.qr-box { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; min-width: 0; }
.qr-box b { word-break: break-all; }
.qr-img { background: #fff; padding: 10px; border-radius: 12px; box-shadow: var(--shadow-sm); border: 1px solid #EDF0F4; }
.qr-img svg { width: 100%; height: auto; display: block; }
.qr-link { width: 100%; font-size: 12px; padding: 6px; margin: 6px 0; }

/* watermark over previews */
.preview-body { position: relative; }
.wm-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; color: #0B2540; opacity: var(--wm-opacity, .18);
  font: 600 var(--wm-size, 30px)/1.25 Roboto, sans-serif; user-select: none; }
.wm-block { text-align: center; white-space: nowrap; }
.wm-center { display: grid; place-items: center; }
.wm-center .wm-block { transform: rotate(var(--wm-angle, -30deg)); }
.wm-top-left { padding: 14px 18px; } .wm-top-left .wm-block { text-align: left; }
.wm-tiled .wm-tiles { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr; place-items: center; }
.wm-tiled .wm-block { transform: rotate(var(--wm-angle, -30deg)); font-size: calc(var(--wm-size, 30px) * .6); }
/* the PDF viewer scrolls itself: no second scroll bar around it */
.preview-body:has(> iframe) { overflow: hidden; }

/* compact header so all actions fit */
.appbar { gap: 16px; padding-left: 20px; }
.appbar-actions { gap: 0; }
.appbar-actions .top-action { padding: 4px 7px; min-width: 0; }
.appbar-actions .top-action span:not(.ic-wrap):not(.badge) { font-size: 11.5px; }
.quick-search { flex: 0 1 300px; min-width: 180px; }
@media (max-width: 1400px) { #top-history { display: none !important; } }

/* tenant form */
.tform .tf-head { margin: 6px 0 0; font-size: 13.5px; color: #1D2939; border-bottom: 1px solid #EDF0F4; padding-bottom: 4px; }
.tform .span-2 { grid-column: span 2; }
.tf-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.tf-stats span { background: #F6F8FB; border-radius: 8px; padding: 6px 10px; font-size: 12.5px; color: var(--muted); }
.tf-stats b { color: #101828; margin-right: 3px; }
.pw-show { font: 600 20px ui-monospace, Consolas, monospace; background: #F6F8FB; padding: 10px 14px; border-radius: 8px; user-select: all; letter-spacing: .04em; }
.btn-danger { background: #fff; color: #B42318; border-color: #F5C2BC; }
.btn-danger:hover { background: #FDECEA; }
.uform .form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* AI panel controls */
.ai-head { gap: 6px; }
.ai-head-gap { flex: 1; }
.ai-hb { border: 0; background: rgba(255,255,255,.12); color: #fff; border-radius: 7px; padding: 4px 8px; font-size: 13px; cursor: pointer;
  display: inline-flex; gap: 4px; align-items: center; transition: background .15s; }
.ai-hb:hover { background: rgba(255,255,255,.26); }
.ai-hb span { font-size: 12px; }
.ai-panel { transition: width .2s ease; }
.ai-panel.ai-full { width: 100vw; }
.ai-panel.ai-full .ai-log { padding: 18px max(18px, calc((100vw - 1000px) / 2)); }
.ai-panel.ai-full .ai-form { padding: 12px max(12px, calc((100vw - 1000px) / 2)); }
.ai-panel.ai-full .ai-msg { max-width: 100%; }
.ai-mini { position: fixed; right: 22px; bottom: 22px; z-index: 89; display: flex; align-items: center; gap: 8px; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #3B2E6E, #6A4FC2); color: #fff; padding: 11px 18px; border-radius: 26px; font: 500 14px Roboto, sans-serif;
  box-shadow: 0 10px 26px rgba(59,46,110,.4); }
.ai-mini .ic { width: 18px; height: 18px; color: #F2D47A; }
.ai-mini-dot { width: 10px; height: 10px; border-radius: 50%; background: #34D399; box-shadow: 0 0 0 3px rgba(52,211,153,.35); }
.ai-hist-head { display: flex; align-items: center; gap: 8px; position: sticky; top: -14px; background: #F7F6FB; padding: 4px 0 8px; }
.ai-hist-list { display: flex; flex-direction: column; gap: 6px; }
.ai-hist-item { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; cursor: pointer; }
.ai-hist-item:hover { border-color: #B9AEE6; box-shadow: var(--shadow-sm); }
.ai-hist-item.current { border-color: #7B61D6; background: #F7F4FF; }
.ai-hist-item > div { flex: 1; min-width: 0; }
.ai-hist-item b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-hist-item small { color: var(--muted); font-size: 11.5px; }
.ai-hist-del { border: 0; background: none; cursor: pointer; font-size: 15px; opacity: .55; padding: 4px; }
.ai-hist-del:hover { opacity: 1; }
/* AI tables */
.ai-table { margin-top: 8px; border: 1px solid #E4E0F3; border-radius: 10px; overflow: hidden; background: #fff; }
.ai-table-head { display: flex; align-items: baseline; gap: 10px; padding: 7px 10px; background: #F5F2FF; }
.ai-table-head b { flex: 1; font-size: 13.5px; }
.ai-table-scroll { overflow: auto; max-height: 360px; }
.ai-msg.bot .ai-table table { border-collapse: collapse; width: 100%; margin: 0; font-size: 12.5px; }
.ai-msg.bot .ai-table th { position: sticky; top: 0; background: #FAFAFD; text-transform: none; white-space: nowrap; }
.ai-msg.bot .ai-table td, .ai-msg.bot .ai-table th { border: 0; border-bottom: 1px solid #F0EEF6; padding: 5px 8px; }
.ai-msg.bot .ai-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ai-msg.bot .ai-table tfoot td { background: #F5F2FF; border-top: 1px solid #E4E0F3; }
.ai-msg.bot .ai-table td a { color: #3B2E6E; }
.ai-table-dl { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 7px 10px; border-top: 1px solid #F0EEF6; font-size: 12.5px; color: var(--muted); }
.ai-msg.bot:has(.ai-table) { max-width: 100%; width: 100%; box-sizing: border-box; }
.ai-msg.bot .ai-table td, .ai-msg.bot .ai-table th { white-space: nowrap; }

/* system administrator viewing another tenant */
.tenant-banner { display: flex; align-items: center; gap: 10px; padding: 7px 18px; font-size: 13px; color: #fff;
  background: linear-gradient(90deg, var(--tb), color-mix(in srgb, var(--tb) 70%, #000)); }
.tenant-banner .tdot2 { background: #fff; }
.tenant-banner span:nth-child(2) { flex: 1; }
.tenant-banner .btn { background: #fff; color: #1D2939; border: 0; }

.ai-sources { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.ai-sources a { background: #F1EEFC; color: #3B2E6E; border-radius: 12px; padding: 3px 9px; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-sources a:hover { background: #E4DEFA; }

.ai-lang { border: 0; border-radius: 7px; background: rgba(255,255,255,.14); color: #fff; font-size: 12.5px; padding: 3px 6px; cursor: pointer; }
.ai-lang option { color: #1D2939; }

.ai-recent { max-height: 340px; overflow: auto; margin: 8px 0 14px; border: 1px solid var(--line); border-radius: 8px; }
.ai-recent tr[data-i] { cursor: pointer; }
.ai-recent td { font-size: 12.5px; vertical-align: top; }

.cr-status { max-width: 760px; margin: 6px 0 10px; } .cr-status td { font-size: 13px; padding: 6px 10px; }
