/* papka.ai cabinet — the style guide (docs/ui): Manrope everywhere, one accent green, borders
   only on the outer contour of cards, dividers a tone lighter inside, a shadow only on the
   floating layer, everything else flat on the gradient background. */
:root {
  --ink: #1b2b17;         /* main text, the sidebar's dark base */
  --ink-soft: #33422f;    /* secondary text in tables */
  --muted: #5c6b57;       /* labels, column headers */
  --muted-2: #7d8f78;     /* section labels in the sidebar, faint hints */
  --accent: #b8e088;      /* buttons, the active menu item, «.ai» */
  --accent-ink: #2f5d19;  /* switches, the chosen day, icons */
  --accent-soft: #e7f3d6; /* circles under the stat icons */
  --line: #e3e6da;        /* card border */
  --line-2: #eceee4;      /* row dividers inside cards */
  --field: #d5dbc9;       /* input and secondary button border */
  --card: #ffffff;
  --row-hover: #f8faf3;
  /* aliases the older rules still use */
  --green-900: #132010;
  --green-800: var(--ink);
  --green-700: #26401f;
  --green-600: #2f5d19;
  --green-500: #2f5d19;
  --green-400: #3f6a1f;
  --lime: var(--accent);
  --lime-50: var(--accent-soft);
  --lime-100: #d9ecc1;
  --bg: #f7f9f0;
  --panel: var(--card);
  --input: var(--field);
  --nav-text: #ffffff;
  --ok-bg: #e7f3d6;  --ok-fg: #2f5d19;
  --err-bg: #fde8e6; --err-fg: #8f1d14;
  --warn-bg: #ffe2c2; --warn-fg: #7a3e00;
  --font: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 500 14px/1.4 var(--font);
  background:
    radial-gradient(900px 600px at 85% 0%, #e4efd2 0%, rgba(228, 239, 210, 0) 70%),
    linear-gradient(160deg, #f7f9f0 0%, #eef2e2 55%, #e9eedb 100%);
  background-attachment: fixed;
  color: var(--ink);
}
a { color: var(--green-800); }
a:hover { color: var(--green-900); }

.shell { display: flex; min-height: 100vh; }

/* ---- left panel ------------------------------------------------------ */
.nav {
  width: 240px; flex-shrink: 0;
  background:
    radial-gradient(420px 320px at 0% 100%, rgba(184, 224, 136, .22) 0%, rgba(184, 224, 136, 0) 70%),
    linear-gradient(180deg, #132010 0%, #1b2b17 50%, #26401f 100%);
  color: #fff;
  display: flex; flex-direction: column; gap: 4px;
  padding: 24px 16px;
  position: sticky; top: 0; height: 100vh;
}
.nav__bar { display: flex; align-items: center; justify-content: space-between; }
.nav__panel { display: flex; flex-direction: column; gap: 4px; flex-grow: 1; min-height: 0; }
.nav__burger { display: none; }
.nav__logo {
  font-family: var(--font-display); font-weight: 800; font-size: 26px; letter-spacing: -.5px;
  color: #fff; padding: 2px 10px 16px;
}
.nav__logo span { color: var(--lime); }
.nav__item {
  display: flex; align-items: center; gap: 10px; padding: 12px 10px; border-radius: 10px;
  color: #fff; text-decoration: none;
}
.nav__icon { flex: none; color: var(--accent); }
.nav__item.is-active .nav__icon { color: var(--accent-ink); }
.nav__item:hover { background: rgba(184, 224, 136, .12); color: #fff; }
.nav__item.is-active { background: var(--accent); color: var(--ink); font-weight: 600; }
.nav__item--muted { color: #c6d9b8; font-size: 13px; }
.nav__section--first { padding-top: 4px; }
.nav__section {
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: #7d8f78; padding: 18px 10px 6px;
}
.nav__spacer { flex-grow: 1; }
.nav__user { border-top: 1px solid rgba(184, 224, 136, .25); padding: 12px 0 0; margin-top: auto; position: relative; }
.account { position: relative; }
.account > summary { list-style: none; }
.account > summary::-webkit-details-marker { display: none; }
.account__btn {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px; border-radius: 10px; cursor: pointer; color: #fff;
}
.account__btn:hover, .account[open] .account__btn { background: rgba(184, 224, 136, .12); }
.account__btn > .nav__icon { color: #c6d9b8; }
.account__btn > svg:last-child { margin-left: auto; color: #7d8f78; flex: none; }
.account__text { display: flex; flex-direction: column; min-width: 0; }
.account__name { font-weight: 600; font-size: 13px; }
.account__email { font-size: 11px; color: #a9b8a3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account__menu {
  display: none; position: absolute; left: calc(100% + 10px); bottom: 0; z-index: 45; min-width: 180px;
  background: var(--card); border: 1px solid var(--field); border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 32px rgba(27, 43, 23, .16);
}
.account:hover .account__menu, .account[open] .account__menu { display: flex; flex-direction: column; gap: 2px; }
.account__item {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 13px;
}
.account__item:hover { background: var(--row-hover); }
.account__item svg { color: var(--accent-ink); }
.account__item--danger, .account__item--danger svg { color: var(--err-fg); }
.account__item--danger:hover { background: var(--err-bg); }
.nav__user-email {
  display: block; padding: 0 10px 6px; font-size: 13px; color: #c6d9b8;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.mailbox-switch {
  display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 10px 12px;
  border: 0; border-radius: 12px;
  background: #263a21; color: #fff; font: inherit; text-align: left;
  margin-bottom: 16px; cursor: pointer; width: 100%; text-decoration: none;
}
.mailbox-switch:hover { color: #fff; background: #2c4426; }
.mailbox-menu { position: relative; margin-bottom: 16px; }
.mailbox-menu > .mailbox-switch { margin-bottom: 0; list-style: none; }
.mailbox-menu > .mailbox-switch::-webkit-details-marker { display: none; }
.mailbox-menu[open] > .mailbox-switch svg { transform: rotate(180deg); }
.mailbox-menu__list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 10;
  background: #263a21; border: 1px solid rgba(184, 224, 136, .25); border-radius: 12px;
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
  box-shadow: 0 12px 32px rgba(27, 43, 23, .35);
}
.mailbox-menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--nav-text);
  font: inherit; text-align: left; cursor: pointer; text-decoration: none;
}
.mailbox-menu__item:hover { background: rgba(184, 224, 136, .14); color: #fff; }
.mailbox-menu__item .mailbox-switch__avatar { width: 24px; height: 24px; font-size: 11px; }
.mailbox-menu__name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailbox-menu__item--manage { font-size: 13px; color: var(--accent); border-top: 1px solid rgba(184, 224, 136, .25); border-radius: 0 0 8px 8px; margin-top: 4px; padding-top: 10px; }
.mailbox-switch__icon {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 9px;
  background: var(--accent); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
}
.mailbox-switch__avatar {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%;
  background: var(--accent); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.mailbox-switch__text { display: flex; flex-direction: column; gap: 1px; flex-grow: 1; min-width: 0; }
.mailbox-switch__name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailbox-switch__hint { font-size: 11px; color: #a9b8a3; }

/* ---- main ------------------------------------------------------------ */
.main {
  flex-grow: 1; min-width: 0;
  padding: 28px 32px; display: flex; flex-direction: column; gap: 20px;
  max-width: 1480px;  /* wide enough for two panels side by side; still not edge to edge on a big monitor */
}
.page-header { display: flex; align-items: center; gap: 16px; }
.page-title {
  margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 800;
  letter-spacing: -.3px;
}
.page-count { color: var(--muted); }
.grow { flex-grow: 1; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
}
.empty { padding: 40px 32px; text-align: center; }
.empty__text { font-weight: 600; font-size: 15px; }
.empty__hint { color: var(--muted); font-size: 13px; margin-top: 6px; max-width: 560px; margin-inline: auto; }

.muted { color: var(--muted); }
.ml { margin-left: 12px; }
.small { font-size: 13px; }
p.muted { margin: 0; }

/* ---- buttons, pills, inputs ------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; height: 40px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--field); background: var(--card);
  color: var(--ink); text-decoration: none; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--row-hover); }
.btn--primary { background: var(--accent); border-color: var(--accent); }
.btn--primary:hover { background: #c4e69a; }
.btn--outline { border-color: var(--green-800); }
.btn--sm { height: 36px; padding: 0 14px; }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.pill--ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill--err { background: var(--err-bg); color: var(--err-fg); }
.pill--warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill--neutral { background: #e8ece4; color: var(--green-600); }
.pill--green { background: #dff3cf; color: #1f5a25; }
.pill--lime { background: var(--lime); color: var(--green-800); }
.pill--blue { background: #dbe9ff; color: #1e3f8a; }
.pill--yellow { background: #fff3c4; color: #6b5300; }
.pill--orange { background: #ffe2c2; color: #7a3e00; }
.pill--red { background: #fde8e6; color: #8f1d14; }
.pill--purple { background: #ece3ff; color: #4b2a8a; }
.pill--grey { background: #e8ece4; color: var(--green-600); }
/* tag color picker: the select takes the chosen color (CSS :has), options are tinted too */
select.color-pick:has(option[value="green"]:checked) { background-color: #dff3cf; color: #1f5a25; border-color: #dff3cf; }
select.color-pick option[value="green"] { background: #dff3cf; color: #1f5a25; }
select.color-pick:has(option[value="lime"]:checked) { background-color: #a3e26f; color: #173219; border-color: #a3e26f; }
select.color-pick option[value="lime"] { background: #a3e26f; color: #173219; }
select.color-pick:has(option[value="blue"]:checked) { background-color: #dbe9ff; color: #1e3f8a; border-color: #dbe9ff; }
select.color-pick option[value="blue"] { background: #dbe9ff; color: #1e3f8a; }
select.color-pick:has(option[value="yellow"]:checked) { background-color: #fff3c4; color: #6b5300; border-color: #fff3c4; }
select.color-pick option[value="yellow"] { background: #fff3c4; color: #6b5300; }
select.color-pick:has(option[value="orange"]:checked) { background-color: #ffe2c2; color: #7a3e00; border-color: #ffe2c2; }
select.color-pick option[value="orange"] { background: #ffe2c2; color: #7a3e00; }
select.color-pick:has(option[value="red"]:checked) { background-color: #fde8e6; color: #8f1d14; border-color: #fde8e6; }
select.color-pick option[value="red"] { background: #fde8e6; color: #8f1d14; }
select.color-pick:has(option[value="purple"]:checked) { background-color: #ece3ff; color: #4b2a8a; border-color: #ece3ff; }
select.color-pick option[value="purple"] { background: #ece3ff; color: #4b2a8a; }
select.color-pick:has(option[value="grey"]:checked) { background-color: #e8ece4; color: #234427; border-color: #e8ece4; }
select.color-pick option[value="grey"] { background: #e8ece4; color: #234427; }

.input, select.input, textarea.input {
  height: 36px; padding: 0 10px; border: 1px solid var(--field); border-radius: 8px;
  font: inherit; background: var(--panel); color: inherit;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
/* selects: our own chevron, pinned right; the opened list is native and takes only font/color */
select.input, .sel__btn {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235f7361' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
select.input:focus { outline: 2px solid var(--lime); outline-offset: 1px; border-color: var(--green-500); }
select.input option, select.input optgroup { font: 14px var(--font); color: var(--green-800); background: var(--panel); padding: 6px 8px; }
select.input optgroup { font-weight: 600; color: var(--muted); }

/* ---- styled dropdowns (static/select.js) ----------------------------- */
.sel { position: relative; display: block; min-width: 0; }
.sel__native {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
  left: 0; bottom: 0; /* still focusable, so «required» validation has an anchor */
}
.sel__btn { width: 100%; display: flex; align-items: center; text-align: left; }
.sel__label { flex-grow: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel__btn[aria-expanded="true"] { border-color: var(--green-500); box-shadow: 0 0 0 2px var(--lime-50); }
.sel__btn[aria-expanded="true"] { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23173219' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m18 15-6-6-6 6'/></svg>"); }
.sel__list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  max-height: 280px; overflow-y: auto; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 34px rgba(23, 50, 25, .14);
}
.sel__item { padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.sel__item:hover { background: var(--lime-50); }
.sel__item.is-selected { background: var(--lime); color: var(--green-800); font-weight: 600; }
.sel__item.is-selected .pill { outline: 2px solid var(--green-800); }
.sel__group { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted-2); padding: 8px 10px 4px; }
.sel--sm .sel__list { max-height: 220px; }
.sel__btn--green { background-color: #dff3cf; color: #1f5a25; border-color: #dff3cf; }
.sel__btn--lime { background-color: #a3e26f; color: #173219; border-color: #a3e26f; }
.sel__btn--blue { background-color: #dbe9ff; color: #1e3f8a; border-color: #dbe9ff; }
.sel__btn--yellow { background-color: #fff3c4; color: #6b5300; border-color: #fff3c4; }
.sel__btn--orange { background-color: #ffe2c2; color: #7a3e00; border-color: #ffe2c2; }
.sel__btn--red { background-color: #fde8e6; color: #8f1d14; border-color: #fde8e6; }
.sel__btn--purple { background-color: #ece3ff; color: #4b2a8a; border-color: #ece3ff; }
.sel__btn--grey { background-color: #e8ece4; color: #234427; border-color: #e8ece4; }
.label { font-size: 12px; color: var(--muted); }
.input::placeholder { color: #b3c2b0; opacity: 1; }
.mono { font-family: var(--font-mono); font-size: 12px; }

/* ---- sections, mailbox rows ------------------------------------------ */
.section { padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; }
.section__title { font-family: var(--font-display); font-size: 18px; font-weight: 800; margin: 0; }
.mbx { display: flex; align-items: center; gap: 14px; padding: 14px 20px; }
.mbx + .mbx { border-top: 1px solid var(--line-2); }
.mbx__avatar {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%;
  background: var(--lime-50); color: var(--green-800);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.mbx__avatar--logo { background: var(--panel); border: 1px solid var(--line); }
.mbx__avatar--logo img { width: 22px; height: 22px; display: block; }
.mbx__text { flex-grow: 1; min-width: 0; }
.mbx__name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.mbx__err { color: var(--err-fg); margin-top: 4px; }
.mbx__actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn--danger { color: var(--err-fg); border-color: #efc7c2; }
.btn--danger:hover { background: var(--err-bg); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inline-form { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.input--sm { height: 32px; font-size: 13px; max-width: 360px; }
/* Model IDs are often long (for example, gpt-5.3-turbo-1106); do not size this
   selector from the currently selected option. */
.input--model { width: min(360px, 100%); min-width: 260px; }
.sel--model { width: min(360px, 100%); min-width: 260px; }
.sel--model .sel__btn { width: 100%; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--green-800); }

/* ---- dashboard ------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat { padding: 18px 20px; display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
a.stat:hover { background: var(--row-hover); }
.stat__icon {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center;
}
.stat__text { display: flex; flex-direction: column; min-width: 0; }
.stat__value { font-family: var(--font-display); font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat__of { font-size: 14px; color: var(--muted-2); font-weight: 700; }
.stat__label { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row-link:hover td { background: var(--row-hover); }
.row-link__status { text-decoration: none; }
.dash-status { white-space: nowrap; }
.dash-run { display: inline-block; vertical-align: middle; margin-left: 6px; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border-radius: 50%; border: 1px solid var(--field); background: var(--card); color: var(--accent-ink);
  cursor: pointer; padding: 0; opacity: .55; transition: opacity .12s;
}
.row-link:hover .btn-icon, .btn-icon:focus-visible { opacity: 1; }
.btn-icon--lg { width: 36px; height: 36px; opacity: 1; }
.btn-icon--danger:hover { background: var(--err-bg); border-color: #efc7c2; color: var(--err-fg); }
.modal__box:has(.form) { max-width: 640px; }
.modal .form { display: flex; flex-direction: column; gap: 12px; }
.modal__actions--between { justify-content: space-between; }
.btn-icon:hover { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.modal__actions--row { align-items: center; gap: 10px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; }
.table--tight th, .table--tight td { padding: 8px 10px; }
.msglist { display: flex; flex-direction: column; }
.msgrow { padding: 10px 0; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 2px; }
.msgrow:last-child { border-bottom: 0; }
.msgrow__top { display: flex; justify-content: space-between; gap: 10px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.pill--x { display: inline-flex; align-items: center; gap: 4px; padding-right: 4px; }
.pill__x { border: 0; background: transparent; color: inherit; opacity: .55; cursor: pointer; font: inherit; line-height: 1; padding: 0 3px; border-radius: 999px; }
.pill__x:hover { opacity: 1; background: rgba(0, 0, 0, .08); }

/* ---- tables, job card ------------------------------------------------ */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 12px 18px; border-bottom: 1px solid var(--line-2); }
.table td { padding: 14px 18px; border-bottom: 1px solid var(--line-2); vertical-align: top; color: var(--ink-soft); }
.table td .strong, .table td a.strong { color: var(--ink); }
.table tr:last-child td { border-bottom: 0; }
.strong { font-weight: 600; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; white-space: nowrap; }
.crumb { color: var(--muted); text-decoration: none; font-weight: 700; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--green-800); text-decoration: underline; cursor: pointer; }
.form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
.subblock {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px 16px; margin: 4px 0 0;
  background: #fafbf8;
}
.subblock__title { font-size: 13px; font-weight: 600; padding: 0 6px; }
.form-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.field--inline { flex-direction: row; align-items: center; gap: 8px; }
.field--note { justify-content: flex-end; }
.folder-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 8px 10px; border: 1px solid var(--input); border-radius: 10px; max-height: 190px; overflow-y: auto; background: var(--panel); }
/* block 4 follows the mode: tag rows for «по одному письму», report action for «все разом» */
.job-form:has(input[name="mode"][value="whole"]:checked) .per-message-only { display: none; }
.job-form:not(:has(input[name="mode"][value="whole"]:checked)) .whole-only { display: none; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-switch label { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--input); border-radius: 12px; cursor: pointer; }
.mode-switch label:has(input:checked) { border-color: var(--green-800); background: var(--lime-50); }
.mode-switch input { margin-top: 3px; accent-color: var(--green-800); }
.mode-switch .strong { display: block; }
.section__subtitle { font-size: 14px; font-weight: 700; margin: 6px 0 0; }
/* custom period dates appear only when that option is selected (no JS: CSS :has) */
.period-custom { display: none; }
.section:has(select[name="period"] option[value="custom"]:checked) .period-custom { display: grid; }
.form-row--right { justify-content: flex-end; margin-top: -8px; }
.input--num { width: 90px; }
.label-row { display: grid; grid-template-columns: 1fr .8fr 2.2fr 1fr 1.1fr; gap: 10px; margin-bottom: 8px; }
.label-row--fallback { color: var(--muted); font-size: 13px; align-items: center; }
.label-row--head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.job-form textarea.input { width: 100%; font-family: var(--font); line-height: 1.5; }
.alert--warn { background: var(--warn-bg); color: var(--warn-fg); }

/* ---- forms, alerts --------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.input--code { font-family: var(--font-mono); font-size: 20px; letter-spacing: .3em; height: 46px; }
.alert { padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.alert--err { background: var(--err-bg); color: var(--err-fg); }
.alert--ok { background: var(--ok-bg); color: var(--ok-fg); }

/* ---- auth screens (no left panel) ------------------------------------ */
.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.auth__panel {
  display: grid; grid-template-columns: 1fr 1fr; width: 100%; max-width: 880px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  overflow: hidden; box-shadow: 0 20px 60px rgba(23, 50, 25, .10);
}
.auth__form { padding: 40px 36px; display: flex; flex-direction: column; justify-content: center; }
.auth__logo { font-family: var(--font-display); font-weight: 800; font-size: 26px; margin-bottom: 28px; }
.auth__logo span { color: var(--accent); }
.auth__title { font-family: var(--font-display); font-size: 20px; margin: 0 0 8px; }
.auth__lead { color: var(--muted); margin: 0 0 18px; }
.auth__foot { margin: 16px 0 0; font-size: 13px; }
.alert + .form { margin-top: 14px; }
.auth .input { height: 44px; }
.auth .btn { height: 44px; justify-content: center; }

/* right column: letters get a tag and fall into folders (CSS only, 9s loop) */
.auth__art {
  background: var(--green-800); color: var(--nav-text);
  padding: 36px 32px; display: flex; flex-direction: column; justify-content: center; gap: 18px;
}
.auth__art-caption { margin: 0; font-size: 13px; color: var(--muted-2); text-align: center; }
.inbox {
  background: var(--green-700); border: 1px solid var(--green-500); border-radius: 14px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.inbox__head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted-2);
  padding: 0 4px 4px;
}
.inbox__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); animation: inbox-dot 1.8s ease-in-out infinite; }
@keyframes inbox-dot { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.inbox__list { display: flex; flex-direction: column; gap: 8px; }
.msg {
  display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 10px;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .08); border-radius: 10px;
  opacity: 0; animation: msg-cycle 9s ease-in-out infinite;
}
.msg--1 { animation-delay: 0s; }
.msg--2 { animation-delay: 3s; }
.msg--3 { animation-delay: 6s; }
.msg__avatar {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%;
  background: var(--green-500); color: #fff; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.msg__text { display: flex; flex-direction: column; min-width: 0; flex-grow: 1; line-height: 1.25; }
.msg__from { font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg__subj { font-size: 11px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg__tag {
  flex-shrink: 0; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--lime); color: var(--green-800);
  opacity: 0; transform: scale(.7); animation: tag-pop 9s ease-out infinite;
}
.msg--1 .msg__tag { animation-delay: 0s; }
.msg--2 .msg__tag { animation-delay: 3s; }
.msg--3 .msg__tag { animation-delay: 6s; }

@keyframes msg-cycle {
  0%        { opacity: 0; transform: translateY(-10px); }
  7%, 40%   { opacity: 1; transform: translateY(0); }
  50%, 100% { opacity: 0; transform: translateY(26px) scale(.96); }
}
@keyframes tag-pop {
  0%, 18%   { opacity: 0; transform: scale(.7); }
  24%, 100% { opacity: 1; transform: scale(1); }
}

.folders { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--green-500); padding-top: 10px; }
.folder {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: 8px;
  font-size: 12px; color: var(--nav-text); animation: folder-hit 9s ease-out infinite;
}
.folder svg { flex-shrink: 0; color: var(--muted-2); }
.folder__badge {
  margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--lime);
  opacity: 0; animation: badge-hit 9s ease-out infinite;
}
.folder--1, .folder--1 .folder__badge { animation-delay: 0s; }
.folder--2, .folder--2 .folder__badge { animation-delay: 3s; }
.folder--3, .folder--3 .folder__badge { animation-delay: 6s; }
@keyframes folder-hit {
  0%, 44%   { background: transparent; color: var(--nav-text); }
  50%       { background: rgba(163, 226, 111, .22); color: #fff; }
  62%, 100% { background: transparent; color: var(--nav-text); }
}
@keyframes badge-hit {
  0%, 46%   { opacity: 0; transform: scale(.5); }
  52%       { opacity: 1; transform: scale(1.3); }
  58%, 100% { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .msg, .msg__tag, .folder, .folder__badge, .inbox__dot { animation: none; opacity: 1; transform: none; }
}

/* ---- runs, messages -------------------------------------------------- */
.runitem { padding: 14px 20px; display: flex; flex-direction: column; gap: 6px; }
.runitem + .runitem { border-top: 1px solid var(--line-2); }
.runitem__head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.report { white-space: pre-wrap; font: 13px/1.5 var(--font); background: #fafbf8; border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; margin: 4px 0 0; max-height: 360px; overflow: auto; }
.tasks { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; margin-top: 4px; }
.rrow { border-bottom: 1px solid var(--line-2); padding: 8px 0; }
.rrow__head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; list-style: none; }
.rrow__head::-webkit-details-marker { display: none; }
.rrow__main { display: flex; flex-direction: column; }
.rrow__action { color: var(--green-500); font-size: 13px; }
.rrow__body { margin-top: 6px; color: var(--green-800); }
.rrow.is-target { background: var(--lime-50); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 8px; }
.rcard { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 6px 0; background: #fafbf8; }
.rcard__title { font-weight: 700; margin-bottom: 4px; }
.rcard__text { margin-top: 4px; }
.rcard__action { margin-top: 6px; font-weight: 600; }
.task { display: inline-flex; align-items: center; gap: 6px; }
.inline { display: inline; }
.section--row { flex-direction: row; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.nowrap { white-space: nowrap; }
.row--unread td { font-weight: 600; }
.dot-btn { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--input); background: var(--panel); cursor: pointer; padding: 0; display: block; }
.dot-btn--unread { background: var(--lime); border-color: var(--green-500); }
details > summary { cursor: pointer; }

/* ---- modal (key checks on «LLM-модели») ------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 50; padding: 16px;
  background: rgba(14, 32, 15, .45); display: grid; place-items: center;
}
.modal[hidden] { display: none; }
.modal__box {
  width: 100%; max-width: 480px; background: var(--panel); border-radius: 16px;
  padding: 22px 24px; box-shadow: 0 24px 64px rgba(14, 32, 15, .25);
}
.modal__title { margin: 0 0 10px; font-size: 16px; font-weight: 700; }
.modal__models { margin: 10px 0 0; word-break: break-word; }
.modal__actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.modal .progress { padding: 6px 0; }

/* ---- «Расписание» ---------------------------------------------------- */
.stats--4 { grid-template-columns: repeat(4, 1fr); }
.stat__value--text { font-size: 20px; }
.section__head--pad { padding: 16px 20px 0; }
.section__pad { padding: 10px 20px 18px; margin: 0; }
.sched-table td { vertical-align: middle; }
.sched-table .sched-actions { width: 1%; white-space: nowrap; }  /* shrinks to its buttons */
.sched-table .sched-chip { white-space: nowrap; }
.sched-table tr.is-off td { color: var(--muted); }
.sched-table tr.is-off .strong { color: var(--muted); }
.sched-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--field); background: var(--card);
  font: inherit; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer;
}
.sched-chip:hover { background: var(--row-hover); }
.sched-chip.is-open { border: 2px solid var(--accent-ink); padding: 0 11px; }
.sched-chip--none { color: var(--muted); }
.sched-chip svg { color: #3f6a1f; }
.sched-chip--none svg { color: var(--muted-2); }
.sched-last { display: flex; align-items: center; gap: 8px; }
.mbx__current { display: inline-flex; align-items: center; gap: 8px; }
.mbx.is-off .mbx__name, .mbx.is-off .mbx__meta { color: var(--muted); }
.mbx.is-off .mbx__avatar { opacity: .55; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute; inset: 0; border-radius: 999px; background: var(--field); transition: background .15s;
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch input:checked + .switch__track { background: var(--accent-ink); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--lime); outline-offset: 2px; }
.agenda { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px 20px; }
.agenda__day { min-width: 0; }
.agenda__title { font-weight: 700; font-size: 13px; color: var(--ink); padding-bottom: 6px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; }
.timeline__row { display: grid; grid-template-columns: 40px 10px 1fr; align-items: start; gap: 8px; padding: 5px 0; }
.timeline__time { font-size: 12px; color: var(--ink); padding-top: 2px; }
.timeline__dot { width: 8px; height: 8px; border-radius: 50%; background: #5c9a2e; margin-top: 6px; }
.timeline__text { font-size: 12px; line-height: 1.4; }
.timeline__row.is-off .timeline__dot { background: #e8ece4; border-color: #cfd8c8; }
.timeline__row.is-off .timeline__text a { color: var(--muted); }
.timeline__text a { text-decoration: none; }

/* ---- jobs list: schedule popover, day picker ---------------------------- */
.jobs-table tr.is-off .strong, .jobs-table tr.is-off td { color: var(--muted); }
.sched-cell { position: relative; }
.jobs-table th { white-space: nowrap; }
.jobs-table .sched-chip { white-space: nowrap; }
/* rows centre vertically; the name and the source take the width, the rest stays on one line */
.jobs-table td { vertical-align: middle; }
.jobs-table .col-name { width: 30%; }
.jobs-table .col-src { width: 26%; }
.jobs-table .col-model, .jobs-table .col-next { white-space: nowrap; width: 1%; }
.jobs-table .col-src .small { color: var(--ink-soft); }
.jobs-table .row-actions { align-items: center; }
.section__foot { display: flex; justify-content: space-between; gap: 12px; padding: 10px 20px 14px; border-top: 1px solid var(--line-2); }
.err { color: var(--err-fg); }
.popover { position: absolute; left: 0; top: calc(100% - 6px); z-index: 30; }
.popover:empty { display: none; }
.pop {
  width: 360px; max-width: calc(100vw - 32px); background: var(--card); border: 1px solid var(--field);
  border-radius: 14px; padding: 18px; box-shadow: 0 12px 32px rgba(27, 43, 23, .16);
  display: flex; flex-direction: column; gap: 12px; text-align: left; white-space: normal;
}
.pop__title { font-weight: 800; font-size: 16px; }
.pop__section { display: flex; flex-direction: column; gap: 6px; }
.pop__row { display: flex; gap: 10px; align-items: flex-end; }
.pop__row .sched__at { flex: 0 0 130px; }
.pop__row .sched__tz { flex: 1 1 140px; min-width: 0; }
.pop__row .sched__every { flex: 0 0 150px; }
.pop__actions { display: flex; justify-content: flex-end; gap: 8px; }
.pop .sched__params { display: contents; }
.pop .sched__params .field { display: none; }
.pop .sched--days .sched__days, .pop .sched--days .sched__at, .pop .sched--days .sched__tz,
.pop .sched--daily .sched__at, .pop .sched--daily .sched__tz, .pop .sched--hourly .sched__every { display: flex; }
.pop .sched--none .pop__row, .pop .sched--hourly .sched__days { display: none; }
.daypick { display: flex; gap: 6px; flex-wrap: wrap; }
.daypick__day input { position: absolute; opacity: 0; width: 0; height: 0; }
.daypick__day span {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 32px;
  border-radius: 999px; border: 1px solid var(--field); font-size: 13px; font-weight: 600; cursor: pointer; user-select: none;
}
.daypick__day input:checked + span { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.daypick__day input:focus-visible + span { outline: 2px solid var(--lime); outline-offset: 2px; }

/* ---- «Активность» ------------------------------------------------------ */
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--field); border-radius: 999px; background: var(--card); }
.seg__item { padding: 0 12px; height: 28px; display: inline-flex; align-items: center; border-radius: 999px; font-size: 13px; text-decoration: none; color: var(--muted); }
.seg__item.is-active { background: var(--ink); color: #fff; font-weight: 600; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter { padding: 0 12px; height: 28px; display: inline-flex; align-items: center; border-radius: 999px; border: 1px solid var(--field); font-size: 12px; text-decoration: none; color: var(--ink); }
.filter.is-active { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.two-col--activity { grid-template-columns: 3fr 2fr; }
.activity-table td { vertical-align: middle; }
.activity-table .col-go { width: 1%; }
.activity-table .btn-icon { opacity: 1; }
.row--err td { background: #fdf3f1; }
.row--err .strong { color: var(--err-fg); }
.stat__icon--err { background: var(--err-bg); color: var(--err-fg); }
.section__foot--right { justify-content: flex-end; }
.msglist--pad { padding: 0 20px; }
.pill--outline { background: var(--card); border: 1px solid var(--field); color: var(--ink); }

/* ---- 2FA ----------------------------------------------------------------- */
.twofa__setup { display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: start; }
.twofa__qr { width: 200px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.twofa__qr svg { width: 100%; height: auto; display: block; }
.twofa__side { display: flex; flex-direction: column; gap: 8px; }
.twofa__secret { display: inline-block; padding: 8px 12px; border: 1px dashed var(--field); border-radius: 8px; font-size: 14px; letter-spacing: .06em; user-select: all; }
.twofa__confirm { margin-top: 8px; max-width: 360px; }
.twofa__state { display: flex; align-items: center; gap: 10px; }
.account__item.is-active { background: var(--accent-soft); }

/* ---- run log ---------------------------------------------------------- */
.runlog { padding: 0; }
.runlog__summary { padding: 14px 20px; font-weight: 600; cursor: pointer; }
.runlog__list { margin: 0; padding: 0 20px 14px 40px; font-size: 13px; max-height: 320px; overflow: auto; }
.runlog__list li { padding: 2px 0; }
.runlog__list li:last-child { font-weight: 600; }
.runlog__list .mono { font-size: 12px; margin-right: 6px; }
.runlog__last { font-weight: 600; }

/* ---- progress -------------------------------------------------------- */
.progress { display: flex; align-items: center; gap: 10px; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(23, 50, 25, .2); border-top-color: var(--green-800);
  animation: spin .8s linear infinite;
}
.spinner--sm { width: 10px; height: 10px; border-width: 2px; }
.running { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- job card: run actions, «⋯» menu, save bar ------------------------ */
.run-actions { display: flex; align-items: center; gap: 8px; }
.unsaved-hint { display: none; }
body.is-dirty .run-actions { display: none; }
body.is-dirty .unsaved-hint { display: inline; }
.menu { position: relative; }
.menu > summary { list-style: none; font-size: 18px; line-height: 1; padding: 0 12px; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 280px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: 0 14px 34px rgba(23, 50, 25, .14); display: flex; flex-direction: column; gap: 2px;
}
.menu__item {
  width: 100%; text-align: left; padding: 9px 12px; border: 0; border-radius: 8px;
  background: transparent; font: inherit; color: var(--green-800); cursor: pointer;
}
.menu__item:hover { background: var(--lime-50); }
.menu__item--danger { color: var(--err-fg); }
.menu__item--danger:hover { background: var(--err-bg); }
.savebar {
  display: none; position: sticky; bottom: 12px; z-index: 15; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--green-800); color: #fff; border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
}
.savebar .btn { border-color: var(--green-500); background: var(--green-700); color: #fff; }
.savebar .btn--primary { background: var(--lime); border-color: var(--lime); color: var(--green-800); }
body.is-dirty .savebar { display: flex; }

/* ---- HTMX ------------------------------------------------------------ */
.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

@media (max-width: 720px) {
  .form-grid, .form-grid--3, .label-row, .stats, .stats--4, .two-col, .two-col--activity, .mode-switch, .folder-list, .agenda, .twofa__setup { grid-template-columns: 1fr; }
  .mbx { flex-wrap: wrap; }
  .auth__panel { grid-template-columns: 1fr; }
  .auth__art { display: none; }
  .auth__form { padding: 28px 22px; }
  .shell { flex-direction: column; }
  /* the panel becomes a top bar with a burger; the menu itself unfolds under it */
  .nav { width: auto; height: auto; position: sticky; top: 0; z-index: 40; padding: 10px 14px; gap: 0; }
  .nav__logo { padding: 4px 6px; }
  .nav__burger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(184, 224, 136, .3);
    background: #263a21; color: #fff; cursor: pointer;
  }
  .nav__burger-close, .nav.is-open .nav__burger-open { display: none; }
  .nav.is-open .nav__burger-close { display: block; }
  .nav__panel { display: none; padding-top: 10px; }
  .nav.is-open .nav__panel { display: flex; }
  .nav__spacer { display: none; }
  .account__menu { position: static; margin-top: 4px; }
  .nav__user { margin-top: 8px; }
  .main { padding: 16px; overflow-wrap: anywhere; }
  /* nothing wider than the screen: tables scroll inside their card, long words wrap,
     action columns may wrap onto a second line */
  html, body { overflow-x: hidden; }
  .card { max-width: 100%; }
  .card:has(> .table) { overflow-x: auto; }
  .table { min-width: 600px; }  /* keeps readable columns; the card scrolls sideways */
  .table--tight { min-width: 460px; }
  .table th, .table td { padding: 10px 10px; }
  .table .pill, .table .btn { white-space: nowrap; }
  .section__head { flex-wrap: wrap; gap: 4px 12px; }
  .row-actions { white-space: normal; flex-wrap: wrap; justify-content: flex-start; }
  .page-header { flex-wrap: wrap; gap: 10px; }
  .mbx { padding: 12px 14px; }
  .mbx__actions { flex-wrap: wrap; flex-shrink: 1; }
  .section { padding: 16px 14px; }
  .stat { padding: 14px 16px; }
  .input--sm { max-width: 100%; }
  .input--model { width: 100%; min-width: 0; }
  .sel--model { width: 100%; min-width: 0; }
  .menu__list { max-width: calc(100vw - 32px); }
  .report { max-height: none; }
  .modal__box { padding: 18px 16px; }
}
