:root {
  --brand: #0f766e;
  --brand-dark: #0b4f4a;
  --brand-soft: #e6f4f1;
  --side: #0c2f2b;
  --side-2: #10403a;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f3f6f8;
  --card: #ffffff;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --green: #059669;
  --green-soft: #ecfdf5;
  --blue-soft: #eff6ff;
  --radius: 12px;
  --mode: #059669;
}
.mode-sandbox { --mode: #d97706; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; font-size: 14px; color: var(--ink); background: var(--bg); line-height: 1.45; }
body.mode-sandbox::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: 4px; background: repeating-linear-gradient(45deg, #f59e0b 0 14px, #111827 14px 28px); z-index: 100; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; margin-bottom: 12px; }
h3 { font-size: 14px; margin: 18px 0 10px; color: var(--brand-dark); text-transform: uppercase; letter-spacing: .04em; }
.ic { width: 18px; height: 18px; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 13px; }
.r { text-align: right; }
.mt { margin-top: 10px; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 252px; flex: none; background: linear-gradient(180deg, var(--side), var(--side-2)); color: #d1fae5; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #34d399, #0f766e); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; letter-spacing: .5px; flex: none; }
.brand-mark.big { width: 52px; height: 52px; font-size: 20px; border-radius: 14px; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: #99c9bf; }
.company-box { margin: 4px 12px 10px; padding: 10px; border-radius: 10px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08); display: flex; gap: 10px; align-items: center; }
.company-box.empty { border-style: dashed; }
.cb-logo { width: 40px; height: 40px; border-radius: 8px; background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none; color: var(--brand-dark); font-weight: 800; }
.cb-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cb-name { color: #fff; font-weight: 600; font-size: 13px; line-height: 1.3; }
.cb-ntn { font-size: 11px; color: #99c9bf; }
.nav { display: flex; flex-direction: column; padding: 4px 8px 12px; gap: 2px; }
.nav a { display: flex; gap: 10px; align-items: center; color: #cfe9e3; padding: 9px 10px; border-radius: 8px; font-size: 13.5px; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.nav a.active { background: #fff; color: var(--brand-dark); font-weight: 600; }
.nav-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #7fb3a8; margin: 14px 10px 4px; }
.sidebar-foot { margin-top: auto; padding: 12px 16px; font-size: 11px; color: #7fb3a8; border-top: 1px solid rgba(255,255,255,.08); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 19px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--ink); }
.menu-btn .ic { width: 22px; height: 22px; }
.switcher select { min-width: 220px; max-width: 280px; }
.mode-badge { background: var(--mode); color: #fff; font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: 999px; letter-spacing: .08em; }
.user-chip { display: flex; flex-direction: column; line-height: 1.15; padding-left: 10px; border-left: 1px solid var(--line); }
.uc-name { font-weight: 600; font-size: 13px; }
.uc-role { font-size: 11px; color: var(--muted); }
.content { padding: 22px 24px; flex: 1; max-width: 1400px; width: 100%; }
.foot { padding: 14px 24px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); background: #fff; }
.nav-shade { display: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card.narrow { max-width: 820px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.head-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cards-row { gap: 18px; }
.cards-row > .card { margin-bottom: 0; }
.grid.cards-row { margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; border-top: 3px solid var(--brand); }
.stat-warn { border-top-color: var(--amber); }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat-value small { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat-note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.empty-state { padding: 26px; text-align: center; color: var(--muted); background: #f8fafc; border: 1px dashed var(--line); border-radius: 10px; }
.pill { background: var(--brand-soft); color: var(--brand-dark); padding: 5px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; }

.grid { display: grid; gap: 14px; }
.g1 { grid-template-columns: 1fr; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.span4 { grid-column: span 4; }

label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: #334155; }
label small { font-weight: 400; color: var(--muted); font-size: 11.5px; }
input, select, textarea { font: inherit; font-size: 14px; font-weight: 400; color: var(--ink); background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.15); }
input[type="checkbox"] { width: auto; }
input[type="file"] { padding: 6px; }
input.readonly, input[readonly] { background: #f1f5f9; font-weight: 700; }
textarea { resize: vertical; }
.check-row { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; align-self: end; padding-bottom: 8px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; }
.input-btn { display: flex; gap: 6px; }
.input-btn input { flex: 1; }
.input-btn .btn { white-space: nowrap; }
.check-out { font-size: 12px; font-weight: 500; min-height: 16px; color: var(--muted); }
.check-out.good { color: var(--green); }
.check-out.bad { color: var(--red); }
.logo-prev { display: inline-flex; align-items: center; gap: 10px; margin-top: 6px; }
.logo-prev img { max-height: 44px; max-width: 120px; border: 1px solid var(--line); border-radius: 6px; padding: 3px; background: #fff; }
.logo-prev.big img { max-height: 90px; max-width: 160px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; min-width: 180px; }
.inline-form .grow { flex: 1; }
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filters label { min-width: 150px; }
.filters .grow { flex: 1; min-width: 220px; }
.filter-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none !important; line-height: 1.2; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-light { background: #fff; color: var(--ink); border-color: #cbd5e1; }
.btn-light:hover:not(:disabled) { background: #f8fafc; border-color: #94a3b8; }
.btn-link { background: none; color: var(--brand); padding: 8px 6px; }
.btn-link.danger, .danger { color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; margin-top: 6px; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; font-size: 13.5px; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert-success { background: var(--green-soft); border-color: #a7f3d0; color: #065f46; }
.alert-error { background: var(--red-soft); border-color: #fecaca; color: #991b1b; }
.alert-warning { background: var(--amber-soft); border-color: #fde68a; color: #92400e; }
.alert-info { background: var(--blue-soft); border-color: #bfdbfe; color: #1e40af; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge-green { background: var(--green-soft); color: #047857; }
.badge-red { background: var(--red-soft); color: #b91c1c; }
.badge-amber { background: var(--amber-soft); color: #b45309; }
.badge-gray { background: #f1f5f9; color: #475569; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { background: #f8fafc; text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafcfd; }
.table tfoot td { background: #f8fafc; font-weight: 600; border-top: 1px solid var(--line); }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions > * { display: inline-block; margin: 2px 0 2px 4px; vertical-align: middle; }
.table .actions form { margin: 2px 0 2px 4px; }
.table .nw { white-space: nowrap; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; color: var(--muted); }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: 13px; }
.tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs .count { opacity: .7; font-weight: 500; margin-left: 4px; }

.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0 0 14px; }
.dl dt { color: var(--muted); font-size: 12.5px; }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 10px; overflow: auto; max-height: 520px; font-size: 12px; margin: 0; white-space: pre-wrap; word-break: break-all; }

.status-card { display: flex; justify-content: space-between; gap: 18px; align-items: center; flex-wrap: wrap; border-left: 5px solid #94a3b8; }
.status-card.status-posted { border-left-color: var(--green); background: linear-gradient(90deg, #f0fdf8, #fff 40%); }
.status-card.status-failed { border-left-color: var(--red); background: linear-gradient(90deg, #fff5f5, #fff 40%); }
.status-card.status-posting { border-left-color: var(--amber); }
.status-main { display: flex; flex-direction: column; gap: 6px; }
.status-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-actions form { margin: 0; }
.fbr-no span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.fbr-no strong { font-size: 20px; color: var(--brand-dark); }
.error-text { color: #991b1b; font-size: 13px; }

.line { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; background: #fbfdfd; }
.line-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.line-no { font-weight: 700; color: var(--brand-dark); }
.line .grid { gap: 10px; }
.line label { font-size: 11.5px; }
.line input, .line select { padding: 7px 8px; font-size: 13.5px; }
.more { margin-top: 10px; }
.more summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 12.5px; margin-bottom: 8px; }
.totals { width: 100%; border-collapse: collapse; align-self: start; }
.totals td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.totals td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.totals .grand td { font-size: 17px; font-weight: 800; color: #fff; background: var(--brand); border: 0; }
.totals .grand td:first-child { border-radius: 8px 0 0 8px; }
.totals .grand td:last-child { border-radius: 0 8px 8px 0; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; padding: 12px 20px 12px; margin: 18px -20px -18px; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 -6px 16px rgba(15,23,42,.06); z-index: 5; }

.auth-page { display: flex; align-items: flex-start; justify-content: center; min-height: 100vh; background: radial-gradient(circle at 20% 0%, #d1fae5, transparent 45%), radial-gradient(circle at 100% 100%, #ccfbf1, transparent 40%), var(--bg); }
.auth-wrap { width: 100%; max-width: 420px; margin: 60px 16px; }
.auth-wrap.wide { max-width: 760px; }
.auth-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.auth-brand .mode-badge { margin-left: auto; }
.auth-title { font-size: 20px; font-weight: 800; color: var(--brand-dark); }
.auth-sub { font-size: 12.5px; color: var(--muted); }
.auth-wrap .card { padding: 24px; }
.auth-wrap form label { margin-bottom: 12px; }
.auth-wrap .grid label { margin-bottom: 0; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; }
.checks { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 4px; }
.checks .ok { color: var(--green); }
.checks .bad { color: var(--red); font-weight: 600; }

@media (max-width: 1100px) {
  .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g6 .span4 { grid-column: span 3; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .nav-open .sidebar { transform: none; }
  .nav-open .nav-shade { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 50; }
  .menu-btn { display: block; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .topbar-right { width: 100%; justify-content: flex-start; }
  .switcher select { min-width: 0; max-width: 100%; }
  .user-chip { display: none; }
  .content { padding: 14px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span2, .span3, .g6 .span4 { grid-column: span 1; }
  .g6 .span2, .g6 .span3, .g6 .span4 { grid-column: span 2; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .inline-form input, .inline-form select { min-width: 0; flex: 1; }
  .sticky-actions { position: static; box-shadow: none; }
  .status-actions .btn, .status-actions form { flex: 1 1 auto; }
}
