:root { --bg: #f6f5ee; --paper: #fff; --ink: #1d2b45; --ink-2: #4b5873; --muted: #7d869d; --line: #e3e5d9; --sky: #8ccbf2; --sky-1: #e5f3fc; --leaf: #4f8f3d; --leaf-1: #e9f3df; --navy: #2c416b; --red: #b33a36; --r: 14px; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 "Onest", system-ui, sans-serif; }
h1, h2, h3 { font-family: "Literata", Georgia, serif; font-weight: 600; margin: 0 0 .5em; }
h1 { font-size: 28px; } h2 { font-size: 21px; } h3 { font-size: 17px; }
a { color: var(--navy); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(180deg, var(--sky-1), var(--leaf-1)); }
.login form { width: 340px; background: #fff; border-radius: 22px; padding: 30px; box-shadow: 0 20px 50px -20px rgba(29, 43, 69, .3); display: grid; gap: 14px; text-align: center; }
.login img { width: 96px; height: 96px; margin: 0 auto; border-radius: 50%; }
.err { color: var(--red); min-height: 1.4em; font-size: 14px; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font: 600 18px "Literata", serif; text-decoration: none; color: var(--ink); }
.side .brand img { width: 38px; height: 38px; border-radius: 50%; }
.side nav { display: grid; gap: 2px; }
.side nav a { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 500; }
.side nav a:hover { background: var(--bg); }
.side nav a.on { background: var(--leaf-1); color: #2f6a22; }
.side nav hr { border: 0; border-top: 1px solid var(--line); margin: 8px 4px; }
.bubble { background: #d9534f; color: #fff; border-radius: 99px; font-size: 12px; padding: 0 7px; line-height: 20px; }
.side-foot { margin-top: auto; display: grid; gap: 6px; padding: 12px 4px 0; }
.side-foot a, .side-foot button { text-align: left; background: none; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--ink-2); text-decoration: none; }
.side-foot a:hover, .side-foot button:hover { background: var(--bg); }
.btn.menu-btn { display: none; }

main { padding: 26px clamp(16px, 3vw, 40px) 120px; max-width: 1100px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { margin: 0; }
.hint { color: var(--muted); font-size: 14px; margin: -8px 0 18px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--navy); background: var(--navy); color: #fff; padding: 9px 16px; border-radius: 99px; cursor: pointer; font-weight: 600; text-decoration: none; font-size: 14px; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: #fff; color: var(--navy); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.danger { border-color: #e3b3b1; background: #fff; color: var(--red); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.card { background: var(--paper); border-radius: var(--r); padding: 20px; box-shadow: 0 1px 2px rgba(29, 43, 69, .06); margin-bottom: 16px; }
.f { display: grid; gap: 5px; margin-bottom: 14px; }
.f > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.f small { color: var(--muted); font-size: 12px; }
.f input[type=text], .f input[type=number], .f input[type=date], .f input[type=password], .f input:not([type]), .f select, .f textarea, .login input {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fcfcf9; }
.f textarea { resize: vertical; min-height: 70px; }
.f textarea.md { min-height: 220px; font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; line-height: 1.55; }
.f input:focus, .f select:focus, .f textarea:focus, .login input:focus { outline: 0; border-color: var(--sky); background: #fff; box-shadow: 0 0 0 3px rgba(140, 203, 242, .3); }
.chk { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--leaf); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.strs { display: grid; gap: 6px; }
.strs .row { display: flex; gap: 6px; }
.strs .row input { flex: 1; }
.ib { width: 32px; height: 36px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; color: var(--ink-2); flex: none; }
.ib:hover { background: var(--bg); }
.ib.x:hover { color: var(--red); border-color: #e3b3b1; }

.list { display: grid; gap: 10px; }
.item { border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.item > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; align-items: center; gap: 10px; font-weight: 600; }
.item > summary::-webkit-details-marker { display: none; }
.item > summary .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item > summary .tag { font-weight: 500; font-size: 12px; color: var(--muted); background: var(--bg); padding: 2px 8px; border-radius: 99px; }
.item > summary img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }
.item > .body { padding: 4px 14px 14px; border-top: 1px solid var(--line); }
.item-tools { display: flex; gap: 6px; justify-content: flex-end; padding-top: 6px; }
.add { margin-top: 10px; }

.img-f { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.img-f .pv { width: 120px; height: 90px; border-radius: 10px; background: var(--bg) center/cover no-repeat; border: 1px solid var(--line); }
.img-f label.btn input { display: none; }

.pairs { display: grid; gap: 6px; }
.pairs .row { display: grid; grid-template-columns: 1fr 1fr 32px; gap: 6px; align-items: center; }
.refs { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.refs label { display: flex; gap: 6px; align-items: center; font-size: 14px; }

.savebar { position: fixed; left: 240px; right: 0; bottom: 0; background: rgba(255, 255, 255, .95); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: 12px clamp(16px, 3vw, 40px); display: flex; align-items: center; gap: 14px; z-index: 20; transform: translateY(100%); transition: transform .25s; }
.savebar.show { transform: none; }
.savebar .msg { flex: 1; color: var(--ink-2); font-size: 14px; }
.toast { position: fixed; top: 16px; right: 16px; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 50; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4); max-width: 420px; }
.toast.bad { background: var(--red); }

/* leads */
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 14px; cursor: pointer; }
.filters button.on { background: var(--leaf-1); border-color: #c8e0b6; color: #2f6a22; font-weight: 600; }
.lead { display: grid; grid-template-columns: 1fr 210px; gap: 16px; }
.lead.new { border-left: 4px solid #d9534f; }
.lead .meta { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.lead .who { font-weight: 600; font-size: 16px; }
.lead .msg { white-space: pre-wrap; margin: 8px 0 0; color: var(--ink-2); }
.lead .side-l { display: grid; gap: 8px; align-content: start; }
.lead textarea { width: 100%; min-height: 60px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.lead select { width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); }
.deliv { font-size: 12px; color: var(--muted); }
.deliv .bad { color: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* stats */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: #fff; border-radius: var(--r); padding: 16px; }
.tile b { display: block; font: 600 28px "Literata", serif; }
.tile span { color: var(--muted); font-size: 13px; }
.chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: 10px; }
.chart div { flex: 1; background: var(--sky); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.chart div i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--leaf); border-radius: 3px 3px 0 0; }
.chart div:hover { filter: brightness(.9); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.top-list { list-style: none; margin: 0; padding: 0; }
.top-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.top-list li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bk { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; width: 260px; transform: translateX(-100%); transition: transform .25s; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; margin-bottom: 12px; }
  .savebar { left: 0; }
  .grid2, .two, .lead { grid-template-columns: 1fr; }
}
