/* Reserved area */

  body { background: var(--bg); }
  /* ---------- login ---------- */
  .login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
  .login .art { position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(900px 400px at 100% 0%, rgba(190,39,45,.55), transparent 60%), linear-gradient(150deg, #1D2128, #2B3038 60%, #3A2026); }
  .login .art::after { content: ''; position: absolute; right: -80px; bottom: -80px; width: 460px; height: 460px; background: url('../img/mark.svg') no-repeat center/contain; opacity: .08; }
  .login .art .logo { background: #fff; border-radius: 14px; padding: 10px 14px; display: inline-block; align-self: flex-start; }
  .login .art h1 { font-size: 38px; font-weight: 800; max-width: 460px; }
  .login .art p { color: #CBD0D8; max-width: 440px; }
  .login .form { display: grid; place-items: center; padding: 32px 16px; }
  .login .box { width: min(420px, 100%); }
  .roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 20px; }
  .roles label { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 8px; text-align: center; cursor: pointer; font-size: 13px; font-weight: 700; background: #fff; display: grid; gap: 4px; }
  .roles label span { font-size: 20px; }
  .roles input { display: none; }
  .roles label:has(input:checked) { border-color: var(--red); background: #FFFBFB; box-shadow: 0 0 0 4px rgba(190,39,45,.1); }
  .or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; margin: 16px 0; }
  .or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
  .spid { background: #0066CC; color: #fff; }
  .spid:hover { background: #0052A3; }

  /* ---------- shell ---------- */
  .app { display: none; min-height: 100vh; grid-template-columns: 264px 1fr; }
  .app.on { display: grid; }
  .sidebar { background: #fff; border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
  .sidebar .logo { padding: 4px 8px 16px; }
  .sidebar .logo img { height: 40px; display: block; }
  .sidebar .group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 14px 10px 6px; }
  .sidebar a.nav { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 600; font-size: 14.5px; text-decoration: none; }
  .sidebar a.nav:hover { background: var(--line-2); }
  .sidebar a.nav.on { background: var(--red-050); color: var(--red-600); }
  .sidebar a.nav .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; border-radius: 99px; padding: 1px 7px; }
  .sidebar .me { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 12px; background: var(--line-2); font-size: 13px; }
  .sidebar .me b { display: block; font-size: 14px; }
  .main { min-width: 0; }
  .topnav { position: sticky; top: 0; z-index: 10; height: 64px; display: flex; align-items: center; gap: 14px; padding: 0 28px; background: rgba(246,247,249,.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
  .topnav .search { flex: 1; max-width: 420px; position: relative; }
  .topnav .search input { padding-left: 36px; background: #fff; }
  .topnav .search::before { content: '⌕'; position: absolute; left: 12px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 18px; }
  .topnav .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
  .icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; cursor: pointer; position: relative; }
  .icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; background: var(--red); border-radius: 50%; border: 2px solid #fff; }
  .demo-role { font-size: 13px; padding: 8px 10px; width: auto; }
  .menu-toggle { display: none; }
  .content { padding: 28px; max-width: 1280px; }
  .page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
  .page-head h1 { font-size: 26px; font-weight: 800; margin: 0; }
  .page-head p { margin: 4px 0 0; color: var(--muted); }
  .crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

  .kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
  .kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
  .kpi .l { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
  .kpi .v { font-size: 30px; font-weight: 800; margin: 6px 0 2px; letter-spacing: -.02em; }
  .kpi .d { font-size: 12.5px; color: var(--muted); }
  .kpi.red { background: linear-gradient(135deg, var(--red), #8E1C24); color: #fff; border: 0; }
  .kpi.red .l, .kpi.red .d { color: #FFD3D5; }

  .cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
  .stack { display: grid; gap: 20px; }
  .hero-case { background: linear-gradient(135deg, #1D2128, #33303A); color: #fff; border-radius: 18px; padding: 24px; display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; box-shadow: var(--shadow-lg); }
  .hero-case h2 { margin: 6px 0; font-size: 22px; }
  .hero-case .meta { color: #C3C8D0; font-size: 14px; }
  .hero-case .amount { text-align: right; }
  .hero-case .amount strong { font-size: 34px; display: block; font-weight: 800; }
  .hero-case .bar { background: rgba(255,255,255,.14); margin-top: 14px; }
  .cols > *, .stack > *, .hero-case > * { min-width: 0; }
  .task { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
  .task:last-child { border-bottom: 0; }
  .task .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; font-size: 18px; }
  .task .tx { flex: 1; min-width: 0; }
  .task .tx b { display: block; font-size: 14.5px; }
  .task .tx span { font-size: 13px; color: var(--muted); }

  .kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 14px; margin: 0; }
  .kv dt { color: var(--muted); }
  .kv dd { margin: 0; font-weight: 600; }
  .chk { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
  .chk:last-child { border-bottom: 0; }
  .chk .i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: none; }
  .chk .i.ok { background: var(--green-050); color: var(--green); }
  .chk .i.ko { background: var(--red-050); color: var(--red); }
  .chk .i.wa { background: var(--amber-050); color: var(--amber); }
  .gen { display: grid; gap: 8px; }
  .gen label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13.5px; cursor: pointer; }
  .gen label:hover { background: #FBFBFD; }
  .gen input { accent-color: var(--red); width: 16px; height: 16px; }
  .gen .n { font-family: ui-monospace, Consolas, monospace; color: var(--muted); font-size: 12px; width: 22px; }
  .switch { position: relative; width: 38px; height: 22px; flex: none; }
  .switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
  .switch span { position: absolute; inset: 0; background: #D5DAE1; border-radius: 99px; transition: .15s; }
  .switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
  .switch input:checked + span { background: var(--red); }
  .switch input:checked + span::after { transform: translateX(16px); }
  .setrow { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
  .setrow:last-child { border-bottom: 0; }
  .setrow .nm b { display: block; font-size: 14.5px; }
  .setrow .nm span { font-size: 13px; color: var(--muted); }
  .setrow input { max-width: 200px; }
  .tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
  .tabs button { border: 0; background: none; padding: 10px 14px; font: 600 14px var(--font); color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
  .tabs button.on { color: var(--red-600); border-color: var(--red); }
  .filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line-2); }
  .filters select, .filters input { width: auto; padding: 8px 10px; font-size: 13.5px; }
  .who { display: flex; gap: 10px; align-items: center; }
  .who b { display: block; font-size: 14px; }
  .who span { font-size: 12.5px; color: var(--muted); }
  .msgs { display: grid; gap: 14px; max-height: 460px; overflow: auto; padding-right: 4px; }
  .msg { display: flex; gap: 10px; max-width: 80%; }
  .msg .b { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; font-size: 14px; }
  .msg .b small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 4px; }
  .msg.me { margin-left: auto; flex-direction: row-reverse; }
  .msg.me .b { background: var(--red-050); border-color: var(--red-100); }
  .compose { display: flex; gap: 10px; margin-top: 16px; }
  .funnel { display: grid; gap: 12px; }
  .funnel .r { display: grid; grid-template-columns: 170px 1fr 48px; gap: 12px; align-items: center; font-size: 13.5px; }
  .funnel .r .bar span { background: linear-gradient(90deg, var(--blue), #4C7CCB); }
  .funnel .r:nth-child(n+5) .bar span { background: linear-gradient(90deg, var(--green), #48B184); }
  .cal { display: grid; gap: 10px; }
  .cal .ev { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
  .cal .day { text-align: center; border-radius: 10px; background: var(--red-050); color: var(--red-600); padding: 6px 0; font-weight: 800; line-height: 1.1; }
  .cal .day small { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; }
  .toast { position: fixed; right: 24px; bottom: 24px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 50; }
  .toast.on { opacity: 1; transform: none; }

  @media (max-width: 1080px) {
    .cols { grid-template-columns: 1fr; }
    .kpis { grid-template-columns: repeat(2, 1fr); }
  }
  @media (max-width: 860px) {
    .login { grid-template-columns: 1fr; }
    .login .art { display: none; }
    .app.on { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: .2s; box-shadow: var(--shadow-lg); }
    .app.nav-open .sidebar { transform: none; }
    .menu-toggle { display: grid; }
    .topnav { padding: 0 16px; }
    .topnav .search { display: none; }
    .content { padding: 18px 16px; }
    .hero-case { grid-template-columns: 1fr; }
    .hero-case .amount { text-align: left; }
    .kv { grid-template-columns: 110px 1fr; }
    .funnel .r { grid-template-columns: 110px 1fr 36px; }
  }
  @media (max-width: 520px) { .kpis { grid-template-columns: 1fr; } .demo-role { max-width: 130px; } .msg { max-width: 95%; } }

/* server-rendered pages */
form.inline { display: inline-flex; gap: 4px; align-items: center; margin: 0; }
form.inline.reject input { width: 120px; padding: 6px 8px; font-size: 12.5px; }
.case-card { text-decoration: none !important; color: inherit; transition: .15s; }
.case-card:hover { border-color: #CBD2DB; transform: translateY(-1px); }
.funnel a.r { color: inherit; text-decoration: none; }
.cal a.ev { color: inherit; text-decoration: none; }
tr.row-link { cursor: pointer; }
.login .art .logo { align-self: flex-start; }
.login .art .logo img { display: block; }
.sidebar .logo img { height: 40px; display: block; }
.topnav .right form { margin: 0; }
textarea { font: 500 14px var(--font); resize: vertical; }
.hint { font-size: 12px; color: var(--muted); }
.checklist { display: grid; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; font-size: 14px; }
.checklist li::before { content: '✓ '; color: var(--green); font-weight: 800; }
.checklist li.ko::before { content: '✕ '; color: var(--red); }
.user-form { display: grid; gap: 10px; }
.user-form fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 10px; margin: 0; }
.user-form legend { font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 0 4px; }
details.edit-user > summary { list-style: none; }
details.edit-user > summary::-webkit-details-marker { display: none; }
details.edit-user[open] { position: relative; }
details.edit-user[open] .user-form { position: absolute; right: 0; z-index: 20; width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; box-shadow: var(--shadow-lg); margin-top: 6px; }
.toast { position: fixed; right: 24px; bottom: 24px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 50; }
.toast.on { opacity: 1; transform: none; }

table.data td.num { white-space: nowrap; }
table.data td:nth-child(2) { white-space: nowrap; }

/* case data correction */
.case-data { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; margin-top: 18px; }
.case-data .grid-3 > *, .case-data .grid-2 > * { min-width: 0; }
@media (max-width: 760px) { .case-data .grid-3, .case-data .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.svc-list { display: grid; gap: 14px; }
.svc-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 16px; background: #FCFCFD; display: grid; gap: 14px; }
.svc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.svc-head b { font-size: 15px; }
.svc-calc { margin-left: auto; }
.svc-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.svc-grid .span-2 { grid-column: span 2; }
.svc-grid input, .svc-grid select { width: 100%; min-width: 0; }
.svc-sub { border: 0; border-top: 1px dashed var(--line); margin: 0; padding: 14px 0 0; display: grid; gap: 12px; min-width: 0; }
.svc-sub legend { padding: 0 8px 0 0; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.svc-sub legend span { text-transform: none; letter-spacing: 0; font-weight: 500; margin-left: 6px; }
.svc-manual .svc-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.svc-check { font-size: 13.5px; }
.field.need input { border-color: var(--red); background: var(--red-050); }
.field.need .hint { color: var(--red-600); font-weight: 600; }
@media (max-width: 1100px) { .svc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .svc-manual .svc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .svc-grid, .svc-manual .svc-grid { grid-template-columns: minmax(0, 1fr); } .svc-grid .span-2 { grid-column: auto; } .svc-calc { margin-left: 0; } }
.studio-card dl.kv { margin: 0; }

/* personal templates */
.ph-field { display: inline-block; padding: 0 6px; margin: 0 1px; border-radius: 5px; background: #E3ECFB; color: #1B4FA8; border: 1px solid #C3D5F4; font-size: .92em; line-height: 1.45; white-space: nowrap; cursor: default; user-select: all; }
.tpl-help ul { margin: 0 0 10px; padding-left: 18px; display: grid; gap: 6px; }
.tpl-help code { background: var(--amber-050); color: #7A4F0D; padding: 0 4px; border-radius: 4px; font-size: .92em; }
.tpl-top { align-items: start; }
.tpl-fields { display: grid; gap: 12px; max-height: calc(100vh - 260px); overflow: auto; }
.tpl-fields h4 { margin: 0 0 6px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tpl-fields button { display: block; width: 100%; text-align: left; padding: 6px 8px; border: 0; border-radius: 7px; background: transparent; font: 500 13px/1.3 var(--font); color: var(--ink-2); cursor: pointer; }
.tpl-fields button:hover, .tpl-fields button:focus-visible { background: #E3ECFB; color: #1B4FA8; }
.tpl-file { cursor: pointer; }
#tpl-import.attn { box-shadow: 0 0 0 3px var(--red-100); }
.ed-page.preview .ed-body, .ed-page.preview .ed-header { cursor: default; }
@media (max-width: 760px) { .tpl-top { grid-template-columns: minmax(0, 1fr); } }
