/* =========================================================================
   Docflow Platform design system (light theme, no external assets).
   Ported from the approved mockup docs/mockups/v3/v3_preview.html; the
   contract is docs/specs/exchange-v2-folders-ux.md (sections 5, 6.1, 6.9,
   6.10). Every class used by a template must be defined here.
   ========================================================================= */

:root {
  /* brand (SIBUR palette kept, used the modern way: neutral surfaces, teal actions) */
  --brand-50: #e8f5f6; --brand-100: #cfe9eb; --brand-600: #008c95; --brand-700: #007a83; --brand-800: #006b73;
  --mint: #77e2c3; --deep: #00313c; --deep-2: #0b4650; --deep-3: #0f5560;
  /* neutrals */
  --canvas: #f4f7f8; --surface: #ffffff; --line: #e2eaec; --line-strong: #c7d6d9;
  --text: #0b2a31; --muted: #586f76; --disabled: #9ab0b5;
  /* status */
  --ok: #0f7a55; --ok-bg: #e3f5ec; --warn: #8a5a00; --warn-bg: #fff3d6;
  --danger: #b3361f; --danger-bg: #fdece8;
  /* shape + elevation */
  --r-ctl: 8px; --r-card: 12px;
  --sh-sm: 0 1px 2px rgba(0, 49, 60, .06), 0 1px 1px rgba(0, 49, 60, .04);
  --sh-md: 0 4px 14px rgba(0, 49, 60, .10), 0 1px 3px rgba(0, 49, 60, .06);
  --sh-lg: 0 18px 48px rgba(0, 49, 60, .22), 0 4px 12px rgba(0, 49, 60, .10);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { color: var(--text); line-height: 1.25; }
h3 { font-size: 1rem; font-weight: 650; margin: 0 0 .5rem; }
a { color: var(--brand-700); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- icons (inline SVG sprite in base.html) ---- */
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.s { width: 16px; height: 16px; }

/* ---- app shell ---- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar);
  background: var(--deep); color: #cfe3e6;
  display: flex; flex-direction: column; padding: 18px 12px 12px; z-index: 20;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #00a7b1, #007a83 60%, #005f66);
  display: grid; place-items: center; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.logo svg { width: 18px; height: 18px; stroke: #fff; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav h6 { margin: 16px 10px 6px; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: #6f9aa0; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px;
  color: #cfe3e6; font-weight: 500; position: relative;
}
.nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.nav a.active { background: var(--deep-2); color: #fff; }
.nav a.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--mint);
}
.usercard {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, .06);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--mint), #3fbfa3); color: var(--deep);
  font-weight: 700; font-size: 13px; display: grid; place-items: center;
}
.who { min-width: 0; flex: 1; line-height: 1.25; }
.who b { display: block; color: #fff; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { display: block; font-size: 12px; color: #8fb3b8; }
.acclink { display: inline-block; margin-top: 2px; font-size: 12px; color: #9fd3d8; font-weight: 500; }
.acclink:hover { color: #fff; }
.logout-form { margin: 0; }
.iconbtn {
  width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 8px;
  border: 0; background: transparent; color: #9fc0c5; cursor: pointer; padding: 0;
}
.iconbtn:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.content { margin-left: var(--sidebar); min-height: 100vh; padding: 24px 32px 56px; max-width: 1280px; }
.auth-main { min-height: 100vh; }
body.auth { background: var(--deep); }

/* ---- page head + breadcrumbs ---- */
.pagehead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; font-weight: 650; }
.spacer { flex: 1; }
.crumb { margin: 0 0 6px; font-size: 14px; }
.crumbs { display: flex; align-items: center; gap: 2px; font-size: 14px; color: var(--muted); }
.crumbs .cur { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px; color: var(--text); font-weight: 650; font-size: 18px; letter-spacing: -.01em; }
.page-note { font-size: .9rem; color: var(--muted); margin: 0 0 1rem; }
.infoline { font-size: 13.5px; color: var(--muted); margin: -4px 0 14px; }
.footnote { font-size: 13px; margin-top: .65rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13.5px; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.hint-line { font-size: 13.5px; color: var(--muted); margin: 0 0 12px; }
.note { flex-basis: 100%; font-size: 13px; color: var(--muted); margin: 0; }
.empty-line { font-size: 14px; margin: .5rem 0; }

/* ---- buttons ---- */
.btn, .btn-sm {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 600; font-size: 14px; line-height: 1.2; cursor: pointer; white-space: nowrap;
  text-decoration: none; color: var(--text);
  transition: background .14s, border-color .14s, box-shadow .14s, color .14s;
}
.btn:hover, .btn-sm:hover { background: var(--brand-50); border-color: var(--brand-600); color: var(--brand-800); text-decoration: none; }
.btn.primary, .btn-sm.primary, button.primary {
  background: var(--brand-700); border-color: var(--brand-700); color: #fff; box-shadow: 0 1px 2px rgba(0, 80, 86, .35);
}
.btn.primary:hover, .btn-sm.primary:hover, button.primary:hover { background: var(--brand-800); border-color: var(--brand-800); color: #fff; }
.btn.danger-outline { color: var(--danger); border-color: #f0c9bf; }
.btn.danger-outline:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn.sm, .btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.block { width: 100%; height: 42px; margin-top: 18px; }
.btn:disabled, .btn-sm:disabled { background: #eef3f4; border-color: var(--line); color: var(--disabled); cursor: not-allowed; box-shadow: none; }
.btn:disabled:hover { background: #eef3f4; border-color: var(--line); color: var(--disabled); }
.linkbtn {
  background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--brand-700);
}
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger, .danger { color: var(--danger); }
.linkbtn.danger:hover { color: #8c2715; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.inline-action { display: inline; margin: 0 0 0 12px; }
.actions-cell { white-space: nowrap; }
.actions-cell > a, .actions-cell > details, .actions-cell > .inline-action { margin-right: 4px; }

/* ---- inputs ---- */
.input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  font: inherit; font-size: 14px; background: #fff; color: var(--text);
  transition: border-color .14s, box-shadow .14s;
}
.input:hover { border-color: #9db6bb; }
.input:focus { outline: 0; border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(0, 140, 149, .18); }
.input.sm { width: auto; height: 30px; min-width: 14rem; font-size: 13px; padding: 0 8px; }
.input.file { width: auto; max-width: 100%; height: auto; padding: 6px 8px; }
.input.area { height: auto; padding: 8px 12px; line-height: 1.5; resize: vertical; }
select.input { padding-right: 8px; }
label { font-size: 13px; font-weight: 600; color: var(--text); }
.field { margin: 0 0 16px; }
.field label, .field label.l { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.field .hint { display: block; margin-top: 6px; }
.choice { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; margin: 0 0 8px; color: var(--text); }
.choice input { margin: 0; }
fieldset.plain { border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 12px 14px 10px; margin: 0 0 16px; }
fieldset.plain legend { font-size: 13px; color: var(--muted); padding: 0 6px; }
.form-card { max-width: 720px; padding: 22px 24px 24px; }
.form-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--line);
}
.form-errors { list-style: none; margin: 0; padding: 0; }
.form-errors li { margin: 0; }
.form-errors-box:empty { display: none; }
.form-errors-box { margin-bottom: 16px; }
.danger-zone { border-top: 0; padding-top: 0; margin-top: 20px; }

/* ---- banners ---- */
.banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; margin-bottom: 16px; border-radius: 10px;
  border: 1px solid var(--brand-100); background: var(--brand-50); color: #05505a; font-size: 14px;
}
.banner > div, .banner > ul { flex: 1; min-width: 0; }
.banner.info { background: var(--brand-50); border-color: var(--brand-100); color: #05505a; }
.banner.success { background: var(--ok-bg); border-color: #c6e8d6; color: var(--ok); }
.banner.error { background: var(--danger-bg); border-color: #f5cfc6; color: var(--danger); }
.banner svg { margin-top: 2px; }

/* ---- cards, badges ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--sh-sm); }
.panel { overflow: hidden; margin-bottom: 0; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 99px;
  font-size: 12.5px; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.grey { background: #ebf0f1; color: #4a6167; }
.badge.green { background: var(--ok-bg); color: var(--ok); }
.badge.blue { background: var(--brand-50); color: var(--brand-800); }
.badge.amber, .badge.yellow { background: var(--warn-bg); color: var(--warn); }
.badge.red { background: var(--danger-bg); color: var(--danger); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted);
  padding: 10px 14px; background: #fafcfc; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 0 14px; height: 54px; border-bottom: 1px solid #eef3f4; font-size: 14px; vertical-align: middle; }
tbody tr:hover { background: #f3f9fa; }
tbody tr:last-child td { border-bottom: 0; }
td.check-col, th.check-col { width: 44px; padding-left: 16px; padding-right: 0; }
.namecell { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.ficon {
  display: inline-grid; place-items: center; width: 30px; height: 34px; border-radius: 7px;
  background: #7b929a; color: #fff; font-size: 9.5px; font-weight: 800; letter-spacing: .02em;
  flex: none; position: relative;
}
.ficon::after {
  content: ""; position: absolute; right: 0; top: 0; width: 9px; height: 9px;
  background: rgba(255, 255, 255, .35); border-radius: 0 7px 0 7px;
}
.ficon.sm { width: 24px; height: 28px; font-size: 8px; border-radius: 6px; }
.ficon.gen { background: #7b929a; }
.user-list, .create-user { margin-bottom: 20px; }
.create-user { max-width: 720px; padding: 18px 20px; }
.create-user h3 { margin-bottom: 4px; }

/* ---- empty state ---- */
.empty-state {
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-card);
  padding: 56px 24px; text-align: center;
}
.empty-state .eico {
  width: 64px; height: 64px; border-radius: 18px; background: var(--brand-50); color: var(--brand-700);
  display: grid; place-items: center; margin: 0 auto 14px;
}
.empty-state .eico svg { width: 30px; height: 30px; }
.empty-state .lead { font-size: 1.05rem; font-weight: 650; margin: 0 0 6px; }
.empty-state .sub { color: var(--muted); margin: 0 0 18px; }

/* ---- upload (resumable + simple) ---- */
.upload-card {
  background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--brand-600);
  border-radius: var(--r-card); padding: 16px 18px 18px; box-shadow: var(--sh-sm); margin: 0 0 18px;
}
.upload-card h3 { margin-bottom: 4px; }
.file-input {
  display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl); background: var(--surface); padding: 5px 10px 5px 5px; font-size: 14px; cursor: pointer;
}
.file-input:hover { border-color: var(--brand-100); background: var(--brand-50); }
.file-input .choose {
  background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: 6px;
  padding: 4px 10px; font-weight: 600; color: var(--brand-800);
}
.file-input .chosen { color: var(--muted); font-family: var(--mono); font-size: 13px; }
.progress-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 10px; }
.progress-row .fname { font-family: var(--mono); font-size: 13.5px; min-width: 200px; }
.progress {
  flex: 1 1 260px; height: 10px; background: #e6eef0; border-radius: 99px; overflow: hidden; min-width: 180px;
}
.progress > span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--brand-600), #27b8c0); border-radius: 99px;
}
.progress-row .pct { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 14px; min-width: 42px; }
.resume-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 14px;
  border: 1px solid #efdcb2; background: var(--warn-bg); color: var(--warn);
  border-radius: var(--r-ctl); padding: 8px 12px;
}
.done-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 14px; font-weight: 600;
  border: 1px solid #c6e8d6; background: var(--ok-bg); color: var(--ok);
  border-radius: var(--r-ctl); padding: 8px 12px;
}

/* ---- inline rename (details) ---- */
.inline-rename { display: inline-block; margin: 0 0 4px; vertical-align: middle; }
.inline-rename summary { cursor: pointer; color: var(--brand-700); font-weight: 500; font-size: 14px; list-style: none; }
.inline-rename summary:hover { text-decoration: underline; }
.inline-rename summary::-webkit-details-marker { display: none; }
.rename-box { margin-top: 8px; }
.rename-top { margin: 0 0 10px; }
.rename-top summary { font-size: 13.5px; }
.rename-top form { margin-top: 8px; }

/* ---- task detail ---- */
.process-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; margin: 0 0 20px;
  border-left: 3px solid var(--brand-600);
}
.process-row label { font-size: 14px; color: var(--muted); font-weight: 500; }
.process-row select { min-width: 220px; height: 34px; }
.section-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 24px 0 12px; }
.section-head h3 { margin: 0; font-size: 1.05rem; }
.state-box {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line-strong);
  border-radius: var(--r-card); padding: 14px 16px; margin-top: 20px;
}
.state-box p { margin: 0; }

/* ---- stat cards (admin storage) ---- */
.stats, .storage-summary { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 22px; }
.stat-card {
  display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; min-width: 200px;
  padding: 16px 18px; border-top: 3px solid var(--brand-600);
}
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12.5px; color: var(--muted); }
.storage-largest, .storage-by-user { margin: 0 0 24px; }
.storage-largest h3, .storage-by-user h3 { margin: 0 0 10px; }

/* ---- form-like cards: login ---- */
.auth-main { display: grid; place-items: center; padding: 40px 16px;
  background:
    radial-gradient(1200px 600px at 15% 10%, rgba(0, 167, 177, .35), transparent 60%),
    radial-gradient(900px 500px at 90% 95%, rgba(119, 226, 195, .25), transparent 60%),
    linear-gradient(160deg, #00313c, #00404d 55%, #005a63);
}
.login-screen { width: 100%; display: grid; place-items: center; }
.lcard {
  width: 400px; max-width: 92vw; background: #fff; border-radius: 18px; box-shadow: var(--sh-lg);
  padding: 30px 30px 26px; color: var(--text);
}
.lcard .brand { color: var(--text); padding: 0 0 18px; }
.lcard .logo svg { stroke: #fff; }
.lcard h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
.lcard .s { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.lcard .banner { margin-top: 8px; }
.lcard label.l { display: block; margin: 12px 0 6px; font-size: 13px; font-weight: 600; }
.lfoot { text-align: center; margin-top: 16px; font-size: 12.5px; color: var(--muted); }

/* ---- responsive: collapse the sidebar on narrow screens ---- */
@media (max-width: 860px) {
  .sidebar { position: static; width: auto; flex-direction: row; flex-wrap: wrap; gap: 8px; padding: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .usercard { margin-top: 0; }
  .content { margin-left: 0; padding: 18px 16px 40px; }
}

/* ---- X2: file information (list columns, sortable headers, details panel) ---- */
.file-layout { display: flex; gap: 16px; align-items: flex-start; }
.file-list { flex: 1 1 auto; min-width: 0; }
.file-details { flex: 0 0 340px; width: 340px; position: sticky; top: 16px; }
.file-details:empty { display: none; }
.rowlink { cursor: pointer; }
.sortlink { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; }
.sortlink:hover { color: var(--brand-800); text-decoration: underline; }
th[aria-sort] .sortlink { color: var(--text); }
.sortarrow { width: 12px; height: 12px; transition: transform .14s; }
.sortarrow.up { transform: rotate(180deg); }
.details { overflow: hidden; }
.dhead { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.dhead .ficon { width: 42px; height: 48px; font-size: 12px; }
.dhead > div { min-width: 0; flex: 1; }
.dhead h3 { margin: 0; font-size: 16px; line-height: 1.3; word-break: break-word; font-weight: 650; }
.dhead p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.details .iconbtn { color: var(--muted); flex: none; }
.details .iconbtn:hover { background: var(--brand-50); color: var(--brand-800); }
.dl { margin: 0; padding: 6px 18px 4px; }
.dl > div { display: grid; grid-template-columns: 112px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.dl > div:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; word-break: break-word; }
.dl dd small { display: block; color: var(--muted); font-size: 12.5px; }
.dacts { padding: 14px 18px 18px; display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); background: #fafcfc; }
.empty-cell { height: auto; padding: 44px 24px; text-align: center; }
.empty-cell .lead { font-size: 1.05rem; font-weight: 650; margin: 0 0 6px; }
.empty-cell .sub { color: var(--muted); margin: 0; }
@media (max-width: 960px) {
  .col-by { display: none; }
}
@media (max-width: 860px) {
  .file-layout { flex-direction: column; }
  .file-details { width: auto; flex: none; position: static; }
}
