/* ===== CRM base styles ===== */
  
:root{--line:#ececf0;--soft:#f7f7f8;--black:#050505;--muted:#777;--green:#6be12c;--greenBg:#efffe2;--pink:#f23d85;--pinkBg:#fff4fa;--blue:#345cff;--orange:#ffa36a;font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif}*{box-sizing:border-box}body{margin:0;background:#fff;color:#111;font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif}button,input,textarea{font:inherit}button{cursor:pointer}.proto{height:50px;background:#ececf0;display:flex;align-items:center;justify-content:space-between;padding:0 14px}.proto button{border:0;background:transparent;font-size:24px}.proto .pill{height:36px;background:#fff;border-radius:9px;display:flex;align-items:center;gap:8px;padding:0 14px;font-weight:700;font-size:14px}.app{display:flex;min-height:calc(100vh - 50px)}.side{width:68px;border-right:1px solid var(--line);overflow:hidden;transition:.18s;background:#fff;flex:0 0 auto}.side.open{width:268px}.brand{height:72px;border-bottom:1px solid var(--line);display:flex;gap:12px;align-items:center;padding:0 20px;white-space:nowrap}.logo{width:36px;height:36px;display:grid;place-items:center;font-weight:900;letter-spacing:-.06em;position:relative}.side.open .logo{background:#000;color:#fff;font-size:13px}.logo:before,.logo:after{content:"";position:absolute;right:-2px;width:9px;height:2px;background:currentColor}.logo:before{top:0}.logo:after{bottom:0}.brand-name{display:none;font-size:22px;font-weight:800}.side.open .brand-name{display:block}.nav{padding-top:18px}.nav button{width:100%;height:60px;border:0;background:#fff;display:flex;align-items:center;gap:15px;padding:0 20px;color:#707070;font-size:16px;position:relative;white-space:nowrap}.nav button.active{background:#fafafa;color:#111}.nav button.active:before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:#000}.ico{width:22px;height:22px;stroke:currentColor;stroke-width:1.8;fill:none;stroke-linecap:round;stroke-linejoin:round;flex:0 0 auto}.nav span{display:none}.side.open .nav span{display:inline}.main{flex:1;min-width:0}.top{height:72px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:28px;padding:0 30px}.burger{width:46px;height:46px;border:0;background:transparent;display:flex;flex-direction:column;gap:7px;justify-content:center;padding:0 8px}.burger span{display:block;width:30px;height:1.5px;background:#111}.branch{font-size:20px;font-weight:750;white-space:nowrap}.chev{display:inline-block;width:8px;height:8px;border-right:1.8px solid #aaa;border-bottom:1.8px solid #aaa;transform:rotate(45deg) translateY(-2px);margin-left:6px}.date{font-size:16px;white-space:nowrap}.search{flex:1;display:flex;justify-content:center}.search div{position:relative;width:min(808px,100%)}.search input{width:100%;height:54px;border:1px solid var(--line);border-radius:8px;padding:0 55px 0 20px;outline:0}.search svg{position:absolute;right:18px;top:50%;transform:translateY(-50%);width:23px;height:23px;stroke:#c7c7c7;fill:none;stroke-width:2}.user{display:flex;align-items:center;gap:10px;white-space:nowrap}.ava{width:36px;height:36px;border-radius:50%;border:1px solid #ffd08b;background:#fff7eb;color:#d79536;display:grid;place-items:center}.head{display:grid;grid-template-columns:1fr auto;gap:20px;align-items:end;padding:24px 30px 14px;border-bottom:1px solid var(--line)}h1{font-size:32px;line-height:1.1;margin:0 0 24px;font-weight:900;letter-spacing:-.04em}.tabs,.actions,.chips{display:flex;flex-wrap:wrap;gap:8px}.tab,.act{height:46px;border:1px solid #e7e7eb;background:#fff;border-radius:6px;padding:0 15px;color:#777;font-size:16px}.tab.active{background:#202020;color:#fff;border-color:#202020}.act{color:#111;display:flex;align-items:center;gap:9px;padding:0 18px}.act.black{background:#000;color:#fff;border-color:#000}.filters{display:grid;grid-template-columns:1fr auto;gap:18px;align-items:center;padding:26px 30px 16px}.chip{height:32px;border-radius:999px;border:0;background:#eee;color:#777;padding:0 13px;font-size:14px}.chip.active{background:#fff;color:#111;border:1px solid #111}.found{font-size:14px;color:#777}.view{display:none;padding:0 30px 36px}.view.on{display:block}.calendar-layout{display:grid;grid-template-columns:minmax(720px,1fr) 590px;gap:30px;align-items:start}.panel{border:1px solid var(--line);background:#fff}.cal-panel{padding:24px 30px 30px}h2{font-size:24px;margin:0;font-weight:900}.cal-head{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:20px;margin:36px 0 30px}.month{text-align:center;font-size:20px;font-weight:900}.small{height:38px;min-width:52px;border:1px solid var(--line);background:#fff;border-radius:6px;padding:0 15px}.week,.days{display:grid;grid-template-columns:repeat(7,1fr);min-width:760px}.week div{height:37px;display:grid;place-items:center;background:#fafafa;border-right:1px solid #f0f0f0;font-weight:700}.day{min-height:120px;border-top:1px solid var(--line);border-right:1px solid var(--line);background:#fff;position:relative;text-align:left;padding:10px 12px}.day:nth-child(7n+1){border-left:1px solid var(--line)}.day:nth-last-child(-n+7){border-bottom:1px solid var(--line)}.day.selected{background:#f7f7f7;box-shadow:inset 0 0 0 1px #cfcfcf}.num{position:absolute;right:12px;top:10px;color:#52ad52}.num.busy{color:#e92f79}.num.other{color:#777}.car-badge{position:absolute;right:13px;bottom:18px;min-width:48px;height:29px;border:1px solid #ddd;border-radius:999px;background:#fff;display:flex;align-items:center;justify-content:center;gap:6px;padding:0 9px;color:#666}.car-badge svg{width:17px;height:17px;stroke:#000;stroke-width:2;fill:none}.orders{min-height:1060px}.orders-empty{min-height:945px;display:grid;place-items:center;text-align:center;color:#777;font-weight:700}.orders-title{padding:20px 28px 0}.orders-date{height:126px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:14px;padding:24px 28px}.orders-date strong{font-size:20px}.orders-list{max-height:934px;overflow:auto}.right-card{border-bottom:1px solid var(--line);padding:20px 28px}.right-card h3,.card h3{font-size:20px;margin:31px 0 16px;font-weight:900;letter-spacing:-.03em}.topline{display:grid;grid-template-columns:1fr auto;gap:14px;align-items:start}.badges{display:flex;gap:7px;flex-wrap:wrap}.badge{height:29px;border-radius:5px;background:#f2f2f2;color:#777;display:inline-flex;align-items:center;padding:0 8px;font-size:14px}.badge.green{background:var(--greenBg);color:var(--green)}.badge.pink{background:var(--pinkBg);color:var(--pink)}.btns{display:flex;gap:8px;position:relative}.icon{width:37px;height:29px;border:1px solid var(--line);background:#fff;border-radius:6px;display:grid;place-items:center;font-weight:900}.down:after,.up:after{content:"";width:8px;height:8px;border-right:2px solid #111;border-bottom:2px solid #111}.down:after{transform:rotate(45deg) translateY(-2px)}.up:after{transform:rotate(225deg) translateY(-2px)}.time{display:flex;gap:16px;align-items:center;flex-wrap:wrap;color:#5d5d5d;font-size:16px;margin-bottom:16px}.time span{display:flex;gap:8px;align-items:center}.time svg{width:18px;height:18px;stroke:#111;stroke-width:1.8;fill:none}.sum{font-size:18px;font-weight:900}.list{width:min(1170px,calc(100vw - 360px));margin-left:clamp(0px,18vw,310px);padding-top:45px}.card{position:relative;min-height:170px;border:1px solid var(--line);background:#fff;padding:20px 24px;margin-bottom:14px}.card.soft{background:#fbfbfb}.card.blue{border-left:4px solid var(--blue)}.card.pinkline{border-left:4px solid var(--pink)}.card.greenline{border-left:4px solid var(--green)}.card.grayline{border-left:4px solid #d8d8d8}.card.orangeline{border-left:4px solid var(--orange)}.card>.btns,.detail>.btns{position:absolute;right:24px;top:20px}.menu{position:absolute;right:0;top:36px;width:190px;background:#fff;border-radius:8px;box-shadow:0 14px 30px #0002;z-index:20;display:none;overflow:hidden;border:1px solid #00000008}.menu.show{display:block}.mrow{height:43px;padding:0 18px;display:flex;align-items:center;justify-content:space-between;color:#777}.mrow:hover{background:#f7f7f7;color:#111}.mcolor{padding:9px 18px 15px;color:#777}.dots{display:flex;gap:9px;margin-top:9px}.dot{width:13px;height:13px;border-radius:50%;border:1px solid #e6e6e6;background:#fff}.dot.gray{background:#ddd}.dot.pink{background:var(--pink)}.dot.green{background:var(--green)}.dot.blue{background:#39a5ff}.dot.orange{background:var(--orange)}.detail{position:relative;border:1px solid var(--line);background:#fff;padding:20px 24px;margin-bottom:14px;min-height:720px}.detail h3{font-size:18px;margin:0 0 26px;font-weight:900}.sec{margin-top:24px}.st{font-weight:900;margin-bottom:14px}.kv{display:grid;grid-template-columns:120px 1fr;gap:10px 12px;max-width:540px}.kv .k{color:#666}.pill{display:inline-flex;height:30px;border-radius:5px;padding:0 9px;align-items:center;background:var(--greenBg);color:var(--green)}.pill.pink{background:var(--pinkBg);color:var(--pink)}.tg{width:24px;height:24px;border-radius:50%;background:#36a9e1;color:#fff;display:grid;place-items:center;font-size:13px;font-weight:900}.svcbox{border:1px solid var(--line);border-radius:5px;width:735px;max-width:100%;overflow:hidden}.svcline{display:grid;grid-template-columns:28px 1fr auto;align-items:start;padding:12px 14px;border-bottom:1px solid #f1f1f3;font-size:15px}.svcline:last-child{border-bottom:0}.price{font-weight:900}.note{grid-column:2/span 2;color:#666;font-size:13px;margin-top:7px}.tdot{display:inline-block;width:7px;height:7px;border-radius:50%;background:var(--pink);margin-right:8px}.tdot.green{background:var(--green)}.execbox{height:29px;border:1px solid var(--line);border-radius:4px;display:flex;align-items:center;padding:0 14px;width:735px;max-width:100%}.overlay{position:fixed;inset:0;background:#0004;display:none;align-items:flex-start;justify-content:center;padding:90px 24px 40px;z-index:100;overflow:auto}.overlay.show{display:flex}.modal{width:824px;background:#fff;border-radius:8px;box-shadow:0 24px 60px #0003;overflow:hidden}.modal.small{width:820px}.modal.full{width:760px}.modal-head{height:74px;border-bottom:1px solid var(--line);display:grid;place-items:center;position:relative}.modal-title{font-size:24px;font-weight:900}.close{position:absolute;right:16px;top:13px;border:0;background:transparent;color:#777;font-size:26px}.mbody{padding:34px 42px 28px}.mfoot{display:flex;justify-content:flex-end;gap:8px;padding:18px 42px 40px}.section{margin-bottom:26px}.section h3{margin:0 0 16px;font-size:18px}.grid2{display:grid;grid-template-columns:1fr 1fr;gap:24px}.field{margin-bottom:18px;position:relative}.field label{display:block;margin-bottom:8px;font-size:14px}.control{height:53px;width:100%;border:1px solid #e5e5e8;border-radius:6px;background:#fff;padding:0 14px;display:flex;align-items:center;justify-content:space-between;color:#111}.control.muted{color:#888}.control input{border:0;outline:0;width:100%;height:100%;background:transparent}.select:after{content:"";width:8px;height:8px;border-right:2px solid #111;border-bottom:2px solid #111;transform:rotate(45deg) translateY(-3px);margin-left:10px}.textarea{height:86px;padding-top:13px;resize:none;display:block}.btn{height:46px;border:1px solid #e5e5e8;border-radius:7px;background:#f6f6f7;padding:0 24px}.btn.black{background:#000;color:#fff;border-color:#000}.box{background:#fdfdfd;border-radius:8px;padding:18px;position:relative;margin-bottom:18px}.x{position:absolute;right:10px;top:8px;border:0;background:transparent;font-size:20px;color:#777}.add{height:36px;border:1px solid #ddd;border-radius:6px;background:#fff;color:#666;padding:0 12px;display:inline-flex;align-items:center;gap:7px}.chips2{display:flex;gap:7px;flex-wrap:wrap}.contact{height:30px;border:1px solid #e7e7e7;background:#fff;border-radius:999px;padding:0 10px;color:#777}.contact.on{border-color:#38a8ff}.media{height:56px;border:1px dashed #ddd;border-radius:5px;display:grid;place-items:center;color:#777}.thumbs{display:flex;gap:8px;margin-top:18px}.thumb{width:52px;height:52px;border-radius:4px;background:linear-gradient(135deg,#17243a,#eee);position:relative}.thumb:nth-child(2){background:linear-gradient(135deg,#ddd,#111)}.thumb:nth-child(3){background:linear-gradient(135deg,#1e2d4a,#cbd5e5)}.thumb:after{content:"×";position:absolute;right:-5px;top:-6px;width:15px;height:15px;border-radius:50%;background:#000;color:#fff;display:grid;place-items:center;font-size:12px}.dropdown{position:absolute;left:0;right:0;top:61px;background:#fff;border-radius:5px;box-shadow:0 16px 30px #0002;z-index:12;overflow:hidden}.opt{height:40px;display:flex;align-items:center;padding:0 14px;background:#fff}.opt:nth-child(2),.opt:hover{background:#f6f6f6}.mini{position:absolute;right:0;top:61px;width:295px;background:#fff;border-radius:10px;box-shadow:0 18px 36px #0002;padding:18px;z-index:13}.minihead{display:flex;justify-content:space-between;font-weight:900;font-size:18px;margin-bottom:14px}.minigrid{display:grid;grid-template-columns:repeat(7,1fr);gap:8px;text-align:center}.mw{color:#999;font-weight:700}.md{height:24px;border-radius:4px;display:grid;place-items:center;color:#555}.md.other{color:#ddd}.md.active{background:#202020;color:#fff}.md.soft{background:#eee}.filtergrid{display:grid;grid-template-columns:1fr 1fr;gap:28px 24px}.contract{background:#fdfdfd;border-radius:8px;padding:22px;position:relative;margin-top:18px}@media(max-width:1400px){.calendar-layout{grid-template-columns:1fr}.list{width:100%;margin-left:0}.orders{min-height:420px}.orders-empty{min-height:320px}}@media(max-width:980px){.proto{display:none}.app{min-height:100vh}.side{display:none}.top{height:auto;min-height:72px;flex-wrap:wrap;padding:10px 18px}.date{display:none}.search{order:10;flex-basis:100%}.head,.filters,.view{padding-left:18px;padding-right:18px}.head,.filters{grid-template-columns:1fr}.grid2,.filtergrid{grid-template-columns:1fr}.overlay{padding-top:20px}.modal,.modal.full,.modal.small{width:min(100%,820px)}}

  
    :root { color-scheme: light only; }
    html, body { margin:0; padding:0; background:#fff; color:#000; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }
    .wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
    h1 { font-size: 20px; margin: 0 0 10px; }

    /* Панель */
    .toolbar { position: sticky; top: 0; z-index: 100; background: #fff; padding: 8px 0 12px; margin-bottom: 8px; border-bottom: 1px solid #eee; }
    .toolbar .row { display:flex; gap:10px; align-items:center; flex-wrap: wrap; }
    select, button { font: inherit; padding: 8px 10px; border-radius: 10px; border:1px solid #ddd; background:#fff; color:#000; }
    .hint { font-size: 13px; opacity: .7; margin: 8px 0; }

    /* Календарь */
    #calendarWrap { display:none; margin-top:8px; user-select:none; }
    .cal-head{
      display:flex;
      flex-direction: column;       /* заголовок сверху, кнопки ниже */
      align-items:flex-start;       /* всё слева */
      gap:6px;
      margin-bottom:6px;
    }
    .cal-title{ font-weight:600; }
    .cal-nav{ display:flex; gap:6px; }
    .cal-btn { padding:6px 10px; border:1px solid #ddd; border-radius:8px; background:#fff; cursor:pointer; }
    .cal-grid { display:grid; grid-template-columns: repeat(7, 1fr); gap:6px; }
    .cal-wd { text-align:center; font-size:12px; opacity:.7; }
    .cal-day {
      padding:8px 0; text-align:center; border:1px solid #eee; border-radius:8px; cursor:pointer; background:#fff;
    }
    .cal-day.mute { opacity:.35; }
    .cal-day.sel { border-color:#000; box-shadow: inset 0 0 0 1px #000; }
    .cal-legend { font-size:12px; opacity:.75; margin-top:6px; }
    .cal-day .mark { display:block; font-size:12px; opacity:.9; }
    .cal-day .ok { color:#1a7f37; }    /* ✅ */
    .cal-day .bad { color:#b00020; }   /* ❌ */
    .cal-day .cnt { font-weight:600; margin-left:2px; }
    .cal-collapsed #calDays,
    .cal-collapsed #calWeekdays,
    .cal-collapsed #calLegend {
      display: none;
    }
    .cal-collapsed #calStrip { display: none; }

    /* Навбар месяца в детализации: стрелка — дата — стрелка */
    .cal-head.monthbar{
      display: grid !important;
      grid-template-columns: auto 1fr auto; /* ← 3 колонки */
      align-items: center;
      gap: 10px;
    }

    /* заголовок по центру */
    .cal-head.monthbar .cal-title{
      text-align: center;
      font-weight: 600;
      min-width: 0; /* не фиксируем ширину, чтобы центр был точным */
    }

    /* «расплющить» контейнер кнопок, чтобы их дети стали элементами грида */
    .cal-head.monthbar .cal-nav{
      display: contents;
    }

    /* расстановка стрелок по краям, центровка заголовка */
    .cal-head.monthbar #calPrev{ grid-column: 1; justify-self: end; }
    .cal-head.monthbar #calTitle{ grid-column: 2; }
    .cal-head.monthbar #calNext{ grid-column: 3; justify-self: start; }

    /* «Сегодня» и «▼/▲» в режиме месячного итога скрываем */
    .cal-head.monthbar #calToday,
    .cal-head.monthbar #calToggle{ display: none !important; }




    /* Список */
    .orders { display: grid; gap: 10px; }
    .order { position:relative; border: 1px solid #e5e5e5; border-radius: 10px; padding: 12px; background:#fff; cursor: pointer; }
    .order:hover { background:#fafafa; }
    .order b { font-weight: 600; }
    .row { display:flex; gap:8px; flex-wrap:wrap; font-size:14px; }
    .pill { font-size: 12px; border:1px solid #ddd; border-radius: 999px; padding:2px 8px; }
    .muted { opacity:.7; }
    .error { color:#b00020; }

    /* Кнопка меню («три точки») снизу карточки */
    .card-actions { position:absolute; right:8px; bottom:8px; }
    .dot-btn {
      width: 28px; height: 28px; border-radius: 50%;
      border: 1px solid #ddd; background: #fff; color:#000; cursor: pointer;
      display: inline-flex; align-items: center; justify-content: center;
      font-weight: 700; line-height: 1;
    }
    .dot-btn:after { content: "⋯"; font-size: 18px; transform: translateY(-1px); }
    .dropdown {
      position: absolute; right: 8px; bottom: 46px; z-index: 20;
      background: #fff; border: 1px solid #ddd; border-radius: 10px;
      box-shadow: 0 8px 20px rgba(0,0,0,.08); min-width: 160px; overflow: hidden;
      display: none;
    }
    .dropdown a { display:block; padding:10px 12px; text-decoration:none; color:#222; }
    .dropdown a:hover { background:#f5f5f7; }

    /* Модалки */
    .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; align-items: center; justify-content: center; z-index: 2000; }
    .modal { width: min(920px, 92vw); max-height: 90vh; overflow: auto; background: #fff; color:#000; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 16px 18px 18px; border: 1px solid #e5e5e5; }
    .modal-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
    .modal-title { font-size: 18px; font-weight: 600; }
    .btn-close { border: none; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; padding: 4px 8px; }
    .kv { display:grid; grid-template-columns: 180px 1fr; gap:6px 12px; font-size:14px; }
    .kv .k { color:#555; }
    .section { margin: 14px 0 8px; font-weight: 600; }
    .list { border:1px solid #eee; border-radius: 10px; padding:8px; background:#fff; }
    .svc { display:grid; grid-template-columns: 1fr auto; gap:6px 10px; padding:8px 6px; border-bottom:1px dashed #eee; }
    .svc:last-child { border-bottom:none; }
    .svc .name { font-weight: 500; }
    .svc .meta { font-size: 12px; color:#666; }

    /* FAB */
    .fab{
      position: fixed;
      left: 18px; bottom: 18px;
      height: 40px;
      padding: 0 14px;
      border-radius: 9999px;
      background:#000; color:#fff; border:none;
      font-size:14px;
      display:inline-flex; align-items:center; justify-content:center;
      box-shadow: 0 8px 20px rgba(0,0,0,.25);
      cursor:pointer;
    }

    .fab:active { transform: translateY(1px); }

    /* Формы */
    .modal .grid2 { display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
    .modal input, .modal select, .modal textarea { width:100%; padding:8px 10px; border:1px solid #ddd; border-radius:10px; background:#fff; color:#000; font:inherit; }
    .field { margin:8px 0; }
    .mini { font-size:12px; opacity:.7; }
    .row-end { display:flex; justify-content:flex-end; gap:10px; margin-top:8px; }
    .btn { padding:8px 12px; border-radius:10px; border:1px solid #ddd; background:#fff; cursor:pointer; }
    .btn.primary { background:#000; color:#fff; border-color:#000; }
    .subtle { border:1px dashed #bbb; background:#fafafa; }

    /* === Детализация заказа === */
    .detail-top { display:flex; gap:10px; align-items:center; margin: 8px 0 12px; }
    .detail-table-wrap { overflow:auto; border:1px solid #eee; border-radius:10px; }
    table.detail { width:100%; border-collapse: collapse; background:#fff; color:#000; font-size:13px; }
    .detail th, .detail td { border-bottom:1px solid #f0f0f0; padding:8px; text-align:left; white-space: nowrap; }
    .detail th { background:#fafafa; position:sticky; top:0; z-index:1; }
    .detail tfoot td {
      background: #f7f7f9;
      font-weight: 600;
      padding: 10px 12px;
      text-align: center;
      vertical-align: middle;
    }

    /* === Итог за месяц: читаемые текстовые колонки и авто-раскрытие === */
    #table-month { table-layout: auto; }          /* не фиксированная сетка */
    #table-month td:nth-child(6),
    #table-month td:nth-child(7) {                /* Расход / Описание расхода */
      white-space: normal;
      vertical-align: top;
    }
    #table-month .exp-amount { min-width: 140px; width: 100%; box-sizing: border-box; }
    #table-month .exp-note   { min-width: 260px; width: 100%; box-sizing: border-box; resize: none; line-height: 1.35; }
    #table-month tr.saving   { background: #fff8e1; }
    #table-month tr.saved    { background: #eefbe7; }
    #table-month tr.error    { background: #fde2e1; }

    #table-month tbody tr { cursor: pointer; }



    .detail input[type="number"] { width:120px; }
    .detail .svc-name { max-width:340px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .grid-end { display:flex; justify-content:flex-end; gap:10px; margin-top:10px; }
    .muted-mini { font-size:12px; opacity:.7; }

    /* === Детализация: аккуратное центрирование и оформление === */
    #details-view.details-center {
      display: none;            /* остаётся как у тебя — управляем JS */
      flex-direction: column;
      align-items: center;       /* <- весь блок по центру */
      gap: 18px;
    }

    #details-view.details-center h3 {
      margin: 8px 0 4px;
      text-align: center;        /* заголовки по центру */
    }

    /* центрируем календарь (если он сверху этой секции) */
    #calendarWrap { margin-left: auto; margin-right: auto; }

    /* карточный вид для таблиц */
    .detail-table-wrap {
      width: min(1100px, 96vw);
      background: #fff;
      border: 1px solid #ececec;
      border-radius: 14px;
      box-shadow: 0 6px 20px rgba(0,0,0,.06);
      overflow: hidden;          /* скругления для sticky-headers */
    }

    /* таблица — чище и читабельнее */
    table.detail { width: 100%; border-collapse: collapse; font-size: 13px; }
    .detail thead th {
      position: sticky; top: 0;
      background: #f7f7f9; color: #111;
      text-align: center;        /* заголовки по центру */
      padding: 10px 12px;
      border-bottom: 1px solid #eee;
    }
    .detail tbody td {
      padding: 10px 12px;
      border-bottom: 1px solid #f2f2f2;
      text-align: center;        /* значения по умолчанию — по центру */
      vertical-align: top;
    }
    .detail tbody tr:nth-child(even) { background: #fcfcfd; }
    .detail tbody tr:hover { background: #f6f8ff; }
    .detail tfoot td {
      background: #f7f7f9; font-weight: 600; padding: 10px 12px;
    }

    /* отдельные текстовые колонки — читаемее слева */
    #table-auto td:nth-child(2),
    #table-auto td:nth-child(3),
    #table-koh  td:nth-child(2),
    #table-koh  td:nth-child(3) { text-align: left; }
    #table-auto tfoot td:first-child,
    #table-koh  tfoot td:first-child { text-align: left; }


    /* мини-текст по центру */
    .muted-mini { text-align: center; width: 100%; display: block; }

    /* === Горизонтальный слайдер таблиц === */
    .hscroll { position: relative; }
    .hscroll .scroll-area {
      overflow-x: auto; overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
      scroll-behavior: smooth;
      cursor: grab;
    }
    .hscroll .scroll-area:active { cursor: grabbing; }

    /* скрываем стандартный скроллбар (не мешает функционально) */
    .hscroll .scroll-area::-webkit-scrollbar { height: 8px; }
    .hscroll .scroll-area::-webkit-scrollbar-track { background: transparent; }
    .hscroll .scroll-area::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); border-radius: 8px; }
    @supports (scrollbar-width: thin) {
      .hscroll .scroll-area { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.25) transparent; }
    }

    /* градиентные края */
    .hscroll::before, .hscroll::after {
      content: ""; position: absolute; top: 0; bottom: 0; width: 32px; z-index: 2; pointer-events: none;
      transition: opacity .15s ease;
    }
    .hscroll::before { left: 0; background: linear-gradient(to right, rgba(255,255,255,1), rgba(255,255,255,0)); opacity: 0; }
    .hscroll::after  { right: 0; background: linear-gradient(to left,  rgba(255,255,255,1), rgba(255,255,255,0)); opacity: 0; }
    .hscroll.can-left::before { opacity: 1; }
    .hscroll.can-right::after { opacity: 1; }

    /* стрелки */
    .scroll-btn {
      position: absolute; top: 50%; transform: translateY(-50%);
      width: 34px; height: 34px; border-radius: 50%;
      border: 1px solid #e6e6e9; background: #fff;
      box-shadow: 0 6px 18px rgba(0,0,0,.08);
      display: grid; place-items: center; z-index: 3;
      cursor: pointer; user-select: none;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s ease;
      opacity: 0;
      pointer-events: none;
      transform: translateY(-50%) scale(0.95);
      transition: opacity 0.25s ease, transform 0.25s ease;
    }
    .scroll-btn:hover { background: #f7f7f9; }
    .scroll-btn.left  { left: 6px; }
    .scroll-btn.right { right: 6px; }
    .scroll-btn svg { width: 18px; height: 18px; }
    .hscroll:hover .scroll-btn,
    .hscroll:focus-within .scroll-btn,
    .hscroll.dragging .scroll-btn {
      transform: translateY(-50%) scale(1);
    }

    @media (max-width: 640px){
      .scroll-btn { display: none; } /* на очень узких — оставим drag/тач */
    }

    /* === Режим "Детализация": фикс выравниваний по колонкам === */
    #table-auto th:nth-child(1),
    #table-auto td:nth-child(1),
    #table-koh  th:nth-child(1),
    #table-koh  td:nth-child(1) { text-align: center !important; }

    #table-auto th:nth-child(2), #table-auto td:nth-child(2),
    #table-auto th:nth-child(3), #table-auto td:nth-child(3),
    #table-koh  th:nth-child(2), #table-koh  td:nth-child(2),
    #table-koh  th:nth-child(3), #table-koh  td:nth-child(3) { text-align: left !important; }

    #table-auto th:nth-child(n+4),
    #table-auto td:nth-child(n+4),
    #table-koh  th:nth-child(n+4),
    #table-koh  td:nth-child(n+4) { text-align: center !important; }

    #table-auto tfoot td,
    #table-koh  tfoot td { text-align: center !important; vertical-align: middle; }
    #table-auto tfoot td:first-child,
    #table-koh  tfoot td:first-child { text-align: left !important; }

    #table-auto td:nth-child(3),
    #table-koh  td:nth-child(3) { white-space: normal; line-height: 1.35; }

    table.detail{ table-layout: fixed; }                /* одна сетка по всей таблице */
    .detail th, .detail td{
      font-variant-numeric: tabular-nums;               /* одинаковая ширина цифр */
      font-feature-settings: "tnum" 1, "lnum" 1;
    }

    /* === Детализация: однострочная ленточка дней === */
    .cal-strip{
      display:flex;
      gap:6px;
      overflow-x:auto;
      -webkit-overflow-scrolling: touch;
      scroll-behavior: smooth;
      padding: 2px 0 6px;
    }
    .cal-strip::-webkit-scrollbar{ height:6px; }
    .cal-strip::-webkit-scrollbar-thumb{ background: rgba(0,0,0,.2); border-radius: 6px; }

    .cal-day-btn{
      min-width: 34px;         /* компактно */
      height: 28px;
      padding: 0 8px;
      border:1px solid #ddd;
      border-radius: 8px;
      background:#fff;
      font: inherit;
      cursor: pointer;
      line-height: 26px;
    }
    .cal-day-btn.sel{
      border-color:#000;
      box-shadow: inset 0 0 0 1px #000;
      font-weight: 600;
    }

    #monthly-view {
      align-items: center;            /* центр по поперечной оси flex-контейнера */
    }
    /* scroll живёт на .scroll-area, она должна занимать всю ширину обёртки */
    #monthly-view .detail-table-wrap .scroll-area {
      width: 100%;
      margin: 0;
    }

    #month-wrapper {
      display: inline-block;        /* ширина по содержимому (таблице) */
    }

    #table-month{
      table-layout: auto !important;
      width: max-content;           /* даёт естественную суммарную ширину из colgroup */
    }


    #table-month input[type="number"],
    #table-month input[type="text"] {
      min-width: 140px;
      padding: 6px 8px;
      box-sizing: border-box;
    }

    #month-wrapper.table-scroll::-webkit-scrollbar{ height: 8px; }
    #month-wrapper.table-scroll::-webkit-scrollbar-thumb{ background: #c8ccd1; border-radius: 8px; }
    #month-wrapper.table-scroll:hover::-webkit-scrollbar-thumb{ background: #9aa3ac; }

    #table-month{ table-layout: auto; }

    #table-month tfoot tr.month-total{
      background: #f3f6fa;
      position: sticky; /* при желании можно прилепить его к низу обёртки */
      bottom: 0;
    }
    #table-month tfoot td{
      font-weight: 600;
      border-top: 2px solid #d7dee6;
    }
    
    /* === Авторизация по ключу студии === */
    body.locked .wrap,
    body.locked #details-view,
    body.locked #monthly-view,
    body.locked #btnAdd {
      display: none !important;
    }
    
    #studio-auth-backdrop {
      position: fixed;
      inset: 0;
      background: #fff;
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 99999;
      padding: 20px;
    }
    
    body.locked #studio-auth-backdrop {
      display: flex;
    }
    
    .studio-auth-card {
      width: min(420px, 92vw);
      border: 1px solid #e5e5e5;
      border-radius: 18px;
      padding: 22px;
      background: #fff;
      color: #000;
      box-shadow: 0 12px 35px rgba(0,0,0,.12);
    }
    
    .studio-auth-title {
      font-size: 22px;
      font-weight: 700;
      margin-bottom: 8px;
    }
    
    .studio-auth-text {
      font-size: 14px;
      opacity: .7;
      margin-bottom: 18px;
      line-height: 1.35;
    }
    
    .studio-auth-card input {
      width: 100%;
      box-sizing: border-box;
      font: inherit;
      padding: 12px 14px;
      border: 1px solid #ddd;
      border-radius: 12px;
      background: #fff;
      color: #000;
      letter-spacing: 1px;
    }
    
    .studio-auth-card button {
      width: 100%;
      margin-top: 12px;
      padding: 12px 14px;
      border-radius: 12px;
      border: 1px solid #000;
      background: #000;
      color: #fff;
      cursor: pointer;
    }
    
    .studio-auth-error {
      min-height: 18px;
      margin-top: 10px;
      font-size: 13px;
      color: #b00020;
    }
    
    .studio-auth-mini {
      margin-top: 10px;
      font-size: 12px;
      opacity: .6;
      text-align: center;
    }
    
    #changeStudioBtn {
      margin-left: auto;
    }



  
  
/* === Visual preview shell for real index.html === */
:root{--line:#ececf0;--soft:#f7f7f8;--black:#050505;--muted:#777;--green:#6be12c;--greenBg:#efffe2;--pink:#f23d85;--pinkBg:#fff4fa;--blue:#345cff;--orange:#ffa36a;}
body{background:#fff;color:#111;}
body.locked .proto,
body.locked .app{display:none!important;}
#studio-auth-backdrop{background:#fff;}

/* keep preview chrome strong even after old CSS */
.proto{height:50px;background:#ececf0;display:flex;align-items:center;justify-content:space-between;padding:0 14px;}
.proto button{border:0;background:transparent;font-size:24px;padding:0;}
.proto .pill{height:36px;background:#fff;border-radius:9px;display:flex;align-items:center;gap:8px;padding:0 14px;font-weight:700;font-size:14px;}
.app{display:flex;min-height:calc(100vh - 50px);}
.side{width:68px;border-right:1px solid var(--line);overflow:hidden;transition:.18s;background:#fff;flex:0 0 auto;}
.side.open{width:268px;}
.brand{height:72px;border-bottom:1px solid var(--line);display:flex;gap:12px;align-items:center;padding:0 20px;white-space:nowrap;}
.logo{width:36px;height:36px;display:grid;place-items:center;font-weight:900;letter-spacing:-.06em;position:relative;}
.side.open .logo{background:#000;color:#fff;font-size:13px;}
.logo:before,.logo:after{content:"";position:absolute;right:-2px;width:9px;height:2px;background:currentColor;}
.logo:before{top:0}.logo:after{bottom:0}.brand-name{display:none;font-size:22px;font-weight:800}.side.open .brand-name{display:block}
.nav{padding-top:18px}.nav button{width:100%;height:60px;border:0;background:#fff;display:flex;align-items:center;gap:15px;padding:0 20px;color:#707070;font-size:16px;position:relative;white-space:nowrap}.nav button.active{background:#fafafa;color:#111}.nav button.active:before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:#000}.ico{width:22px;height:22px;stroke:currentColor;stroke-width:1.8;fill:none;stroke-linecap:round;stroke-linejoin:round;flex:0 0 auto}.nav span{display:none}.side.open .nav span{display:inline}
.main{flex:1;min-width:0;}
.top{height:72px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:28px;padding:0 30px;background:#fff;}
.burger{width:46px;height:46px;border:0;background:transparent;display:flex;flex-direction:column;gap:7px;justify-content:center;padding:0 8px;border-radius:0;}
.burger span{display:block;width:30px;height:1.5px;background:#111}.branch{font-size:20px;font-weight:750;white-space:nowrap}.chev{display:inline-block;width:8px;height:8px;border-right:1.8px solid #aaa;border-bottom:1.8px solid #aaa;transform:rotate(45deg) translateY(-2px);margin-left:6px}.date{font-size:16px;white-space:nowrap}.search{flex:1;display:flex;justify-content:center}.search div{position:relative;width:min(808px,100%)}.search input{width:100%;height:54px;border:1px solid var(--line);border-radius:8px;padding:0 55px 0 20px;outline:0}.search svg{position:absolute;right:18px;top:50%;transform:translateY(-50%);width:23px;height:23px;stroke:#c7c7c7;fill:none;stroke-width:2}.user{display:flex;align-items:center;gap:10px;white-space:nowrap}.ava{width:36px;height:36px;border-radius:50%;border:1px solid #ffd08b;background:#fff7eb;color:#d79536;display:grid;place-items:center}
.head{display:grid;grid-template-columns:1fr auto;gap:20px;align-items:end;padding:24px 30px 14px;border-bottom:1px solid var(--line);}
.head h1{font-size:32px;line-height:1.1;margin:0 0 24px;font-weight:900;letter-spacing:-.04em;}
.tabs,.actions,.chips{display:flex;flex-wrap:wrap;gap:8px}.tab,.act{height:46px;border:1px solid #e7e7eb;background:#fff;border-radius:6px;padding:0 15px;color:#777;font-size:16px}.tab.active{background:#202020;color:#fff;border-color:#202020}.act{color:#111;display:flex;align-items:center;gap:9px;padding:0 18px}.act.black{background:#000;color:#fff;border-color:#000}
.filters{display:grid;grid-template-columns:1fr auto;gap:18px;align-items:center;padding:26px 30px 16px}.chip{height:32px;border-radius:999px;border:0;background:#eee;color:#777;padding:0 13px;font-size:14px}.chip.active{background:#fff;color:#111;border:1px solid #111}.found{font-size:14px;color:#777}.found.error{color:#b00020;}
.preview-content{padding:0 30px 36px;}
.calendar-layout{display:grid;grid-template-columns:minmax(720px,1fr) 590px;gap:30px;align-items:start;}
.calendar-layout.no-calendar{display:block;}
.panel{border:1px solid var(--line);background:#fff;}
.cal-panel{padding:24px 30px 30px;overflow:auto;}
.cal-panel h2,.orders-title h2{font-size:24px;margin:0;font-weight:900;}
.cal-panel .cal-head{display:grid!important;grid-template-columns:auto 1fr auto;align-items:center;gap:20px;margin:36px 0 30px;}
.cal-panel .cal-head.monthbar{grid-template-columns:auto 1fr auto!important;}
.cal-panel .cal-title{text-align:center;font-size:20px;font-weight:900;}
.cal-panel .cal-nav{display:flex;gap:8px;justify-content:flex-end;}
.cal-panel .cal-btn,.small{height:38px;min-width:52px;border:1px solid var(--line);background:#fff;border-radius:6px;padding:0 15px;}
.cal-panel .cal-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:0;min-width:760px;}
.cal-panel .cal-wd{height:37px;display:grid;place-items:center;background:#fafafa;border-right:1px solid #f0f0f0;font-weight:700;font-size:13px;opacity:1;text-transform:uppercase;}
.cal-panel .cal-day{min-height:120px;border:0;border-top:1px solid var(--line);border-right:1px solid var(--line);border-radius:0;background:#fff;position:relative;text-align:left;padding:10px 12px;cursor:pointer;}
.cal-panel .cal-day:nth-child(7n+1){border-left:1px solid var(--line)}
.cal-panel .cal-day:nth-last-child(-n+7){border-bottom:1px solid var(--line)}
.cal-panel .cal-day.mute{opacity:1;background:#fff;color:#999;}
.cal-panel .cal-day.sel{background:#f7f7f7;box-shadow:inset 0 0 0 1px #cfcfcf;border-color:var(--line);}
.cal-panel .cal-day .mark{position:absolute;right:13px;bottom:18px;min-width:48px;height:29px;border:1px solid #ddd;border-radius:999px;background:#fff;display:flex;align-items:center;justify-content:center;gap:6px;padding:0 9px;color:#666;font-size:0;}
.cal-panel .cal-day .mark:before{content:'🚘';font-size:15px;}
.cal-panel .cal-day .mark.ok{display:none;}
.cal-panel .cal-day .mark.bad{color:#666;}
.cal-panel .cal-day .cnt{font-size:14px;font-weight:700;margin-left:0;}
.cal-panel .cal-legend{font-size:13px;color:#777;margin-top:14px;opacity:1;}
.cal-strip{display:flex;gap:6px;overflow-x:auto;padding:2px 0 6px}.cal-day-btn{min-width:40px;height:32px;padding:0 10px;border:1px solid #ddd;border-radius:8px;background:#fff;}.cal-day-btn.sel{background:#202020;color:#fff;border-color:#202020;box-shadow:none;}
.orders-shell{min-height:760px;overflow:hidden;}
.orders-title{padding:20px 28px 0;}
#orders{display:block;gap:0;max-height:980px;overflow:auto;padding:0;background:#fff;}
.calendar-layout.no-calendar .orders-shell{width:min(1170px,calc(100vw - 360px));margin-left:clamp(0px,18vw,310px);border:0;background:transparent;min-height:0;}
.calendar-layout.no-calendar .orders-title{display:none;}
.calendar-layout.no-calendar #orders{max-height:none;overflow:visible;background:transparent;}
.order{position:relative;min-height:170px;border:1px solid var(--line);border-radius:0;padding:20px 24px;margin:0 0 14px;background:#fff;cursor:pointer;box-shadow:none;}
.orders-shell #orders .order{border-left:0;border-right:0;border-bottom:1px solid var(--line);border-top:0;margin:0;border-radius:0;min-height:148px;padding:20px 28px;}
.calendar-layout.no-calendar #orders .order{border:1px solid var(--line);margin-bottom:14px;min-height:170px;padding:20px 24px;}
.order:hover{background:#fbfbfb;}
.order .row{display:flex;gap:14px;align-items:center;flex-wrap:wrap;font-size:16px;margin-bottom:12px;}
.order .row:first-child{display:grid;grid-template-columns:1fr auto;align-items:start;}
.order b{font-weight:900;}
.order .pill{height:29px;border-radius:5px;background:#f2f2f2;color:#777;border:0;display:inline-flex;align-items:center;padding:0 8px;font-size:14px;}
.order .muted{color:#5d5d5d;opacity:1;}
.order .sum{font-size:18px;font-weight:900;}
.card-actions{position:absolute;right:24px;top:20px;bottom:auto;}.dot-btn{width:37px;height:29px;border:1px solid var(--line);background:#fff;border-radius:6px;display:grid;place-items:center;font-weight:900;color:#111;}.dot-btn:after{content:'•••';font-size:13px;transform:none;}
.order .dropdown{position:absolute;right:24px;top:56px;bottom:auto;width:190px;background:#fff;border-radius:8px;box-shadow:0 14px 30px #0002;z-index:20;display:none;overflow:hidden;border:1px solid #00000008;}
.order .dropdown a{height:43px;padding:0 18px;display:flex;align-items:center;justify-content:space-between;color:#777;text-decoration:none;}.order .dropdown a:hover{background:#f7f7f7;color:#111;}
#details-view,#monthly-view{padding:0 30px 36px;}
.detail-table-wrap{border-radius:0;border:1px solid var(--line);box-shadow:none;}
/* table.detail must stay a table, preview has .detail sections */
table.detail{position:static!important;display:table!important;min-height:0!important;border:0!important;margin:0!important;padding:0!important;background:#fff!important;}
.detail th,.detail td{border-bottom:1px solid #f0f0f0;}
.modal-backdrop{background:rgba(0,0,0,.35);}
.modal{border-radius:8px;box-shadow:0 24px 60px #0003;border:0;}
.modal-header{height:74px;border-bottom:1px solid var(--line);display:grid;place-items:center;position:relative;margin:0 -18px 24px;}
.modal-title{font-size:24px;font-weight:900;}.btn-close{position:absolute;right:16px;top:13px;color:#777;}
.btn.primary,.btn.black{background:#000;color:#fff;border-color:#000}.btn{height:46px;border-radius:7px;}
@media(max-width:1400px){.calendar-layout{grid-template-columns:1fr}.orders-shell{min-height:420px}.calendar-layout.no-calendar .orders-shell{width:100%;margin-left:0}.orders-shell #orders{max-height:none}}
@media(max-width:980px){.proto{display:none}.app{min-height:100vh}.side{display:none}.top{height:auto;min-height:72px;flex-wrap:wrap;padding:10px 18px}.date,.user{display:none}.search{order:10;flex-basis:100%}.head,.filters,.preview-content,#details-view,#monthly-view{padding-left:18px;padding-right:18px}.head,.filters{grid-template-columns:1fr}.calendar-layout{display:block}.cal-panel .cal-grid{min-width:640px}.cal-panel .cal-day{min-height:88px}.modal{width:min(100%,820px)}}
