:root {
  --bg: #f5f8f6;
  --surface: #ffffff;
  --surface-2: #f0f4f1;
  --border: #e1e8e3;
  --border-strong: #c9d5cd;
  --text: #14211a;
  --muted: #687a6e;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-soft: #e7f6ec;
  --accent-2: #22c55e;
  --success: #15803d;
  --error: #dc2626;
  --warning: #b45309;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 33, 26, .04), 0 1px 3px rgba(20, 33, 26, .06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1 { font-size: 26px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 650; margin: 0 0 12px; }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- раскладка ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  /* Геометрия по образцу: 228 px + граница 1 px, шапка 67 px, пункты 44 px с шагом 46 px */
  width: 229px; flex: 0 0 229px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-head {
  height: 67px; flex: 0 0 67px; display: flex; align-items: center; padding: 6px 18px 0;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); font-weight: 600; font-size: 19px; letter-spacing: -0.015em; line-height: 1; }
.brand img { width: 30px; height: 30px; border-radius: 7px; flex: 0 0 30px; }
.brand:hover { color: var(--text); }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 9px; }
.nav-tools { padding-top: 10px; }
.nav-link {
  display: flex; align-items: center; gap: 14px; height: 44px; padding: 0 13px; border-radius: 8px;
  color: var(--text); font-size: 15px; font-weight: 450; line-height: 1; white-space: nowrap;
}
.nav-link span { overflow: hidden; text-overflow: ellipsis; }
.nav-link .nav-icon { color: var(--muted); }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 500; }
.nav-link.active .nav-icon { color: var(--accent); }
.nav-icon { flex: 0 0 18px; width: 18px; height: 18px; }
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px 22px; padding-left: 13px; border-left: 1.5px solid var(--border); }
.nav-sublink {
  display: flex; align-items: center; height: 36px; padding: 0 12px; border-radius: 8px;
  color: var(--muted); font-size: 14px; font-weight: 450; position: relative;
}
.nav-sublink:hover { background: var(--surface-2); color: var(--text); }
.nav-sublink.active { color: var(--accent-hover); font-weight: 500; background: var(--accent-soft); }
.nav-sublink.active::before { content: ""; position: absolute; left: -14.5px; top: 8px; bottom: 8px; width: 1.5px; background: var(--accent); }
/* У раздела с вкладками подсвечивается вкладка, а сам раздел — только иконкой */
.nav-group.open.has-sub > .nav-link { background: transparent; color: var(--text); font-weight: 500; }
.nav-group.open.has-sub > .nav-link .nav-icon { color: var(--accent); }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; padding-top: 10px; }
.nav-system { padding-bottom: 10px; }
.sidebar-user {
  display: flex; align-items: center; gap: 12px; padding: 16px 13px 16px 13px; border-top: 1px solid var(--border);
}
.user-avatar {
  flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; font-size: 16px;
}
.user-text { flex: 1; min-width: 0; line-height: 1.25; }
.user-name { font-size: 15.5px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 34px; height: 34px; padding: 0; justify-content: center; border: none; background: transparent; color: var(--muted); border-radius: 8px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border: none; }
.icon-btn .nav-icon { width: 19px; height: 19px; flex-basis: 19px; }
.whoami { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { flex: 1; min-width: 0; padding: 30px 36px 48px; max-width: 1280px; }
.page-head { margin-bottom: 18px; }
.page-head p { margin: 0; }
.tool-head { margin-bottom: 18px; }
.tool-head h1 { margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab {
  color: var(--muted); font-weight: 600; padding: 8px 14px; margin-bottom: -1px;
  border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--accent-hover); border-bottom-color: var(--accent); }
.page-lead { margin: 0 0 16px; }

/* ---------- элементы форм ---------- */
button, .button {
  font: inherit; font-weight: 600; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 16px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--border-strong); background: #e8eeea; color: var(--text); }
button:disabled { color: #a3b0a7; background: var(--surface); border-color: var(--border); cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.primary:disabled { background: #b7dfc4; border-color: #b7dfc4; color: #fff; }
button.danger { color: var(--error); }
button.danger:hover { border-color: #f3b4b4; background: #fef2f2; }
button.danger:disabled { color: #a3b0a7; }
button.link, a.link {
  background: none; border: none; padding: 2px 4px; color: var(--accent); font-weight: 500;
}
button.link:hover, a.link:hover { color: var(--accent-hover); background: none; text-decoration: underline; }
button.link.danger { color: var(--error); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 11px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
select { padding-right: 28px; min-width: 120px; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; padding: 0; }
textarea { width: 100%; resize: vertical; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
textarea::placeholder, input::placeholder { color: #9aa89f; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
.check-label { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.field-label { font-weight: 600; font-size: 13px; margin-bottom: 8px; display: block; }
.buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline-form input:not([type="checkbox"]) { flex: 1 1 180px; }

.alert { border-radius: var(--radius); padding: 11px 14px; margin-bottom: 14px; border: 1px solid; }
.alert.warn { background: #fffbeb; border-color: #fcd9a0; color: var(--warning); }
.alert.error { background: #fef2f2; border-color: #fbc4c4; color: var(--error); }

/* ---------- загрузки ---------- */
.composer { margin-bottom: 26px; }
.composer textarea { min-height: 140px; max-height: 320px; }
.composer-foot { display: flex; justify-content: space-between; margin: 8px 0 12px; }
.composer-foot .warn-count { color: var(--warning); }
.kbd-hint { font-size: 12px; }
.save-info { margin: 12px 0 0; font-size: 12.5px; }
.save-info .path { color: var(--text); }
.section-head { display: flex; align-items: baseline; gap: 10px; }
.empty { text-align: center; padding: 34px 0; }

.batch { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.batch-meta { color: var(--muted); font-size: 12px; margin: 4px 2px 0; }
.summary {
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
  background: var(--accent-soft); border: 1px solid #b7e2c5; border-radius: var(--radius); padding: 12px 16px;
}
.summary.has-errors { background: #fffbeb; border-color: #fcd9a0; }
.summary-title { font-weight: 700; font-size: 14.5px; }
.summary-stats { color: var(--muted); }
.summary-stats b.ok { color: var(--success); }
.summary-stats b.bad { color: var(--error); }
.summary-stats b.zero { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.job { padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.job-top { display: flex; gap: 12px; align-items: baseline; }
.job-title { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-status { font-weight: 600; white-space: nowrap; font-size: 13px; }
.job-url { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-bar { display: flex; align-items: center; gap: 10px; }
.bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; position: relative; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent-2); border-radius: 4px; transition: width .3s ease; }
.bar.indeterminate > span { width: 30%; position: absolute; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { left: -30%; } 100% { left: 100%; } }
.job.done .bar > span { background: var(--accent); }
.job.error .bar > span, .job.cancelled .bar > span { background: var(--error); }
.job.cancelled .bar > span { background: var(--muted); }
.pct { width: 42px; text-align: right; color: var(--muted); font-size: 12.5px; }
.job-bottom { display: flex; align-items: flex-start; gap: 8px; }
.job-detail { flex: 1; min-width: 0; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.job.error .job-detail { color: var(--error); }
.job-actions { display: flex; gap: 2px; }

.st-waiting { color: var(--muted); }
.st-resolving, .st-downloading, .st-processing { color: #0e7490; }
.st-done { color: var(--success); }
.st-error { color: var(--error); }
.st-cancelled { color: var(--muted); }

/* ---------- таблицы ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 0 1 300px; }
.spacer { flex: 1; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 9px 12px; border-bottom: 1px solid #edf1ee; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f7faf8; }
.table tr.selected { background: var(--accent-soft); }
.table .check { width: 34px; }
.table .num { text-align: right; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .date { white-space: nowrap; color: var(--muted); font-size: 12.5px; }
.cell-file { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-url { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.cell-url a { color: var(--muted); }
.cell-url a:hover { color: var(--accent); }
.missing { color: var(--muted); font-size: 12px; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge.admin { background: var(--accent-soft); color: var(--accent-hover); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; }

/* ---------- настройки ---------- */
.card.form { padding: 20px 22px; margin-bottom: 16px; max-width: 760px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 12px 0; border-bottom: 1px solid #edf1ee; }
.row:first-child { padding-top: 0; }
.row:last-child { border-bottom: none; padding-bottom: 0; }
.row .field-label { margin-bottom: 2px; }
.card.form .stack { max-width: 360px; }
.ok-text { color: var(--success); }
.warn-text { color: var(--warning); }
.err-text { color: var(--error); }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 30px 28px; display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { font-size: 21px; margin: 0; }
.login-card p { margin: 0; }
.login-card button { justify-content: center; margin-top: 4px; padding: 10px; }

/* ---------- диалог и уведомление ---------- */
dialog {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; width: min(380px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(20, 33, 26, .35); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: #14211a; color: #fff; border: 1px solid #14211a; border-radius: 10px; padding: 10px 16px;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #7f1d1d; border-color: #7f1d1d; color: #fff; }

/* ---------- телефон ---------- */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: auto; flex: none; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap;
    border-right: none; border-bottom: 1px solid var(--border); padding: 0 6px 6px; overflow: visible;
  }
  .sidebar-head { height: 52px; flex: 1 0 100%; border-bottom: none; padding: 0 8px; }
  .brand { font-size: 17px; }
  .brand img { width: 26px; height: 26px; flex-basis: 26px; }
  .nav { flex-direction: row; flex-wrap: wrap; padding: 0; gap: 2px; }
  .nav-tools { padding-top: 0; }
  .nav-link { height: 38px; padding: 0 10px; gap: 8px; font-size: 14px; }
  .nav-sub { display: none; }
  .sidebar-bottom { margin: 0; padding: 0; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .nav-system { padding-bottom: 0; }
  .sidebar-user { border-top: none; padding: 0 4px 0 8px; gap: 8px; }
  .user-avatar { width: 30px; height: 30px; flex-basis: 30px; font-size: 14px; }
  .user-role { display: none; }
  .content { padding: 20px 16px 40px; }
  .kbd-hint { display: none; }
  .summary { flex-direction: column; align-items: flex-start; }
  .row { flex-direction: column; align-items: flex-start; }
  .table .cell-url, #history-table th:nth-child(7), #users-table th:nth-child(6) { display: none; }
}

/* ---------- папки ---------- */
button.ghost { background: transparent; border-style: dashed; color: var(--accent); }
button.ghost:hover { background: var(--accent-soft); border-color: var(--accent); }
.buttons .spacer { flex: 1; }
.folder-pick { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--muted); font-size: 13px; }
.folder-pick select { min-width: 170px; }
.hint { margin: -4px 0 10px; }

.with-folders { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.folders {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 8px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 20px;
  max-height: calc(100vh - 40px); overflow-y: auto;
}
.folders-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 10px 4px; font-weight: 600; }
.folder-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: transparent;
  border: 1px solid transparent; border-radius: 8px; padding: 7px 10px; font-weight: 500; color: var(--text);
}
.folder-item::before {
  content: ""; flex: 0 0 14px; height: 11px; border-radius: 2px 3px 3px 3px; background: #c9d5cd;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .35);
}
.folder-item:hover { background: var(--surface-2); border-color: transparent; }
.folder-item.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.folder-item.active::before { background: var(--accent); }
.folder-item.drop { background: var(--accent-soft); border-color: var(--accent); border-style: dashed; }
.is-dragging .folder-item:not(.drop) { border-color: var(--border); border-style: dashed; }
.folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count { color: var(--muted); font-size: 12px; font-weight: 500; }
.folder-add { background: transparent; border: 1px dashed var(--border-strong); color: var(--accent); margin-top: 6px; justify-content: center; font-weight: 500; }
.folder-add:hover { background: var(--accent-soft); border-color: var(--accent); }
.folder-input { margin-top: 6px; width: 100%; }
.folder-tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px; padding: 8px 4px 2px; border-top: 1px solid var(--border); margin-top: 8px; font-size: 12.5px; }
.chip { display: inline-block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
  background: var(--accent-soft); color: var(--accent-hover); font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 99px; }
.cell-folder { white-space: nowrap; }
tr[draggable="true"] { cursor: grab; }
tr.dragging, .note-item.dragging { opacity: .45; }

/* ---------- заметки ---------- */
.row-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.notes-layout { display: grid; grid-template-columns: 210px 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.notes-list-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.notes-list-col input { width: 100%; }
.notes-list { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 220px); overflow-y: auto; }
.note-item {
  display: flex; flex-direction: column; align-items: stretch; gap: 3px; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  font-weight: 400; white-space: normal; cursor: pointer; box-shadow: var(--shadow);
}
.note-item:hover { border-color: var(--border-strong); background: var(--surface); }
.note-item.active { border-color: var(--accent); background: var(--accent-soft); }
.note-item-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item-snippet { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-item-date { color: #9aa89f; font-size: 11.5px; }
.editor { padding: 14px 18px 12px; display: flex; flex-direction: column; gap: 10px; min-height: 480px; }
.editor-bar { display: flex; align-items: center; gap: 10px; }
.editor-bar select { min-width: 160px; }
.note-title { border: none; padding: 4px 0; font-size: 22px; font-weight: 700; background: transparent; box-shadow: none !important; }
.note-body {
  flex: 1; min-height: 380px; border: none; padding: 4px 0; resize: none; background: transparent;
  font-family: var(--font); font-size: 15px; line-height: 1.6; box-shadow: none !important;
}
.editor-empty { display: grid; place-items: center; min-height: 300px; border: 1px dashed var(--border-strong); border-radius: var(--radius); }

@media (max-width: 1100px) {
  .notes-layout { grid-template-columns: 200px minmax(0, 1fr); }
  .notes-layout .editor, .notes-layout .editor-empty { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .with-folders, .notes-layout { grid-template-columns: minmax(0, 1fr); }
  .folder-main { min-width: 0; }
  .toolbar > * { flex: 1 1 140px; min-width: 0; }
  .with-folders .toolbar input[type="search"] { flex-basis: 100%; }
  .tool-head h1 { font-size: 23px; }
  .folders { position: static; max-height: none; flex-direction: row; flex-wrap: wrap; }
  .folder-item { width: auto; }
  .folders-label { display: none; }
  .folder-add, .folder-input { margin-top: 0; width: auto; }
  .folder-tools { width: 100%; }
  .row-head { flex-direction: column; align-items: flex-start; }
  .folder-pick { width: 100%; }
}

#history-table td[class^="st-"] { white-space: nowrap; }
.with-folders .toolbar input[type="search"] { flex: 1 1 220px; }
@media (max-width: 1300px) {
  #history-table .cell-url, #history-table th:nth-child(7) { display: none; }
}

/* ---------- Медиа ---------- */
.media-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.media-tree { padding: 6px; }
.tree-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; user-select: none; min-width: 0;
}
.tree-row:hover { background: var(--surface-2); }
.tree-row.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.tree-row.drop { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.tree-row.disabled { opacity: .4; cursor: not-allowed; }
.tree-toggle {
  flex: 0 0 18px; width: 18px; height: 18px; padding: 0; border: none; background: none; color: var(--muted);
  font-size: 12px; justify-content: center; border-radius: 4px;
}
.tree-toggle:hover { background: var(--border); }
.tree-toggle.empty { visibility: hidden; }
.tree-icon { flex: 0 0 15px; height: 11px; border-radius: 2px 3px 3px 3px; background: #c9d5cd; }
.tree-row.active .tree-icon { background: var(--accent); }
.tree-icon.home { background: var(--accent); border-radius: 3px; height: 13px; }
.tree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.media-main { position: relative; min-width: 0; min-height: 420px; }
.media-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.media-top input[type="search"] { flex: 0 1 280px; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; font-size: 15px; }
.crumb { background: none; border: 1px solid transparent; padding: 3px 8px; border-radius: 7px; font-weight: 600; color: var(--muted); }
.crumb:hover { background: var(--surface-2); color: var(--text); }
button.crumb { font-size: 15px; }
.crumb.current { color: var(--text); font-weight: 700; padding: 3px 8px; }
.crumb.drop { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.crumb-sep { color: #a3b0a7; }
.media-toolbar { margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg-btn { border: none; border-radius: 0; padding: 7px 11px; background: transparent; color: var(--muted); font-size: 15px; }
.seg-btn.active { background: var(--accent-soft); color: var(--accent-hover); }

.selection-bar {
  position: sticky; top: 10px; z-index: 3; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--text); color: #fff; border-radius: 10px; padding: 8px 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.selection-bar #sel-count { font-weight: 600; margin-right: 6px; }
.selection-bar .link { color: #9ff0c0; }
.selection-bar .link:hover { color: #fff; }
.selection-bar .link.danger { color: #ffb4b4; }

.media-items.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.tile {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 8px 10px;
  cursor: pointer; box-shadow: var(--shadow); min-width: 0; outline: none; transition: border-color .12s, box-shadow .12s;
}
.tile:hover { border-color: var(--border-strong); box-shadow: 0 4px 14px rgba(20, 33, 26, .08); }
.tile:focus-visible { border-color: var(--accent); }
.tile.selected { border-color: var(--accent); background: var(--accent-soft); }
.tile.drop { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.tile.dragging, .list-row.dragging { opacity: .45; }
.tile-check { position: absolute; top: 12px; left: 12px; z-index: 2; opacity: 0; transition: opacity .1s; }
.tile:hover .tile-check, .tile.selected .tile-check, .selecting .tile-check { opacity: 1; }
.tile-preview {
  position: relative; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--surface-2);
  display: grid; place-items: center; margin-bottom: 8px;
}
.tile-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kind-image .tile-preview img, .tile-preview.kind-image img { object-fit: cover; }
.folder-preview { background: transparent; }
.big-folder { width: 64%; height: 50%; border-radius: 6px 10px 10px 10px; background: linear-gradient(180deg, #4ade80, #16a34a); position: relative; box-shadow: 0 6px 14px rgba(22, 163, 74, .25); }
.big-folder::before { content: ""; position: absolute; left: 0; top: -9%; width: 40%; height: 20%; background: #22c55e; border-radius: 6px 6px 0 0; }
.tile-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta, .tile-path { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-path { color: #9aa89f; }
.badge-ext, .badge-dur {
  position: absolute; bottom: 6px; background: rgba(20, 33, 26, .72); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 2px 6px; border-radius: 5px; letter-spacing: .02em;
}
.badge-ext { left: 6px; }
.badge-dur { right: 6px; }
.play-mark {
  position: absolute; width: 38px; height: 38px; border-radius: 50%; background: rgba(255, 255, 255, .88);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
}
.play-mark::after {
  content: ""; position: absolute; left: 15px; top: 11px; border-left: 12px solid var(--accent-hover);
  border-top: 8px solid transparent; border-bottom: 8px solid transparent;
}
.kind-icon {
  width: 52%; aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px;
  background: linear-gradient(135deg, #86efac, #16a34a);
}
.kind-icon.audio { background: linear-gradient(135deg, #a7f3d0, #0f766e); border-radius: 50%; }
.kind-icon.image { background: linear-gradient(135deg, #bbf7d0, #65a30d); }
.kind-icon.video { background: linear-gradient(135deg, #6ee7b7, #15803d); }
.thumb-wait { color: var(--muted); font-size: 12px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }

.media-items.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.media-items.list:empty { display: none; }
.list-row {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) 160px 90px 150px; align-items: center; gap: 10px;
  padding: 7px 12px; border-bottom: 1px solid #edf1ee; cursor: pointer; min-width: 0;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: #f7faf8; }
.list-row.selected { background: var(--accent-soft); }
.list-row.drop { background: var(--accent-soft); outline: 1.5px dashed var(--accent); outline-offset: -2px; }
.list-head { cursor: default; color: var(--muted); font-size: 12.5px; font-weight: 600; background: var(--surface); }
.list-head:hover { background: var(--surface); }
.list-row .c-name { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 500; }
.list-row .c-type, .list-row .c-date, .list-row .c-by { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .c-size { text-align: right; color: var(--muted); font-size: 12.5px; }
.list-row .tile-check { position: static; opacity: 1; }
.list-row .tile-preview { flex: 0 0 40px; width: 40px; height: 30px; aspect-ratio: auto; margin: 0; border-radius: 5px; }
.list-row .kind-icon { width: 24px; font-size: 7px; border-radius: 5px; }
.list-row .kind-icon.audio { border-radius: 50%; }
.mini-folder { flex: 0 0 22px; height: 16px; border-radius: 3px 5px 5px 5px; background: linear-gradient(180deg, #4ade80, #16a34a); margin: 0 9px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.media-empty { text-align: center; padding: 60px 20px; color: var(--muted); border: 1.5px dashed var(--border-strong); border-radius: var(--radius); }
.media-empty p { margin: 6px 0; }
.empty-icon { width: 64px; height: 48px; margin: 0 auto 10px; border-radius: 8px 12px 12px 12px; background: var(--accent-soft); border: 2px solid #b7e2c5; }

.dropzone {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; text-align: center; padding: 20px;
  background: rgba(231, 246, 236, .92); border: 2.5px dashed var(--accent); border-radius: 14px; color: var(--accent-hover);
  font-size: 16px; pointer-events: none;
}

.uploads {
  position: fixed; right: 20px; bottom: 20px; z-index: 20; width: min(380px, calc(100vw - 40px)); max-height: 50vh;
  display: flex; flex-direction: column; padding: 12px 14px; box-shadow: 0 10px 30px rgba(20, 33, 26, .18);
}
.uploads-head { display: flex; align-items: center; margin-bottom: 8px; }
.uploads-list { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.up-row { display: flex; flex-direction: column; gap: 4px; }
.up-top { display: flex; gap: 8px; align-items: baseline; }
.up-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-status { flex: 0 1 auto; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-row.ok .up-status { color: var(--success); }
.up-row.ok .bar > span { background: var(--accent); }
.up-row.fail .up-status { color: var(--error); white-space: normal; }
.up-row.fail .bar > span { background: var(--error); width: 100% !important; }

dialog.viewer {
  width: min(1100px, calc(100vw - 32px)); max-width: none; height: min(820px, calc(100vh - 32px)); max-height: none;
  padding: 0; overflow: hidden; background: #0f1512; color: #fff; border: none; border-radius: 16px;
}
dialog.viewer[open] { display: flex; flex-direction: column; }
dialog.viewer::backdrop { background: rgba(10, 16, 12, .75); }
.viewer-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: #17201b; flex-wrap: wrap; }
.viewer-title { display: flex; flex-direction: column; min-width: 0; flex: 1 1 260px; }
.viewer-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-title .muted { color: #9fb3a7; }
.viewer-head button, .viewer-head .button { background: #24302a; border-color: #33423a; color: #e8f3ec; padding: 6px 12px; }
.viewer-head button:hover, .viewer-head .button:hover { background: #2e3c35; color: #fff; }
.viewer-head button.danger { color: #ffb4b4; }
.viewer-x { font-size: 16px; padding: 6px 10px !important; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 12px; }
.viewer-img, .viewer-video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #000; }
.viewer-video { width: 100%; height: 100%; }
.viewer-audio { display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(520px, 100%); }
.viewer-audio audio { width: 100%; }
.audio-art {
  width: 180px; height: 180px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 22px;
  background: radial-gradient(circle at 30% 30%, #86efac, #15803d 70%); box-shadow: 0 10px 40px rgba(34, 197, 94, .35);
}
.audio-name { font-weight: 600; text-align: center; overflow-wrap: anywhere; }
.viewer-fallback { display: flex; flex-direction: column; align-items: center; gap: 12px; color: #c9d8cf; text-align: center; }
.viewer-fallback .kind-icon { width: 96px; }
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; font-size: 34px; line-height: 1;
  background: rgba(255, 255, 255, .08); border: none; color: #fff; border-radius: 10px; justify-content: center; padding: 0;
}
.viewer-nav:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.viewer-nav.prev { left: 10px; }
.viewer-nav.next { right: 10px; }

dialog.picker { width: min(500px, calc(100vw - 32px)); }
.picker h2 { margin-bottom: 10px; }
.picker-tree { border: 1px solid var(--border); border-radius: 10px; max-height: 50vh; overflow-y: auto; padding: 6px; margin-bottom: 14px; }
.picker-buttons { align-items: center; }
.picker-buttons .spacer { flex: 1; }

@media (max-width: 980px) {
  .list-row { grid-template-columns: 34px minmax(0, 1fr) 80px 100px; }
  .list-row .c-type { display: none; }
}
@media (max-width: 760px) {
  .media-layout { grid-template-columns: minmax(0, 1fr); }
  .media-tree { position: static; max-height: 220px; }
  .media-items.grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .tile-check { opacity: 1; }
  .media-top input[type="search"] { flex: 1 1 100%; }
  .list-row { grid-template-columns: 30px minmax(0, 1fr) 70px; }
  .list-row .c-date { display: none; }
  .viewer-nav { width: 36px; height: 52px; }
}

/* ---------- Пароли ---------- */
.vault-gate { max-width: 460px; margin: 30px auto; padding: 28px 28px 22px; display: flex; flex-direction: column; gap: 12px; }
.vault-gate h2 { margin: 0; font-size: 21px; }
.vault-gate p { margin: 0; }
.vault-gate .link { align-self: center; }
.gate-icon { width: 54px; height: 54px; border-radius: 16px; background: var(--accent-soft); position: relative; }
.gate-icon::before {
  content: ""; position: absolute; left: 16px; top: 23px; width: 22px; height: 17px; border-radius: 4px; background: var(--accent);
}
.gate-icon::after {
  content: ""; position: absolute; left: 20px; top: 11px; width: 10px; height: 13px; border: 3px solid var(--accent);
  border-bottom: none; border-radius: 8px 8px 0 0;
}
.forgot-box { margin-top: 4px; }
.strength { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: -4px; }
.strength span { display: block; height: 100%; width: 0; border-radius: 3px; transition: width .2s; background: var(--error); }
.strength span.lvl1 { background: var(--warning); }
.strength span.lvl2 { background: #65a30d; }
.strength span.lvl3 { background: var(--accent); }

.vault-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.vault-top input[type="search"] { flex: 1 1 320px; max-width: 520px; font-size: 15px; padding: 10px 14px; }
#lock-timer { font-variant-numeric: tabular-nums; }
.vault-count { margin: 2px 2px 8px; }
.vault-list { display: flex; flex-direction: column; gap: 8px; }
.vault-item {
  display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
}
.vault-item:hover { border-color: var(--border-strong); }
.vault-item.dragging { opacity: .45; }
.vault-item.broken { border-color: #fbc4c4; background: #fff8f8; }
.vault-avatar { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #fff; }
.avatar-c0 { background: #16a34a; } .avatar-c1 { background: #0e7490; } .avatar-c2 { background: #7c3aed; } .avatar-c3 { background: #c2410c; }
.avatar-c4 { background: #be185d; } .avatar-c5 { background: #4d7c0f; } .avatar-c6 { background: #1d4ed8; } .avatar-c7 { background: #a16207; }
.vault-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.vault-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; }
.vault-name { font-weight: 700; font-size: 15px; }
.vault-domain { color: var(--muted); font-size: 12.5px; }
.vault-fields { display: flex; gap: 22px; flex-wrap: wrap; min-width: 0; }
.vault-field { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.vf-label { color: var(--muted); font-size: 12px; }
.vf-value { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.vf-value.mono { font-family: var(--mono); letter-spacing: .04em; }
.vf-value.revealed { background: #fffbeb; border-radius: 4px; padding: 0 4px; user-select: all; }
.vault-notes { color: var(--muted); font-size: 12.5px; white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.vault-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 540px; }
.item-dialog textarea { font-family: var(--font); font-size: 14px; }
.vbtn { padding: 6px 9px; font-size: 12.5px; font-weight: 600; border-radius: 8px; background: var(--surface); }
.vbtn.primary-ghost { color: var(--accent-hover); border-color: #b7e2c5; background: var(--accent-soft); }
.vbtn.primary-ghost:hover { background: #d7f0df; }
.vbtn.danger { color: var(--error); }
.vbtn.off { opacity: .4; pointer-events: none; }
.empty-icon.lock { border-radius: 14px; }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

dialog.item-dialog { width: min(520px, calc(100vw - 32px)); }
.item-dialog h2 { margin: 0; }
.item-dialog hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
.pw-field { display: flex; gap: 6px; }
.pw-field input { flex: 1; min-width: 0; font-family: var(--mono); }
.pw-field button { padding: 6px 10px; font-size: 12.5px; }

@media (max-width: 1180px) {
  .vault-item { grid-template-columns: 38px minmax(0, 1fr); }
  .vault-actions { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
  .vault-avatar { width: 38px; height: 38px; }
}

/* ---------- Планировщик ---------- */
body[data-page="planner"] .content { max-width: none; padding-left: 28px; padding-right: 28px; }
.planner-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 14px; }
.planner-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.planner-nav button { padding: 7px 13px; }
.planner-range { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.planner-range b { font-size: 16px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: stretch; }
.day {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 320px; min-width: 0; transition: border-color .15s, background .15s;
}
.day.past { background: #fafcfb; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.day.drop { border-color: var(--accent); background: var(--accent-soft); }
.day-head { display: flex; align-items: center; gap: 5px; padding: 10px 9px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; min-width: 0; }
.day-name { font-weight: 700; font-size: 13px; letter-spacing: .03em; }
.day-date { color: var(--muted); font-size: 13px; }
.day.today .day-name, .day.today .day-date { color: var(--accent-hover); }
.day-badge { background: var(--accent); color: #fff; font-size: 10px; font-weight: 600; border-radius: 6px; padding: 1px 5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.day-count { margin-left: auto; padding-left: 2px; color: var(--muted); font-size: 11.5px; }
.day-tasks { display: flex; flex-direction: column; gap: 5px; padding: 8px 6px 4px; }
.task {
  display: flex; gap: 7px; align-items: flex-start; padding: 6px 7px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer; min-width: 0; outline: none;
}
.task:hover, .task:focus-visible { border-color: var(--border-strong); background: #fbfdfc; }
.task:focus-visible { box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.task.dragging { opacity: .45; }
.task input[type="checkbox"] { margin: 1px 0 0; flex: 0 0 15px; cursor: pointer; }
.task-body { min-width: 0; flex: 1; }
.task-title { font-size: 13px; line-height: 1.35; overflow-wrap: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.task-time { color: var(--accent-hover); font-weight: 600; font-size: 12px; margin-right: 1px; font-variant-numeric: tabular-nums; }
.task-note { color: var(--muted); font-size: 11.5px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.task.done { background: var(--surface-2); border-color: transparent; }
.task.done .task-title { color: var(--muted); text-decoration: line-through; }
.task.done .task-time { color: var(--muted); }
.day-add {
  margin: 2px 6px 8px; justify-content: center; background: transparent; border: 1px dashed var(--border-strong);
  color: var(--muted); font-weight: 500; font-size: 12.5px; padding: 6px 4px;
}
.day-add:hover { color: var(--accent-hover); border-color: var(--accent); background: var(--accent-soft); }
.planner-hint { margin: 12px 2px 0; }
.task-when { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.task-when input { width: 100%; }
.task-move { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#task-form textarea { font-family: var(--font); font-size: 14px; }

@media (max-width: 1100px) and (min-width: 761px) {
  .week { grid-template-columns: repeat(7, minmax(150px, 1fr)); overflow-x: auto; padding-bottom: 6px; }
}
@media (max-width: 760px) {
  body[data-page="planner"] .content { padding-left: 16px; padding-right: 16px; }
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .planner-nav { width: 100%; }
  .planner-nav button { flex: 1; justify-content: center; padding: 7px 8px; font-size: 13px; }
  .planner-hint { display: none; }
  .wk-long { display: none; }
}
