:root {
  font-family: Inter, Arial, sans-serif;
  color: #0a1f44;
  background: #f3f7fc;
  font-synthesis: none;
  --bg: #f3f7fc;
  --surface: #ffffff;
  --ink: #0a1f44;
  --navy: #071b3a;
  --navy-2: #102b55;
  --blue: #0f63d8;
  --blue-brand: #1675f2;
  --blue-bright: #2b91ff;
  --blue-soft: #d9eaff;
  --panel-soft: #edf5ff;
  --muted: #536987;
  --quiet: #667a96;
  --line: rgba(25, 72, 130, .13);
  --line-strong: rgba(25, 72, 130, .22);
  --green: #16845b;
  --amber: #b86d0d;
  --red: #b44343;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.is-hidden { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: var(--navy); }
.login-panel { width: min(100%, 610px); padding: clamp(30px, 6vw, 64px); color: white; border: 1px solid rgba(255,255,255,.16); border-radius: 26px; }
.brand-lockup { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; font-size: 13px; font-weight: 750; letter-spacing: .08em; }
.brand-symbol { width: 34px; height: 34px; display: grid; place-items: center; color: white; background: var(--blue); border-radius: 10px; font-size: 16px; letter-spacing: 0; }
.login-panel h1 { margin: 54px 0 20px; max-width: 14ch; font-size: clamp(38px, 7vw, 58px); line-height: .98; letter-spacing: -.04em; }
.login-panel h1 span { color: #75b8ff; }
.login-panel > p { max-width: 48ch; color: #b9c8dd; font-size: 17px; line-height: 1.55; }
.login-form { margin-top: 42px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.login-form label { color: #d8e2ef; }
.login-form .button { min-width: 122px; }
.form-error { grid-column: 1 / -1; min-height: 20px; margin: 0; color: #ffb4b4; font-size: 13px; }

.app-view { min-height: 100vh; }
.topbar { height: 70px; display: grid; grid-template-columns: 1fr auto auto; gap: 24px; align-items: center; padding: 0 clamp(20px, 3vw, 46px); color: white; background: var(--navy); }
.topbar-status { display: flex; align-items: center; gap: 9px; color: #c3d0e1; font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--quiet); }
.status-dot.ok { background: #4dd79f; }
.status-dot.warn { background: #ffc66e; }
.status-dot.error { background: #ff8484; }
.text-button { padding: 6px 0; color: var(--blue); background: none; border: 0; font-weight: 700; }
.topbar .text-button { color: #b9c8dd; }

.workspace { min-height: calc(100vh - 70px); display: grid; grid-template-columns: 270px 1fr; }
.sidebar { padding: 32px 22px; display: flex; flex-direction: column; background: #eaf2fc; border-right: 1px solid var(--line); }
.sidebar-heading { margin: 0 10px 14px; color: var(--muted); font-size: 12px; font-weight: 700; }
.app-link, .future-slot { width: 100%; min-height: 70px; padding: 14px 12px; display: grid; grid-template-columns: 34px 1fr; gap: 11px; align-items: start; text-align: left; color: var(--ink); background: transparent; border: 0; border-radius: 14px; }
.app-link.active { background: white; box-shadow: 0 18px 50px rgba(0, 0, 0, .06); }
.app-index { color: var(--blue); font-size: 12px; font-weight: 750; }
.app-link span:last-child, .future-slot span:last-child { display: grid; gap: 5px; }
.app-link strong, .future-slot strong { font-size: 14px; }
.app-link small, .future-slot small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.future-slot { margin-top: 7px; opacity: .55; }
.sidebar-footer { margin-top: auto; padding: 20px 12px 0; display: grid; gap: 6px; border-top: 1px solid var(--line); }
.sidebar-footer strong { font-size: 12px; }
.sidebar-footer span { color: var(--muted); font-size: 12px; line-height: 1.4; }

.main { min-width: 0; padding: clamp(28px, 4vw, 58px); }
.page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 36px; align-items: end; }
.context-line { margin: 0 0 16px; color: var(--blue); font-size: 12px; font-weight: 700; }
.page-head h1 { margin: 0; max-width: 17ch; font-size: clamp(38px, 5vw, 62px); line-height: .99; letter-spacing: -.04em; }
.page-head h1 span { color: var(--blue-brand); }
.page-head > div:first-child > p:last-child { max-width: 61ch; margin: 22px 0 0; color: var(--muted); font-size: 16px; line-height: 1.55; }
.head-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.button { min-height: 43px; padding: 0 17px; border: 0; border-radius: 12px; font-weight: 700; transition: transform .16s ease, background-color .16s ease, border-color .16s ease; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button.primary { color: white; background: var(--blue); }
.button.primary:hover:not(:disabled) { background: #0c65d9; }
.button.secondary { color: var(--ink); background: white; border: 1px solid var(--line-strong); }
.button.secondary:hover:not(:disabled) { border-color: var(--blue); }
.button.danger { color: #8d3434; background: #ffebeb; }

.section-nav { margin-top: 46px; display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.nav-button { min-height: 45px; padding: 0 18px; color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; font-weight: 700; }
.nav-button.active { color: var(--blue); border-bottom-color: var(--blue); }
.content-section { display: none; padding-top: 28px; }
.content-section.active { display: block; }

.status-strip { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--navy); border-radius: 22px; overflow: hidden; }
.status-strip > div { min-height: 136px; padding: 24px; display: grid; align-content: space-between; border-left: 1px solid rgba(255,255,255,.12); }
.status-strip > div:first-child { border-left: 0; }
.status-strip span { color: #96aac5; font-size: 12px; }
.status-strip strong { color: white; font-size: 23px; letter-spacing: -.02em; }
.status-strip small { color: #c3d0e1; font-size: 12px; }

.system-panel { margin-top: 22px; padding: 30px; display: grid; grid-template-columns: 1fr 70px 1fr 70px 1fr; align-items: center; background: white; border-radius: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.055); }
.system-step { display: grid; grid-template-columns: 44px 1fr; gap: 15px; align-items: start; }
.step-number { width: 44px; height: 44px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); border-radius: 12px; font-size: 12px; font-weight: 800; }
.system-step strong { display: block; margin-top: 3px; font-size: 17px; }
.system-step p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.system-link { height: 1px; background: var(--line-strong); position: relative; }
.system-link span { position: absolute; right: -3px; top: -3px; width: 7px; height: 7px; background: var(--blue); border-radius: 50%; }

.split-panel { margin-top: 22px; display: grid; grid-template-columns: minmax(0, 1fr) 310px; background: white; border-radius: 22px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.055); }
.panel-main { padding: 28px; }
.panel-aside { padding: 28px; color: white; background: var(--navy-2); }
.panel-head, .settings-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.panel-head h2, .settings-head h2 { margin: 0; font-size: 25px; letter-spacing: -.025em; }
.panel-head p, .settings-head p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.panel-aside h3 { margin: 26px 0 10px; font-size: 23px; line-height: 1.08; }
.panel-aside p { color: #c8d5e5; font-size: 13px; line-height: 1.5; }
.aside-mark { display: inline-grid; place-items: center; width: 58px; height: 58px; color: white; background: var(--blue); border-radius: 16px; font-size: 13px; font-weight: 800; }
.panel-aside dl { margin: 30px 0 0; }
.panel-aside dl div { padding: 12px 0; display: flex; justify-content: space-between; gap: 15px; border-top: 1px solid rgba(255,255,255,.14); }
.panel-aside dt { color: #9fb1c9; font-size: 12px; }
.panel-aside dd { margin: 0; font-size: 12px; text-align: right; }

.event-list { margin-top: 22px; }
.event-row { padding: 15px 0; display: grid; grid-template-columns: 8px minmax(0,1fr) auto; gap: 13px; border-top: 1px solid var(--line); }
.event-row:first-child { border-top: 0; }
.event-mark { width: 5px; height: 38px; border-radius: 3px; background: var(--quiet); }
.event-row.delivered .event-mark { background: var(--green); }
.event-row.error .event-mark { background: var(--red); }
.event-row.suppressed .event-mark { background: var(--amber); }
.event-body { min-width: 0; }
.event-body strong { display: block; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.event-body p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.event-row time { color: var(--quiet); font-size: 12px; white-space: nowrap; }
.empty-state { padding: 40px 0; color: var(--quiet); text-align: center; }

.settings-panel, .journal-panel { padding: clamp(22px, 3vw, 36px); background: white; border-radius: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.055); }
.settings-grid { margin-top: 30px; display: grid; grid-template-columns: 1fr 1fr 1fr; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
fieldset { min-width: 0; margin: 0; padding: 26px; border: 0; border-left: 1px solid var(--line); }
fieldset:first-child { border-left: 0; }
legend { padding: 0; color: var(--blue); font-size: 13px; font-weight: 800; }
label { display: grid; gap: 7px; margin-top: 15px; color: var(--ink); font-size: 12px; font-weight: 700; }
label small { color: var(--quiet); font-weight: 400; }
input, textarea, select { width: 100%; color: var(--ink); background: #f8fbff; border: 1px solid var(--line-strong); border-radius: 11px; outline: none; }
input, select { height: 42px; padding: 0 12px; }
textarea { padding: 11px 12px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22,117,242,.12); }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch-row { min-height: 58px; padding: 11px; display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; background: var(--panel-soft); border-radius: 12px; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--blue); box-shadow: none; }
.switch-row span { display: grid; gap: 3px; }
.switch-row strong { font-size: 12px; }
.switch-row small { color: var(--muted); font-size: 12px; font-weight: 400; }
.info-note { margin-top: 20px; padding: 13px; color: #7a4e0e; background: #fff4df; border-radius: 12px; font-size: 12px; line-height: 1.45; }
.form-message { min-height: 20px; margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.form-message.ok { color: var(--green); }
.form-message.error { color: var(--red); }

.proxy-grid { margin-top: 30px; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.proxy-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.inline-buttons { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.journal-list { margin-top: 24px; }
.journal-list .event-row { min-height: 76px; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: 380px; padding: 14px 17px; color: white; background: var(--navy); border-radius: 13px; box-shadow: 0 20px 50px rgba(0,0,0,.22); opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 220px 1fr; }
  .main { padding: 32px; }
  .page-head { grid-template-columns: 1fr; align-items: start; }
  .head-actions { justify-content: flex-start; }
  .settings-grid { grid-template-columns: 1fr; }
  fieldset { border-left: 0; border-top: 1px solid var(--line); }
  fieldset:first-child { border-top: 0; }
}

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; }
  .topbar-status { display: none; }
  .workspace { display: block; }
  .sidebar { padding: 16px 20px; display: grid; grid-template-columns: 1fr; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-heading, .future-slot, .sidebar-footer { display: none; }
  .app-link { width: min(100%, 310px); min-height: 56px; }
  .main { padding: 26px 20px 42px; }
  .status-strip { grid-template-columns: 1fr 1fr; }
  .status-strip > div:nth-child(3) { border-left: 0; border-top: 1px solid rgba(255,255,255,.12); }
  .status-strip > div:nth-child(4) { border-top: 1px solid rgba(255,255,255,.12); }
  .system-panel { grid-template-columns: 1fr; gap: 16px; }
  .system-link { width: 1px; height: 30px; margin-left: 21px; }
  .system-link span { right: -3px; top: auto; bottom: -3px; }
  .split-panel, .proxy-grid { grid-template-columns: 1fr; }
  .panel-aside { min-height: 260px; }
  .proxy-grid fieldset + fieldset { border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 600px) {
  .topbar { height: 62px; padding: 0 16px; }
  .brand-lockup { font-size: 11px; }
  .brand-symbol { width: 30px; height: 30px; }
  .page-head h1 { font-size: 36px; }
  .head-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .head-actions .button { width: 100%; }
  .head-actions .primary { grid-column: 1 / -1; }
  .section-nav { overflow-x: auto; }
  .nav-button { flex: 0 0 auto; padding-inline: 13px; }
  .status-strip { grid-template-columns: 1fr; }
  .status-strip > div { min-height: 108px; border-left: 0; border-top: 1px solid rgba(255,255,255,.12); }
  .status-strip > div:first-child { border-top: 0; }
  .panel-head, .settings-head { display: grid; }
  .settings-head .button { width: 100%; }
  .two-fields, .proxy-fields { grid-template-columns: 1fr; }
  fieldset { padding: 22px 0; }
  .settings-panel, .journal-panel { padding: 20px; }
  .login-form { grid-template-columns: 1fr; }
  .login-form .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
