/* Общие стили в духе Office: зелёный цвет таблиц, шрифт Segoe UI, элементы Fluent.
   Фирменный цвет меняется в --accent (и оттенках рядом). */
:root {
  --accent: #107c41;
  --accent-hover: #0c6b37;
  --accent-pressed: #0a5a2e;
  --accent-dark: #0b5f31;
  --accent-50: #ebf5ef;
  --accent-100: #d5ebdd;
  --accent-200: #a8d5b9;
  --text: #242424;
  --text-2: #424242;
  --muted: #616161;
  --line: #e0e0e0;
  --line-strong: #d1d1d1;
  --bg: #f5f5f5;
  --bg-2: #fafafa;
  --panel: #ffffff;
  --hover: #f0f0f0;
  --pressed: #e0e0e0;
  --danger: #c42b1c;
  --ok: #107c10;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow: 0 8px 16px rgba(0, 0, 0, 0.14), 0 0 2px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 14px 28px rgba(0, 0, 0, 0.18), 0 0 4px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 2px rgba(0, 0, 0, 0.1);
  --font: "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.43 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, ui-monospace, SFMono-Regular, Menlo, monospace; }
.pad { padding: 12px; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.row > .input { flex: 1; min-width: 0; }
.fi { display: block; width: 20px; height: 20px; flex: 0 0 auto; }

/* логотип */
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 16px; }
.logo-mark { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; background: var(--accent); color: #fff; font: 700 18px/1 Georgia, "Times New Roman", serif; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18); flex: 0 0 auto; }
.logo-mark.big { width: 48px; height: 48px; border-radius: 10px; font-size: 30px; }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; min-width: 80px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: #fff; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none; color: var(--text); transition: background 0.1s, border-color 0.1s; }
.btn:hover { background: var(--bg); border-color: #c7c7c7; }
.btn:active { background: var(--pressed); }
.btn:focus-visible { outline: 2px solid #000; outline-offset: 1px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; }
.btn-primary:active { background: var(--accent-pressed); }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger:hover { background: #a52518; }
.btn-ghost { background: transparent; border-color: transparent; min-width: 0; }
.btn-ghost:hover { background: var(--hover); border-color: transparent; }
.btn-block { width: 100%; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 13px; min-width: 0; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; color: var(--text-2); padding: 0; flex: 0 0 auto; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { background: var(--pressed); }
.icon-btn svg { width: 20px; height: 20px; }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* поля */
.input { height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-bottom-color: #8a8a8a; border-radius: var(--radius); background: #fff; outline: none; width: 100%; transition: border-color 0.1s, box-shadow 0.1s; }
.input:hover { border-color: #c7c7c7; border-bottom-color: #616161; }
.input:focus { border-color: var(--line-strong); border-bottom-color: var(--accent); box-shadow: inset 0 -1px 0 var(--accent); }
.input:disabled { background: var(--bg-2); color: var(--muted); }
textarea.input { height: auto; padding: 6px 10px; resize: vertical; }
.input-sm { height: 26px; font-size: 13px; }
.input-narrow { width: auto; flex: 0 0 auto; }
select.input { padding-right: 6px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 14px; color: var(--text); font-weight: 400; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* аватары */
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 0; background: #5c2e91; color: #fff; font-weight: 600; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto; }
.avatar.more { background: #8a8a8a; cursor: default; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent-50); color: var(--accent-dark); font-size: 11px; font-weight: 600; margin-left: 8px; }

/* меню */
.menu { position: fixed; z-index: 1000; min-width: 200px; max-width: 440px; max-height: calc(100vh - 16px); overflow: auto; background: #fff; border: 1px solid rgba(0, 0, 0, 0.06); border-radius: 6px; box-shadow: var(--shadow); padding: 4px; outline: none; }
.menu-item { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 32px; padding: 3px 10px 3px 4px; border-radius: 4px; cursor: pointer; border: 0; background: none; text-align: left; font-size: 14px; white-space: nowrap; color: var(--text); }
.menu-item.active, .menu-item:hover { background: var(--hover); }
.menu-item.disabled { color: #bdbdbd; cursor: default; }
.menu-item.disabled:hover { background: none; }
.menu-item.disabled .menu-icon { color: #c7c7c7; }
.menu-check { width: 16px; color: var(--text); font-size: 12px; text-align: center; flex: 0 0 auto; }
.menu-icon { width: 20px; height: 20px; display: inline-flex; justify-content: center; align-items: center; color: var(--text-2); flex: 0 0 auto; }
.menu-icon svg { width: 20px; height: 20px; }
.menu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; padding-left: 2px; }
.menu-hint { color: var(--muted); font-size: 12px; margin-left: 24px; }
.menu-arrow { color: var(--muted); font-size: 16px; line-height: 1; }
.menu-sep { height: 1px; background: var(--line); margin: 4px -4px; }
.menu-title { padding: 6px 10px 6px; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-section { padding: 6px 10px 4px; font-size: 12px; font-weight: 600; color: var(--text); background: var(--bg-2); margin: 0 -4px 4px; border-bottom: 1px solid var(--line); }

/* палитра (как в Office: цвета темы и стандартные) */
.color-picker { padding: 4px 6px 6px; width: 236px; }
.cp-auto { display: flex; align-items: center; gap: 8px; width: 100%; height: 28px; border: 1px solid transparent; background: none; cursor: pointer; padding: 0 6px; border-radius: 4px; font-size: 13px; }
.cp-auto:hover { background: var(--hover); }
.cp-auto i { width: 16px; height: 16px; border: 1px solid #c8c8c8; display: inline-block; }
.cp-title { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 8px 2px 4px; }
.palette { display: grid; grid-template-columns: repeat(10, 18px); column-gap: 4px; row-gap: 0; justify-content: space-between; }
.palette.std { row-gap: 0; }
.palette .swatch + .swatch { }
.swatch { width: 18px; height: 18px; border: 1px solid rgba(0, 0, 0, 0.12); cursor: pointer; padding: 0; border-radius: 0; }
.palette.theme .swatch.first { margin-bottom: 5px; }
.swatch:hover { outline: 2px solid #f0a30a; outline-offset: -1px; position: relative; z-index: 1; }
.color-custom { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 4px 6px; margin-top: 6px; border-radius: 4px; }
.color-custom:hover { background: var(--hover); }
.color-input { width: 22px; height: 20px; border: 0; padding: 0; background: none; cursor: pointer; }
.cp-recent { display: flex; gap: 4px; flex-wrap: wrap; }

/* окна */
.dlg-back { position: fixed; inset: 0; z-index: 900; background: rgba(0, 0, 0, 0.4); display: flex; align-items: flex-start; justify-content: center; padding: 9vh 16px 16px; overflow: auto; animation: fade 0.1s; }
.dlg { width: 480px; max-width: 100%; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-height: 84vh; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px 24px; cursor: default; }
.dlg-title { font-size: 20px; font-weight: 600; line-height: 1.3; }
.dlg-x { width: 32px; height: 32px; font-size: 16px; }
.dlg-body { padding: 10px 24px; overflow: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px 20px; }
.dlg-text { margin: 0; line-height: 1.5; }
@keyframes fade { from { opacity: 0; } }

/* уведомления */
.toasts { position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #fff; color: var(--text); padding: 10px 16px; border-radius: 6px; box-shadow: var(--shadow); font-size: 14px; max-width: min(560px, 90vw); transition: opacity 0.3s, transform 0.3s; animation: up 0.18s; border-left: 4px solid var(--accent); }
.toast-error { border-left-color: var(--danger); }
.toast.hide { opacity: 0; transform: translateY(6px); }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }

/* окно «Поделиться» */
.share-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.share-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.share-row:last-child { border-bottom: 0; }
.share-who { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.share-who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.share-who span { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.share-sep { height: 1px; background: var(--line); }

.empty-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 24px; }
.empty-page h1 { margin: 10px 0 0; font-size: 22px; font-weight: 600; }
.empty-page p { margin: 0 0 12px; color: var(--muted); max-width: 440px; }

@media (max-width: 640px) { .hide-sm { display: none !important; } }

/* вкладки и группы в окнах (как в «Формате ячеек» Excel) */
.dlg-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 14px; flex-wrap: wrap; }
.dlg-tabs button { border: 0; background: none; padding: 8px 10px; font-size: 14px; cursor: pointer; color: var(--text-2); position: relative; border-radius: 4px 4px 0 0; }
.dlg-tabs button:hover { background: var(--hover); }
.dlg-tabs button.active { color: var(--text); font-weight: 600; }
.dlg-tabs button.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 2px; background: var(--accent); }
.dlg-fs { border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px 10px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.dlg-fs legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.dlg-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.kbd-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13px; }
.kbd-list kbd { font: 12px/1.6 var(--font); background: #f3f3f3; border: 1px solid #d1d1d1; border-bottom-width: 2px; border-radius: 4px; padding: 0 6px; white-space: nowrap; }
.kbd-group { grid-column: 1 / -1; font-weight: 600; margin-top: 10px; }
.sym-grid { display: grid; grid-template-columns: repeat(16, 30px); gap: 2px; max-height: 300px; overflow: auto; }
.sym-grid button { width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 16px; padding: 0; }
.sym-grid button:hover, .sym-grid button.active { border-color: var(--accent); background: var(--accent-50); }
