/* MKA CRM — стили */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
:root {
  --bg: #0f1620; --panel: #17212c; --panel2: #1d2a38; --line: #2a3a4a;
  --text: #e6edf4; --muted: #8fa3b5; --accent: #3d8bfd; --accent2: #2f6fd0;
  --gold: #c9a45c; --red: #d45757; --green: #4bbf73;
  --r: 8px;
}
body { font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* вход */
.login-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--panel); padding: 36px 30px; border-radius: 12px; border: 1px solid var(--line); width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login-brand { text-align: center; font-size: 22px; font-weight: 700; color: var(--gold); letter-spacing: 1px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.login-card input { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; color: var(--text); font-size: 14px; }
.error { color: var(--red); font-size: 12px; min-height: 16px; }

/* app */
.app { display: flex; height: 100vh; }
.sidebar { width: 210px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; flex-shrink: 0; }
.brand { font-size: 18px; font-weight: 700; color: var(--gold); padding: 6px 10px 16px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav button { display: flex; align-items: center; gap: 10px; background: none; border: none; color: var(--muted); padding: 10px 12px; border-radius: var(--r); cursor: pointer; font-size: 14px; text-align: left; }
.sidebar nav button:hover { background: var(--panel2); color: var(--text); }
.sidebar nav button.active { background: var(--accent); color: #fff; }
.sidebar-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.sidebar-foot span { padding: 0 10px; }

.workspace { flex: 1; overflow: auto; padding: 20px 24px; }

/* кнопки */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 14px; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.ghost { background: none; border: none; color: var(--muted); padding: 6px 10px; }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn.danger { color: var(--red); }

/* заголовки и панели */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-head h1 { font-size: 20px; font-weight: 600; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 16px; }
.panel h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

/* таблицы */
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.data tr:hover td { background: var(--panel2); }
.cell-main { display: block; }
.cell-sub { display: block; color: var(--muted); font-size: 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; background: var(--panel2); border: 1px solid var(--line); }
.badge.todo { color: var(--muted); }
.badge.in_progress { color: var(--gold); }
.badge.done { color: var(--green); }
.row-actions { display: flex; gap: 4px; }
a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }

/* фильтр-табы */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }

/* календарь (самописный) */
.cal-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-title-inline { color: var(--muted); font-size: 13px; margin-left: 6px; }
.cal-wd { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0 8px; }

/* день */
.day-col { display: flex; flex-direction: column; }
.hour-row { display: flex; min-height: 44px; border-bottom: 1px solid var(--line); cursor: pointer; }
.hour-row:hover { background: var(--panel2); }
.hour-label { width: 52px; padding: 6px 8px; color: var(--muted); font-size: 11px; text-align: right; flex-shrink: 0; }
.hour-cell { flex: 1; display: flex; gap: 4px; flex-wrap: wrap; padding: 4px; align-content: flex-start; }

/* неделя */
.week-grid { display: grid; grid-template-columns: 52px repeat(7, 1fr); }
.wh-label { padding: 8px 6px; color: var(--muted); font-size: 11px; text-align: right; border-bottom: 1px solid var(--line); }
.whd { padding: 8px 4px; text-align: center; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; }
.whd .wd-name { color: var(--muted); font-size: 11px; }
.whd .wd-num { font-size: 16px; font-weight: 600; }
.whd.today { background: rgba(61,139,253,0.08); border-radius: 6px 6px 0 0; }
.wcell { min-height: 44px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 3px; cursor: pointer; display: flex; gap: 3px; flex-wrap: wrap; align-content: flex-start; }
.wcell:hover { background: var(--panel2); }

/* месяц */
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.mday { min-height: 90px; background: var(--panel); padding: 6px; cursor: pointer; }
.mday:hover { background: var(--panel2); }
.mday.other { background: var(--panel2); opacity: 0.4; }
.mday.today { box-shadow: inset 0 0 0 1px var(--gold); }
.mday-num { color: var(--muted); font-size: 12px; }
.mday-events { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.mday-events .more { color: var(--muted); font-size: 11px; }

/* событие */
.event-chip { color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* годовой вид */
.year-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mini-month { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; cursor: pointer; }
.mini-month:hover { border-color: var(--accent); }
.mini-month h4 { font-size: 13px; margin-bottom: 6px; color: var(--gold); }
.mini-month .wd { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--muted); font-size: 10px; margin-bottom: 2px; }
.mini-month .days { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; }
.mini-month .days span { padding: 2px 0; border-radius: 4px; }
.mini-month .days span.has-event { background: var(--accent); color: #fff; }
.mini-month .days span.today { outline: 1px solid var(--gold); }

/* модальные */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: 480px; max-width: 92vw; max-height: 90vh; overflow: auto; }
.modal h3 { margin-bottom: 14px; font-size: 16px; }
.modal form { display: flex; flex-direction: column; gap: 10px; }
.modal label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 12px; }
.modal input, .modal select, .modal textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; color: var(--text); font-size: 14px; font-family: inherit; }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* toast */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; z-index: 200; }

.empty { color: var(--muted); padding: 20px; text-align: center; }
