/* Стили платформенной админки (api.workab.ru). Вынесены во внешний файл (не inline <style>),
   чтобы CSP style-src мог со временем стать таким же строгим, как script-src — см. журнал. */
:root {
  color-scheme: dark;
  --bg: #101014; --panel: #17171c; --panel2: #1c1c22; --border: #26262e; --border2: #2c2c36;
  --ink: #e8e8ec; --muted: #8a8a96; --accent: #ff6a1a; --danger: #ff6a6a; --ok: #3ddc84; --warn: #ffb43c;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ---- экран входа ---- */
#loginWrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.card {
  width: 100%; max-width: 360px; padding: 32px; margin: 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.card h1 { font-size: 16px; font-weight: 600; margin: 0 0 4px; color: #fff; }
.card .sub { font-size: 12px; color: var(--muted); margin: 0 0 24px; }
label { display: block; font-size: 12px; color: #a8a8b4; margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; background: #0d0d10; border: 1px solid var(--border2);
  border-radius: 8px; color: #fff; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.btn { border: none; border-radius: 8px; padding: 10px 16px; font-size: 13px; cursor: pointer; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-p { background: var(--accent); color: #fff; font-weight: 600; }
.btn-g { background: var(--panel2); color: var(--ink); border: 1px solid var(--border2); }
#loginForm .btn-p { width: 100%; margin-top: 20px; padding: 11px; }
.err { margin-top: 14px; font-size: 13px; color: var(--danger); display: none; }

/* ---- каркас приложения ---- */
#appShell { display: none; min-height: 100vh; }
#appShell.on { display: flex; }
.sidebar {
  width: 220px; flex: 0 0 220px; background: var(--panel); border-right: 1px solid var(--border);
  padding: 20px 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 0 20px 20px; font-weight: 600; color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar button.navitem {
  all: unset; cursor: pointer; padding: 10px 20px; color: var(--muted); font-size: 13px; box-sizing: border-box;
}
.sidebar button.navitem:hover { color: var(--ink); }
.sidebar button.navitem.on { color: #fff; background: var(--panel2); border-left: 2px solid var(--accent); padding-left: 18px; }
.sidebar .logout { margin-top: auto; padding: 10px 20px; }
.main { flex: 1; padding: 24px 28px; overflow: auto; min-width: 0; }
.main h2 { margin-top: 0; font-size: 18px; }

.metrics { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.metric-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; min-width: 140px; }
.metric-card .n { font-size: 24px; font-weight: 700; }
.metric-card .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=text] { flex: 1; min-width: 200px; }

.tblwrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; padding: 8px 10px; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.link { cursor: pointer; color: var(--ink); }
.link:hover { color: var(--accent); text-decoration: underline; }
.pill { padding: 2px 8px; border-radius: 20px; font-size: 11px; white-space: nowrap; }
.pill.active { background: rgba(61,220,132,.15); color: var(--ok); }
.pill.trial { background: rgba(255,180,60,.15); color: var(--warn); }
.pill.grace { background: rgba(255,180,60,.15); color: var(--warn); }
.pill.locked { background: rgba(255,106,106,.15); color: var(--danger); }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; font-size: 13px; color: var(--muted); }

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

/* ---- модалка ---- */
#scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; z-index: 40; }
#scrim.on { display: block; }
#modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; z-index: 41; }
#modal.on { display: flex; }
#modalBox { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 24px; max-width: 420px; width: 100%; max-height: 90vh; overflow: auto; }
#modalBox h2 { font-size: 16px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--border); max-width: 640px; }
.switch { position: relative; width: 44px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border2); border-radius: 24px; cursor: pointer; transition: .15s; }
.switch .slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2);
  border: 1px solid var(--border2); padding: 10px 18px; border-radius: 8px; font-size: 13px;
  display: none; z-index: 50; max-width: 90vw;
}
