/* ==========================================================================
   Milestone Extranet — UI styles
   Brand: Milestone Branding Guidelines rev.00 + screen extensions (brand kit v2.0)
   ========================================================================== */

@font-face { font-family: "Roboto"; src: url("../fonts/roboto-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Roboto"; src: url("../fonts/roboto-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Roboto"; src: url("../fonts/roboto-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Roboto Condensed"; src: url("../fonts/roboto-condensed-latin-300-normal.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Roboto Condensed"; src: url("../fonts/roboto-condensed-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Roboto Condensed"; src: url("../fonts/roboto-condensed-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Roboto Condensed"; src: url("../fonts/roboto-condensed-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --font-text: "Roboto", "Helvetica Neue", Arial, sans-serif;
  --font-title: "Roboto Condensed", "Helvetica Neue LT Std Cn", "Arial Narrow", Arial, sans-serif;

  --brand: #5C80A2;          /* Corporate Blue */
  --brand-80: #7D99B5;       /* Corporate Blue 80% */
  --navy: #1F2B36;

  --bg: #F2F2F2;             /* Laboratory Grey */
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --surface-hover: #F2F5F8;
  --selected: #EEF2F6;
  --selected-strong: #DCE4EC;
  --border: #E5E5E5;
  --border-strong: #CCCCCC;
  --input-border: #8C9196;
  --text: #111111;
  --text-2: #646463;
  --text-3: #8C9196;
  --heading: #425B76;
  --primary: #4A6681;
  --primary-hover: #425B76;
  --primary-text: #FFFFFF;
  --link: #0B6E99;
  --focus: #1799CE;
  --danger: #C0272D;
  --danger-bg: #FBE9EA;
  --success: #1F7A3E;
  --success-bg: #E8F3EC;
  --warning: #A15C00;
  --warning-bg: #FDF3E2;
  --overlay: rgba(20, 26, 32, .55);
  --shadow: 0 8px 28px rgba(31, 43, 54, .16);

  --sidebar-bg: #1F2B36;
  --sidebar-text: #C9D3DC;
  --sidebar-text-strong: #FFFFFF;
  --sidebar-hover: #2A3946;
  --sidebar-active: #425B76;
  --sidebar-border: #2E3D4A;

  --radius: 2px;
  --row: 44px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #141A20;
  --surface: #1B232B;
  --surface-2: #202A33;
  --surface-hover: #25303A;
  --selected: #24313D;
  --selected-strong: #2E3F4F;
  --border: #3A4652;
  --border-strong: #4A5866;
  --input-border: #6B7A88;
  --text: #E8ECEF;
  --text-2: #A9B3BC;
  --text-3: #87929C;
  --heading: #B6C7D7;
  --primary: #4A6681;
  --primary-hover: #5A7896;
  --link: #4DB8E6;
  --focus: #4DB8E6;
  --danger: #FF6B6B;
  --danger-bg: #3A2426;
  --success: #4CC27A;
  --success-bg: #1E3327;
  --warning: #F0B04A;
  --warning-bg: #3A2F1C;
  --overlay: rgba(0, 0, 0, .65);
  --shadow: 0 10px 32px rgba(0, 0, 0, .5);
  --sidebar-bg: #10161B;
  --sidebar-hover: #1B242C;
  --sidebar-border: #232E37;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Icons ---------- */
.i { width: 18px; height: 18px; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.i-lg { width: 22px; height: 22px; }
.i-xl { width: 40px; height: 40px; }

/* ---------- Typography ---------- */
.title, h1, h2, h3 { font-family: var(--font-title); font-weight: 500; text-transform: uppercase; letter-spacing: .02em; color: var(--heading); margin: 0; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.label { font-family: var(--font-title); font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: #C0272D; border-color: #C0272D; color: #fff; }
.btn-danger:hover { background: #A51F25; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }
.btn.is-active { background: var(--selected-strong); border-color: var(--brand); color: var(--text); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label, .field > .label { font-size: 13px; font-weight: 500; color: var(--text-2); text-transform: none; letter-spacing: 0; font-family: var(--font-text); }
.input, select.input, textarea.input {
  height: 40px; padding: 0 12px; width: 100%;
  border: 1px solid var(--input-border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
textarea.input { height: auto; padding: 10px 12px; }
.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
.input::placeholder { color: var(--text-3); }
.hint { font-size: 12px; color: var(--text-2); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 2px; top: 2px; height: 36px; width: 38px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }

/* ---------- Alerts / status (shape + colour + word) ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid; border-left-width: 4px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert .i { margin-top: 1px; }
.alert-error { background: var(--danger-bg); border-color: var(--danger); color: var(--text); }
.alert-error .i { color: var(--danger); }
.alert-success { background: var(--success-bg); border-color: var(--success); }
.alert-success .i { color: var(--success); }
.alert-info { background: var(--selected); border-color: var(--brand); }
.alert-info .i { color: var(--brand); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning); }
.alert-warning .i { color: var(--warning); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid var(--border-strong); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-success { color: var(--success); border-color: currentColor; background: var(--success-bg); }
.badge-danger { color: var(--danger); border-color: currentColor; background: var(--danger-bg); }
.badge-warning { color: var(--warning); border-color: currentColor; background: var(--warning-bg); }
.badge-brand { color: var(--heading); border-color: var(--brand-80); background: var(--selected); }
.badge-plain::before { display: none; }

/* ==========================================================================
   Auth pages (login, forgot, reset, setup)
   ========================================================================== */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 44%) 1fr; }
.auth-brand {
  /* Background photo: replace assets/img/login-bg.jpg to change it.
     It is shown as a Corporate Blue duotone (grayscale photo + blue multiply layer). */
  background: var(--brand); color: #fff;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px 56px; position: relative; overflow: hidden; isolation: isolate;
}
/* Duotone: grayscale photo (::after) tinted with Corporate Blue in multiply (::before) */
.auth-brand::after { content: ""; position: absolute; inset: 0; z-index: -2; background: url("../img/login-bg.jpg") 50% 45% / cover no-repeat; filter: grayscale(1) contrast(1.15) brightness(1.05); }
.auth-brand::before { content: ""; position: absolute; inset: 0; z-index: -1; background: #5C80A2; mix-blend-mode: multiply; }
.auth-brand .logo { position: relative; }
.auth-brand .logo { width: 260px; max-width: 80%; }
.auth-brand .mark-watermark { position: absolute; right: -50px; bottom: 96px; width: 280px; opacity: .10; pointer-events: none; }
.auth-message { margin-top: auto; font-family: var(--font-title); text-transform: uppercase; line-height: 1.02; font-size: 46px; letter-spacing: .01em; position: relative; }
.auth-message .light { font-weight: 300; display: block; }
.auth-message .medium { font-weight: 500; display: block; }
.auth-brand .foot { font-size: 13px; opacity: .9; position: relative; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); position: relative; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 32px; margin-bottom: 6px; }
.auth-card .lead { color: var(--text-2); margin: 0 0 28px; }
.auth-card .links { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 20px; font-size: 14px; }
.auth-theme { position: absolute; top: 20px; right: 20px; }
.auth-logo-mobile { display: block; width: 210px; margin-bottom: 40px; }
.setup-checks { list-style: none; margin: 0 0 24px; padding: 0; border: 1px solid var(--border); }
.setup-checks li { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.setup-checks li:last-child { border-bottom: 0; }
.setup-checks .ok { color: var(--success); }
.setup-checks .ko { color: var(--warning); }
.auth-card.wide { max-width: 520px; }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}

/* ==========================================================================
   App shell
   ========================================================================== */
.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--sidebar-border); }
.sidebar-logo { display: block; padding: 22px 22px 20px; border-bottom: 1px solid var(--sidebar-border); }
.sidebar-logo img { width: 176px; display: block; }
.nav { padding: 14px 0; overflow-y: auto; flex: 1; }
.nav-section { padding: 16px 22px 6px; font-family: var(--font-title); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #8FA2B4; }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 22px;
  color: var(--sidebar-text); font-size: 14px; border-left: 3px solid transparent; text-decoration: none;
}
.nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.nav a.active { background: var(--sidebar-active); color: #fff; border-left-color: var(--focus); }
.nav .count { margin-left: auto; font-size: 12px; color: #8FA2B4; }
.nav a.active .count { color: #DCE4EC; }
.sidebar-user { border-top: 1px solid var(--sidebar-border); padding: 14px 16px 14px 22px; display: flex; align-items: center; gap: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-family: var(--font-title); font-weight: 500; font-size: 14px; flex: 0 0 auto; letter-spacing: .03em; }
.sidebar-user .who { min-width: 0; flex: 1; }
.sidebar-user .who a { color: #fff; font-weight: 500; font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who span { font-size: 12px; color: #8FA2B4; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .btn { color: var(--sidebar-text); }
.sidebar-user .btn:hover { background: var(--sidebar-hover); color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { height: 60px; flex: 0 0 60px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px; }
.search { position: relative; flex: 1; max-width: 560px; }
.search .i { position: absolute; left: 12px; top: 11px; color: var(--text-2); }
.search input { padding-left: 40px; background: var(--surface-2); border-color: var(--border-strong); height: 40px; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }

.content { flex: 1; overflow-y: auto; padding: 24px 28px 64px; min-height: 0; position: relative; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .heading { min-width: 0; }
.page-head h1 { display: flex; align-items: center; gap: 10px; overflow-wrap: anywhere; }
.page-head .sub { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.page-head .sub .i { width: 15px; height: 15px; vertical-align: -3px; }

.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 13px; margin-bottom: 8px; color: var(--text-2); }
.crumbs a { color: var(--text-2); padding: 2px 4px; border-radius: var(--radius); }
.crumbs a:hover { color: var(--link); background: var(--surface-hover); text-decoration: none; }
.crumbs .i { width: 14px; height: 14px; color: var(--text-3); }
.crumbs .current { color: var(--text); font-weight: 500; padding: 2px 4px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { height: 34px; min-width: 38px; padding: 0 10px; border: 0; background: var(--surface); color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--selected-strong); color: var(--text); }
select.input.sort-select { height: 36px; width: auto; padding-right: 30px; font-size: 14px; border-color: var(--border-strong); }

.fav-btn { color: var(--text-3); }
.fav-btn.on, .row-actions .fav-btn.on, .row-actions .fav-btn.on:hover { color: #B8860B; }
html[data-theme="dark"] .fav-btn.on { color: #F0B04A; }
.fav-btn.on .i { fill: currentColor; }

/* ---------- Selection bar ---------- */
.selbar {
  position: sticky; top: -24px; z-index: 5; margin: -6px 0 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--navy); color: #fff; padding: 8px 10px 8px 16px; border-radius: var(--radius);
}
html[data-theme="dark"] .selbar { background: var(--selected-strong); }
.selbar .btn { background: transparent; border-color: rgba(255,255,255,.35); color: #fff; }
.selbar .btn:hover { background: rgba(255,255,255,.12); }
.selbar .count { font-weight: 500; margin-right: auto; }

/* ---------- File list (table) ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); }
.flist { width: 100%; border-collapse: collapse; table-layout: fixed; }
.flist th {
  text-align: left; height: 40px; padding: 0 12px; border-bottom: 1px solid var(--border);
  font-family: var(--font-title); font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2);
  background: var(--surface-2); user-select: none; white-space: nowrap;
}
.flist th.sortable { cursor: pointer; }
.flist th.sortable:hover { color: var(--text); }
.flist th .i { width: 14px; height: 14px; }
.flist td { height: var(--row); padding: 0 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14px; }
.flist tr:last-child td { border-bottom: 0; }
.flist tbody tr { cursor: default; }
.flist tbody tr:hover td { background: var(--surface-hover); }
.flist tbody tr.sel td { background: var(--selected); }
.flist .c-check { width: 44px; padding-right: 0; }
.flist .c-name { width: auto; }
.flist .c-loc { width: 26%; }
.flist .c-date { width: 170px; color: var(--text-2); white-space: nowrap; }
.flist .c-size { width: 110px; color: var(--text-2); text-align: right; white-space: nowrap; }
.flist th.c-size { text-align: right; }
.flist .c-act { width: 96px; text-align: right; padding-right: 8px; white-space: nowrap; }
.flist input[type=checkbox], .gcard input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; margin: 0; vertical-align: middle; }
.fname { display: flex; align-items: center; gap: 12px; min-width: 0; }
.fname a, .fname .nm { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.fname a:hover { color: var(--link); text-decoration: underline; }
.fname .missing { color: var(--text-3); text-decoration: line-through; }
.loc-link { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; font-size: 13px; }
.row-actions { display: inline-flex; gap: 2px; }
.row-actions .btn { color: var(--text-2); }
.row-actions .btn:hover { color: var(--text); }
.flist tbody tr:not(:hover):not(.sel) .row-actions .hover-only { visibility: hidden; }

/* File type icon tile */
.ftype { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: var(--radius); color: var(--brand); background: var(--selected); }
.ftype .i { width: 18px; height: 18px; }
.ftype.t-dir { color: var(--brand); background: transparent; }
.ftype.t-dir .i { width: 24px; height: 24px; fill: var(--selected-strong); }
html[data-theme="dark"] .ftype.t-dir .i { fill: #2E3F4F; }
.ftype.t-pdf { color: #C0272D; background: #FBE9EA; }
.ftype.t-img { color: #1F7A3E; background: #E8F3EC; }
.ftype.t-video { color: #6B3FA0; background: #F1EAF8; }
.ftype.t-audio { color: #0B6E99; background: #E6F2F8; }
.ftype.t-sheet { color: #1F7A3E; background: #E8F3EC; }
.ftype.t-doc { color: #2B5797; background: #E9EFF8; }
.ftype.t-slide { color: #A15C00; background: #FDF3E2; }
.ftype.t-zip { color: #646463; background: #EFEFEF; }
html[data-theme="dark"] .ftype:not(.t-dir) { background: var(--surface-hover); }
html[data-theme="dark"] .ftype.t-pdf { color: #FF8A8A; }
html[data-theme="dark"] .ftype.t-img, html[data-theme="dark"] .ftype.t-sheet { color: #6FD39A; }
html[data-theme="dark"] .ftype.t-video { color: #C3A2EA; }
html[data-theme="dark"] .ftype.t-audio { color: #4DB8E6; }
html[data-theme="dark"] .ftype.t-doc { color: #8FB3EA; }
html[data-theme="dark"] .ftype.t-slide { color: #F0B04A; }
html[data-theme="dark"] .ftype.t-zip { color: #A9B3BC; }

/* ---------- Grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; }
.gcard { background: var(--surface); border: 1px solid var(--border); position: relative; display: flex; flex-direction: column; cursor: default; transition: border-color .12s; }
.gcard:hover { border-color: var(--border-strong); }
.gcard.sel { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--selected); }
.gthumb { aspect-ratio: 4 / 3; display: grid; place-items: center; background: var(--surface-2); border-bottom: 1px solid var(--border); overflow: hidden; cursor: pointer; }
.gthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gthumb .ftype { width: 64px; height: 64px; }
.gthumb .ftype .i { width: 32px; height: 32px; }
.gthumb .ftype.t-dir .i { width: 64px; height: 64px; stroke-width: 1; }
.gthumb .ext { position: absolute; }
.gbody { padding: 10px 12px 12px; display: flex; gap: 6px; align-items: flex-start; }
.gbody .txt { min-width: 0; flex: 1; }
.gbody .nm { font-size: 14px; font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); cursor: pointer; }
.gbody .nm:hover { color: var(--link); }
.gbody .meta { font-size: 12px; color: var(--text-2); }
.gcard .gcheck { position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); }
.gcard .gfav { position: absolute; top: 6px; right: 6px; background: var(--surface); border: 1px solid var(--border); }
.gcard:not(:hover):not(.sel) .gcheck { opacity: 0; }
.gcard:not(:hover) .gfav:not(.on) { opacity: 0; }
.grid-ext { position: absolute; left: 10px; bottom: auto; }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; padding: 64px 20px; color: var(--text-2); }
.empty > .i { width: 48px; height: 48px; color: var(--brand-80); stroke-width: 1.2; }
.empty p .i { width: 16px; height: 16px; vertical-align: -3px; color: var(--text-2); }
.empty h2 { margin: 14px 0 6px; color: var(--text); }
.loading { padding: 48px; text-align: center; color: var(--text-2); }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border-strong); border-top-color: var(--brand); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Drop zone ---------- */
.dropzone { position: absolute; inset: 12px; border: 2px dashed var(--brand); background: color-mix(in srgb, var(--selected) 88%, transparent); display: none; align-items: center; justify-content: center; flex-direction: column; gap: 10px; z-index: 20; pointer-events: none; color: var(--heading); font-family: var(--font-title); font-size: 22px; text-transform: uppercase; }
.dropzone .i { width: 48px; height: 48px; }
.content.dragging .dropzone { display: flex; }

/* ---------- Menus ---------- */
.menu { position: fixed; z-index: 220; min-width: 220px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); padding: 6px 0; border-radius: var(--radius); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 14px; border: 0; background: none; text-align: left; font-size: 14px; cursor: pointer; color: var(--text); }
.menu button:hover, .menu button:focus-visible { background: var(--surface-hover); outline: none; }
.menu button .i { color: var(--text-2); }
.menu button.danger, .menu button.danger .i { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 180; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); width: 100%; max-width: 480px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow); border-top: 4px solid var(--brand); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 10px; }
.modal-head h2 { font-size: 20px; }
.modal-body { padding: 8px 22px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.modal-foot .left { margin-right: auto; }

/* ---------- Preview ---------- */
.preview { position: fixed; inset: 0; z-index: 150; background: rgba(12, 16, 20, .94); display: flex; flex-direction: column; color: #E8ECEF; }
.preview-head { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 16px 0 20px; border-bottom: 1px solid #2A343E; background: #10161B; }
.preview-head .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-head .meta { color: #A9B3BC; font-size: 13px; white-space: nowrap; }
.preview-head .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.preview-head .btn { background: transparent; color: #E8ECEF; border-color: #3A4652; }
.preview-head .btn:hover { background: #25303A; }
.preview-head .btn.fav-btn.on { color: #F0B04A; }
.preview-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; padding: 16px 64px; }
.preview-body img { max-width: 100%; max-height: 100%; object-fit: contain; background: repeating-conic-gradient(#2a2a2a 0% 25%, #333 0% 50%) 50% / 20px 20px; }
.preview-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.preview-body video { max-width: 100%; max-height: 100%; background: #000; }
.preview-body audio { width: min(560px, 100%); }
.preview-body pre { width: 100%; height: 100%; margin: 0; overflow: auto; background: #1B232B; color: #E8ECEF; padding: 18px 22px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; border: 1px solid #3A4652; }
.preview-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; background: rgba(255,255,255,.06); color: #fff; cursor: pointer; display: grid; place-items: center; }
.preview-nav:hover { background: rgba(255,255,255,.16); }
.preview-nav.prev { left: 10px; }
.preview-nav.next { right: 10px; }
.preview-none { text-align: center; color: #A9B3BC; }
.preview-none > .i { width: 64px; height: 64px; color: #7D99B5; stroke-width: 1; }
.preview-none p { margin: 12px 0 20px; }

/* ---------- Upload panel ---------- */
.uploads { position: fixed; right: 20px; bottom: 20px; width: 380px; max-width: calc(100vw - 40px); background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); z-index: 90; }
.uploads-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px; background: var(--navy); color: #fff; }
.uploads-head .t { flex: 1; font-family: var(--font-title); text-transform: uppercase; letter-spacing: .03em; font-size: 15px; }
.uploads-head .btn { color: #fff; }
.uploads-head .btn:hover { background: rgba(255,255,255,.12); }
.uploads-list { max-height: 300px; overflow-y: auto; }
.uploads.collapsed .uploads-list { display: none; }
.up-item { padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.up-item:last-child { border-bottom: 0; }
.up-row { display: flex; align-items: center; gap: 8px; }
.up-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-row .st { color: var(--text-2); white-space: nowrap; }
.up-row .st.ok { color: var(--success); }
.up-row .st.err { color: var(--danger); }
.up-bar { height: 4px; background: var(--border); margin-top: 7px; }
.up-bar > span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.up-item.done .up-bar > span { background: var(--success); }
.up-item.error .up-bar > span { background: var(--danger); }
.up-err { color: var(--danger); margin-top: 4px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; background: var(--navy); color: #fff; padding: 10px 16px; box-shadow: var(--shadow); font-size: 14px; border-left: 4px solid var(--focus); max-width: 560px; animation: toastIn .18s ease-out; white-space: pre-line; }
html[data-theme="dark"] .toast { background: #25303A; }
.toast.error { border-left-color: #FF6B6B; }
.toast.success { border-left-color: #4CC27A; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Data tables (admin) ---------- */
.dtable { width: 100%; border-collapse: collapse; background: var(--surface); }
.dtable th { text-align: left; height: 40px; padding: 0 14px; font-family: var(--font-title); font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.dtable td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.dtable tr:last-child td { border-bottom: 0; }
.dtable tbody tr:hover td { background: var(--surface-hover); }
.dtable .num { text-align: right; }
.dtable .actions { text-align: right; white-space: nowrap; }
.dtable .strong { font-weight: 500; }
.dtable .sub { font-size: 12px; color: var(--text-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); }
.cell-ellipsis { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-chips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 360px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; font-size: 12px; background: var(--selected); border: 1px solid var(--selected-strong); color: var(--text); border-radius: var(--radius); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .i { width: 13px; height: 13px; color: var(--brand); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; }
.filters .input { height: 36px; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; color: var(--text-2); font-size: 14px; }

/* ---------- Folder tree picker ---------- */
.tree { border: 1px solid var(--border-strong); max-height: 320px; overflow-y: auto; padding: 6px 0; background: var(--surface); }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { padding-left: 20px; }
.tree .node { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; font-size: 14px; cursor: pointer; }
.tree .node:hover { background: var(--surface-hover); }
.tree .node.on { background: var(--selected-strong); }
.tree .node.disabled { opacity: .45; cursor: not-allowed; }
.tree .tog { width: 22px; height: 22px; border: 0; background: none; padding: 0; cursor: pointer; color: var(--text-2); display: grid; place-items: center; }
.tree .tog .i { width: 15px; height: 15px; transition: transform .12s; }
.tree .tog.open .i { transform: rotate(90deg); }
.tree .tog.leaf { visibility: hidden; }
.tree .node .i.fold { color: var(--brand); width: 17px; height: 17px; }
.tree .node input { accent-color: var(--primary); width: 15px; height: 15px; margin: 0 2px 0 0; }
.tree .node .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-empty { padding: 14px; color: var(--text-2); font-size: 14px; }

/* ---------- Cards (profile) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--border); }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card-head h2 { font-size: 17px; }
.card-head::before { content: ""; width: 3px; height: 18px; background: #ADABAB; }
.card-body { padding: 20px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 10px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.pw-rules { list-style: none; padding: 0; margin: -6px 0 16px; font-size: 13px; color: var(--text-2); }
.pw-rules li { display: flex; align-items: center; gap: 6px; }
.pw-rules li .i { width: 14px; height: 14px; }
.pw-rules li.ok { color: var(--success); }

/* ---------- Public share page ---------- */
.share { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.share-top { background: var(--surface); border-bottom: 1px solid var(--border); height: 64px; display: flex; align-items: center; padding: 0 28px; }
.share-top img { height: 38px; }
.share-top .spacer { flex: 1; }
.share-bar { height: 4px; background: var(--brand); }
.share-main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 40px 20px; gap: 22px; }
.share-card { width: 100%; max-width: 720px; background: var(--surface); border: 1px solid var(--border); }
.share-file { display: flex; gap: 18px; align-items: center; padding: 26px 28px; }
.share-file .ftype { width: 56px; height: 56px; }
.share-file .ftype .i { width: 30px; height: 30px; }
.share-file .info { flex: 1; min-width: 0; }
.share-file h1 { font-size: 22px; overflow-wrap: anywhere; text-transform: none; font-family: var(--font-text); color: var(--text); letter-spacing: 0; }
.share-file .meta { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.share-actions { display: flex; gap: 10px; padding: 0 28px 26px; flex-wrap: wrap; }
.share-preview { width: 100%; max-width: 1100px; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; min-height: 200px; }
.share-preview img { max-width: 100%; max-height: 78vh; display: block; }
.share-preview iframe { width: 100%; height: 80vh; border: 0; }
.share-preview video { max-width: 100%; max-height: 78vh; display: block; }
.share-preview audio { margin: 40px; width: min(520px, 90%); }
.share-foot { text-align: center; color: var(--text-2); font-size: 12px; padding: 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .flist .c-date { width: 140px; }
  .flist .c-loc { display: none; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 120; transform: translateX(-100%); transition: transform .2s; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: var(--overlay); z-index: 110; }
  .menu-btn { display: inline-flex; }
  .topbar .spacer { display: none; }
  .search { max-width: none; }
  .topbar { padding: 0 14px; }
  .content { padding: 18px 14px 64px; }
  .flist .c-date, .flist .c-size { display: none; }
  .row2 { grid-template-columns: 1fr; }
  .preview-body { padding: 10px; }
  .preview-nav { display: none; }
  .preview-head .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Utilities ---------- */
.ml-auto { margin-left: auto; }
.mt-n6 { margin-top: -6px; }
.mt-20 { margin-top: 20px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.gap-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
html[data-theme="dark"] .only-light, html:not([data-theme="dark"]) .only-dark { display: none !important; }
.nowrap { white-space: nowrap; }

/* ---------- Company details ---------- */
.auth-brand .foot { line-height: 1.6; }
.auth-brand .foot a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.auth-help { margin: 24px 0 0; padding-top: 18px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-2); }
.auth-company { margin-top: 28px; font-style: normal; font-size: 12px; line-height: 1.7; color: var(--text-2); }
.auth-company strong { color: var(--text); font-weight: 500; }
.auth-help + .auth-company { margin-top: 16px; }
@media (max-width: 860px) { .auth-help, .auth-company { text-align: center; } }
.share-foot { line-height: 1.7; }
.share-foot .share-contact { font-size: 14px; color: var(--text); margin: 0 0 14px; }
.auth-brand .foot { background: rgba(31, 43, 54, .38); margin: 0 -56px -48px; padding: 18px 56px; font-size: 13px; opacity: 1; position: relative; }
@media (max-width: 1180px) { .auth-message { font-size: 34px; } .auth-brand { padding: 40px; } .auth-brand .foot { margin: 0 -40px -40px; padding: 16px 40px; } }

/* ---------- Role picker (user form) ---------- */
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-opt { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.role-opt:hover { background: var(--surface-hover); }
.role-opt:has(input:checked) { border-color: var(--brand); background: var(--selected); box-shadow: inset 0 0 0 1px var(--brand); }
.role-opt:has(input:disabled) { cursor: not-allowed; opacity: .75; }
.role-opt input { margin: 3px 0 0; accent-color: var(--primary); }
.role-opt strong { display: block; font-weight: 500; font-size: 14px; }
.role-opt .hint { display: block; margin-top: 2px; }
#uf-admin-note { margin-top: 2px; }
@media (max-width: 900px) { .role-pick { grid-template-columns: 1fr; } }

/* ---------- What's new ---------- */
.nav .news-count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--focus); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.nav a.active .news-count { background: #fff; color: var(--navy); }
.news-banner { align-items: center; }
.news-banner > div { flex: 1; }
.news-banner .btn { flex: 0 0 auto; }
.flist tr.group-row td { height: 34px; background: var(--surface-2); font-family: var(--font-title); font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--heading); border-bottom: 1px solid var(--border); }
.flist tbody tr.group-row:hover td { background: var(--surface-2); }
.grid-group { grid-column: 1 / -1; font-family: var(--font-title); font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--heading); padding: 6px 0 0; border-bottom: 1px solid var(--border-strong); }
.grid-group:not(:first-child) { margin-top: 8px; }
.st-badge { height: 20px; padding: 0 7px; font-size: 11px; margin-left: 8px; flex: 0 0 auto; }
.gbody .meta .st-badge { margin: 0 6px 0 0; }

/* ---------- Consent page (terms acceptance) ---------- */
.consent-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.consent-page .share-top img { height: 38px; }
.consent-main { flex: 1; display: flex; justify-content: center; padding: 36px 20px 60px; }
.consent-card { width: 100%; max-width: 820px; background: var(--surface); border: 1px solid var(--border); padding: 32px 36px; }
.consent-card h1 { font-size: 30px; margin-bottom: 6px; }
.consent-card .lead { color: var(--text-2); margin: 0 0 24px; }
.consent-doc { border-top: 1px solid var(--border); padding: 22px 0 6px; }
.consent-doc-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.consent-doc-head h2 { font-size: 19px; }
.consent-num { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-family: var(--font-title); font-weight: 700; font-size: 14px; flex: 0 0 auto; margin-top: -2px; }
.consent-text, .ack-text { max-height: 300px; overflow-y: auto; border: 1px solid var(--border-strong); background: var(--surface-2); padding: 16px 20px; font-size: 14px; line-height: 1.6; }
.consent-text h3, .ack-text h3 { font-family: var(--font-title); font-size: 15px; text-transform: uppercase; letter-spacing: .03em; color: var(--heading); margin: 14px 0 6px; }
.consent-text h3:first-child, .ack-text h3:first-child { margin-top: 0; }
.consent-text p, .ack-text p { margin: 0 0 10px; }
.consent-text ul, .ack-text ul { margin: 0 0 10px; padding-left: 20px; }
.consent-check { margin: 14px 0 6px; font-weight: 500; }
.consent-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border); margin-top: 18px; padding-top: 20px; }
.consent-note { margin: 16px 0 0; }
@media (max-width: 700px) { .consent-card { padding: 22px 18px; } .consent-actions { flex-direction: column-reverse; } .consent-actions .btn { width: 100%; } }
.share-lock { padding: 0 28px 26px; }
.share-lock-row { display: flex; gap: 10px; }
.share-lock-row .input { max-width: 320px; }
.share-unlock-note { padding: 0 28px 20px; margin: -10px 0 0; }

/* ---------- Protection indicators ---------- */
.pol-ic { display: inline-flex; margin-left: 8px; color: var(--text-2); flex: 0 0 auto; }
.pol-ic .i { width: 15px; height: 15px; }
.pol-ic.conf { color: var(--warning); }
.gbody .meta .pol-ic { margin: 0 6px 0 0; vertical-align: -3px; }
.pol-badge { margin-left: 8px; height: 22px; gap: 4px; vertical-align: 1px; }
.pol-badge .i { width: 13px; height: 13px; }
.status-note { margin-top: 3px; color: var(--warning); }
.consents { list-style: none; margin: 4px 0 0; padding: 0; font-size: 13px; }
.consents li { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; border-bottom: 1px solid var(--border); }
.consents li .i { width: 15px; height: 15px; color: var(--success); margin-top: 2px; }
.consents-box { margin: 18px 0 4px; }
.modal .ack-text { max-height: 46vh; margin-top: 4px; }

/* ---------- Terms & security ---------- */
.settings-cards { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.doc-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
textarea.doc-text { font-size: 14px; line-height: 1.55; min-height: 220px; resize: vertical; }
.doc-actions { margin-top: 16px; justify-content: flex-end; }
@media (max-width: 900px) { .settings-cards { grid-template-columns: 1fr; } }

/* ---------- CSV import ---------- */
.import-cols { margin: 0 0 12px; padding-left: 20px; font-size: 14px; line-height: 1.7; }
.import-summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.import-table { max-height: 46vh; overflow: auto; }
.import-table .dtable td { font-size: 13px; padding: 8px 12px; }
.import-table .chip { max-width: 260px; }
.dtable tr.row-error td { background: var(--danger-bg); }
.dtable .sub.err { color: var(--danger); }
.import-errors { margin: 0 0 12px; padding-left: 20px; font-size: 14px; }
.dtable .c-check { width: 44px; }
.dtable input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.dtable tbody tr.sel td { background: var(--selected); }
#usel { position: static; margin: 0 0 12px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--link); cursor: pointer; font: inherit; }
.link-btn:hover { text-decoration: underline; }
.dtable td > .gap-row { flex-wrap: nowrap; }
.mail-diag { margin-top: 12px; font-size: 13px; } .mail-diag summary { cursor: pointer; color: var(--text-2); margin-bottom: 8px; } .mail-diag .kv { grid-template-columns: 140px 1fr; }
