:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #17212e;
  --muted: #64748b;
  --line: #dde3ea;
  --line-soft: #edf1f5;
  --nav: #142235;
  --nav-ink: #c9d4e2;
  --nav-active: #22364f;
  --accent: #e08a00;
  --accent-ink: #ffffff;
  --primary: #1f5fae;
  --primary-hover: #194f92;
  --danger: #c62828;
  --danger-bg: #fdecec;
  --ok: #2e7d32;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body, #root { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink); background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: #f6f8fb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.accent:hover { filter: brightness(.95); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.sm { padding: 4px 8px; font-size: 12.5px; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 5px;
  color: var(--muted); display: inline-flex; align-items: center;
}
.icon-btn:hover { background: #eef2f7; color: var(--ink); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn svg, .btn svg { width: 16px; height: 16px; }
input[type=text], input[type=password], input[type=date], input[type=search], select {
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; background: #fff; min-width: 0;
}
input:focus, select:focus { outline: 2px solid rgba(31,95,174,.25); border-color: var(--primary); }

/* ---------- вход ---------- */
.login-wrap {
  min-height: 100%; display: grid; place-items: center;
  background: linear-gradient(160deg, #142235 0%, #1d3350 60%, #2a4565 100%);
}
.login-card {
  width: 340px; background: #fff; border-radius: 12px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 13px; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 20px; padding: 10px; }
.login-err { color: var(--danger); margin-top: 12px; min-height: 18px; }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 56px 1fr; height: 100%; }
.topbar {
  grid-column: 1 / 3; display: flex; align-items: center; gap: 16px; padding: 0 18px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand-mark { width: 28px; height: 28px; border-radius: 6px; background: var(--nav); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.topbar .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.userbox b { color: var(--ink); }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: #fff3e0; color: #a35f00; font-weight: 600; }

.sidebar { background: var(--nav); color: var(--nav-ink); padding: 14px 10px; overflow-y: auto; }
.sidebar h6 { margin: 10px 10px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #7f93ab; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px;
  color: var(--nav-ink); margin-bottom: 2px;
}
.nav-item:hover { background: var(--nav-active); text-decoration: none; color: #fff; }
.nav-item.active { background: var(--nav-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-item .lvl { margin-left: auto; font-size: 10.5px; opacity: .65; }

.main { overflow: auto; padding: 22px 26px 40px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head .sub { color: var(--muted); }
.page-head .spacer { flex: 1; }
.notice {
  background: #fff8e6; border: 1px solid #f3d9a0; color: #7a4d00; padding: 10px 14px; border-radius: var(--radius);
  margin-bottom: 14px; display: flex; gap: 10px; align-items: center;
}
.readonly-note { font-size: 12px; color: var(--muted); background: #eef2f7; padding: 3px 8px; border-radius: 10px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.toolbar label.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; color: var(--muted); }
.count { color: var(--muted); font-size: 13px; }
.loading, .empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- таблицы ---------- */
.table-wrap { overflow: auto; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
table.grid th, table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
table.grid thead th {
  position: sticky; top: 0; background: #f8fafc; z-index: 2; font-weight: 600; font-size: 12.5px;
  color: #334155; white-space: nowrap; border-bottom: 1px solid var(--line);
}
table.grid thead tr.filters th { top: 35px; background: #fbfcfd; padding: 6px 6px; }
table.grid thead th.sortable { cursor: pointer; user-select: none; }
table.grid thead th.sortable:hover { color: var(--primary); }
table.grid thead th .arrow { font-size: 10px; margin-left: 3px; color: var(--primary); }
table.grid tr.filters input, table.grid tr.filters select { width: 100%; padding: 4px 6px; font-size: 12.5px; min-width: 64px; }
table.grid tr.filters input.date-f { min-width: 92px; }
table.grid tbody tr:hover td { background: #f8fbff; }
table.grid td.nowrap { white-space: nowrap; }
table.grid td.actions { white-space: nowrap; text-align: right; width: 1%; }
td.expiring { color: var(--danger); font-weight: 700; background: var(--danger-bg) !important; }
.cert-cell { display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.cert-cell .fname { max-width: 160px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: middle; }
.muted { color: var(--muted); }

/* ---------- файловый менеджер ---------- */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 15px; }
.crumbs a { font-weight: 600; }
.crumbs .sep { color: var(--muted); }
.crumbs .cur { font-weight: 700; }
.fs-row-name { display: flex; align-items: center; gap: 10px; }
.fs-row-name svg { width: 20px; height: 20px; flex: none; }
.fs-row-name .ico-folder { color: #e0a100; }
.fs-row-name .ico-project { color: var(--primary); }
.fs-row-name .ico-file { color: #7a8ba0; }
.fs-row-name a.folder-link { color: var(--ink); font-weight: 600; }
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 14px; text-align: center; color: var(--muted);
  margin-bottom: 12px; background: #fff; transition: .15s;
}
.dropzone.over { border-color: var(--primary); background: #eef5ff; color: var(--primary); }
.uploads { margin-bottom: 12px; display: grid; gap: 6px; }
.up-item { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.up-item .bar { height: 4px; background: var(--line-soft); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.up-item .bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .1s; }
.up-item.done .bar i { background: var(--ok); }
.up-item.err { border-color: #f1b5b5; color: var(--danger); }

/* ---------- администрирование ---------- */
.admin-create { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 14px; margin-bottom: 16px; }
.admin-create h3 { width: 100%; margin: 0 0 4px; font-size: 15px; }
.perm-select { padding: 4px 6px !important; font-size: 12.5px; }
.perm-select.full { background: #eaf6ec; border-color: #a9d8b0; }
.perm-select.read { background: #eef4ff; border-color: #b3c8ea; }
.legend { color: var(--muted); font-size: 12.5px; margin: 10px 2px; line-height: 1.6; }

/* ---------- модальные окна ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 100%; max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; }
.modal .body { padding: 16px 20px; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / 3; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; color: #334155; }
.field input, .field select { width: 100%; }
.field .req { color: var(--danger); }
.form-err { color: var(--danger); margin-top: 10px; min-height: 16px; }

/* ---------- уведомления ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; }
.toast { background: #1e293b; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 380px; }
.toast.err { background: var(--danger); }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 56px auto 1fr; }
  .sidebar { grid-column: 1; display: flex; overflow-x: auto; padding: 6px; }
  .sidebar h6 { display: none; }
  .nav-item .lvl { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: 1; }
}
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
table.admin th, table.admin td { padding: 7px 8px; }
table.admin .perm-select { width: 124px; }
.brand-logo { height: 42px; width: auto; max-width: 180px; object-fit: contain; display: block; }
.login-card .brand-logo { height: 64px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.checks label { display: inline-flex !important; align-items: center; gap: 6px; font-weight: 500 !important; margin: 0 !important;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; cursor: pointer; background: #fff; }
.checks label:has(input:checked) { background: #eef4ff; border-color: #b3c8ea; }
.checks input { width: auto !important; margin: 0; }
.logo-card { padding: 14px; margin-top: 22px; }
.logo-card h3 { margin: 0 0 10px; font-size: 15px; }
.logo-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.logo-box { width: 160px; height: 90px; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; background: #fff; padding: 8px; }
.logo-preview { max-width: 100%; max-height: 100%; object-fit: contain; }
table.grid tbody td:first-child { white-space: nowrap; }

.modal.wide { width: 920px; }
.modal textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: inherit; resize: vertical; }
.lfd h4 { margin: 18px 0 8px; font-size: 14px; color: #1e3a5f; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.lfd-note { background: #f4f7fb; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 12.5px; color: #475569; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.lfd-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lfd-table th { text-align: left; font-size: 12px; color: #475569; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.lfd-table td { padding: 3px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.lfd-table td.no { width: 34px; color: var(--muted); vertical-align: top; padding-top: 8px; }
.lfd-table td.ttl { font-weight: 600; vertical-align: top; padding-top: 8px; }
.lfd-table td.sub { color: var(--muted); white-space: nowrap; }
.lfd-table input { width: 100%; padding: 4px 6px; background: #fffbe6; border-color: #ecd98a; }
.lfd-table td.mark { width: 90px; }
.lfd-table td:nth-child(4) { width: 200px; }
.lfd-table .field input { background: #fffbe6; }
.lfd .form-grid input, .lfd .form-grid textarea { background: #fffbe6; border-color: #ecd98a; }
.login-brand { justify-content: center; margin-bottom: 18px; }
.login-card .brand-mark { width: 56px; height: 56px; }
.login-card .brand-mark svg { width: 34px; height: 34px; }

.modal.xwide { width: 96vw; max-width: 1800px; }
.wlog .field input { background: #fffbe6; border-color: #ecd98a; }
.wlog-wrap { overflow: auto; max-height: calc(100vh - 330px); border: 1px solid var(--line); border-radius: 6px; }
.wlog-table { border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.wlog-table thead th { position: sticky; background: #00b0f0; color: #0b2540; font-weight: 700; padding: 5px 6px; text-align: center;
  border-right: 1px solid #7fd3f2; border-bottom: 1px solid #7fd3f2; z-index: 2; }
.wlog-table thead tr:first-child th { top: 0; }
.wlog-table thead tr:nth-child(2) th { top: 27px; }
.wlog-table th.grp { border-bottom: 1px solid #7fd3f2; }
.wlog-table td { padding: 2px 3px; border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); }
.wlog-table td input, .wlog-table td select { width: 100%; min-width: 86px; padding: 4px 5px; font-size: 12.5px; background: #eef8e6; border: 1px solid #c4e3a8; border-radius: 4px; }
.wlog-table td.wide input { min-width: 220px; }
.wlog-table td.date input { min-width: 128px; }
.wlog-table .rn { color: var(--muted); text-align: right; min-width: 30px; padding-right: 6px; }
.wlog-table td.narrow input { min-width: 0; width: 64px; }

.wl-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.wl-table th { background: #00b0f0; color: #0b2540; text-align: left; padding: 6px 8px; }
.wl-table td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
.wl-table td.wl-id { width: 170px; }
.wl-certs { display: grid; gap: 6px; }
.wl-cert { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.wl-cert input { margin-top: 3px; }
.wl-cert.expired { color: var(--danger); }
.wl-warn { color: var(--danger); }

.ds-tree { max-height: calc(100vh - 380px); overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.ds-folder summary { cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.ds-folder summary svg, .ds-file svg { width: 18px; height: 18px; }
.ds-body { padding-left: 22px; border-left: 1px dashed var(--line); margin-left: 8px; }
.ds-file { display: flex; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer; }
.ds-done { color: var(--ok); font-size: 12px; }
.del-left { color: var(--danger); font-weight: 600; }

.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.lang-btn { border: none; background: #fff; padding: 5px 9px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.lang-btn + .lang-btn { border-left: 1px solid var(--line); }
.lang-btn.active { background: var(--primary); color: #fff; }
.login-lang { display: flex; justify-content: flex-end; margin: -10px -10px 4px 0; }

/* доступ к проектам */
.proj-access { display: block; margin-top: 4px; background: none; border: 0; padding: 0; color: var(--primary);
  font-size: 12px; cursor: pointer; text-decoration: underline dotted; white-space: nowrap; }
.pa-modal { width: min(560px, 94vw); }
.pa-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.pa-opt input { margin-top: 3px; }
.pa-modal input[type=search] { width: 100%; margin: 8px 0; }
.pa-list { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.pa-list.disabled { opacity: .45; }
.pa-row { display: flex; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.pa-row:hover { background: #f3f6fa; }

/* занятое место */
.storage-card { padding: 14px; margin-top: 22px; }
.storage-card h3 { margin: 0 0 10px; font-size: 15px; }
.st-total { display: flex; flex-wrap: wrap; gap: 28px; margin: 6px 0 14px; }
.st-big { font-size: 28px; font-weight: 700; color: var(--primary); }
.st-mid { font-size: 20px; font-weight: 600; }
.st-cols { display: flex; flex-wrap: wrap; gap: 24px; }
.st-block { flex: 1 1 320px; }
.st-block h4 { margin: 0 0 6px; font-size: 13px; }
.st-table td { padding: 5px 10px; }
.st-table td.num { text-align: right; white-space: nowrap; }
.nav-storage { padding: 0 14px 8px 38px; margin-top: -2px; font-size: 12px; color: rgba(255,255,255,.6); }
.nav-storage:empty { display: none; }
