:root {
  --brand: #26306f;
  --brand-strong: #111a52;
  --accent: #b9151b;
  --ink: #151820;
  --muted: #69707f;
  --line: #d6d9e0;
  --panel: #f3f4f7;
  --surface: #ffffff;
  --success: #157a54;
  --warning: #9a6200;
  --danger: #b91c1c;
  --focus: #3b70ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #e8eaef;
  color: var(--ink);
  font-size: 15px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(135deg, rgba(247, 249, 253, 0.94) 0%, rgba(230, 234, 243, 0.92) 52%, rgba(210, 217, 232, 0.86) 100%),
    url("/assets/img/login-bg.svg");
  background-size: cover;
  background-position: center;
}

.login-stage {
  width: min(1040px, 100%);
  display: grid;
  gap: 22px;
}

.login-hero-logo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  padding: 0 4px;
}

.login-hero-logo .mark {
  width: 82px;
  height: 58px;
}

.login-hero-logo .brand-title {
  font-size: 42px;
}

.login-hero-logo .brand-subtitle {
  text-align: left;
  font-size: 22px;
}

.login-panel {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(320px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.login-card,
.login-side {
  border: 1px solid rgba(186, 194, 211, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 50px rgba(18, 22, 40, 0.16);
}

.login-card {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.login-card-head h2 {
  margin: 0;
  color: var(--brand);
  font-size: 28px;
}

.login-card-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.login-side {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mark {
  width: 76px;
  height: 54px;
  border-radius: 6px;
  background: var(--brand);
  clip-path: polygon(0 0, 74% 0, 100% 100%, 0 100%);
}

.brand-title {
  margin: 0;
  color: var(--brand);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}

.brand-subtitle {
  color: var(--accent);
  font-size: 22px;
}

.login-form {
  display: grid;
  gap: 14px;
  align-self: center;
}

.login-form .field label {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  color: var(--ink);
  font-weight: 800;
}

.login-form input {
  min-height: 46px;
  background: #fff;
}

.login-form .primary-btn {
  min-height: 46px;
  margin-top: 4px;
}

.login-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.login-actions a {
  min-height: 42px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.demo-action {
  background: #b9151b;
}

.info-action {
  background: #111;
}

.login-news {
  display: grid;
  gap: 0;
  align-content: start;
}

.login-news a {
  min-height: 70px;
  display: grid;
  grid-template-columns: 54px 1fr;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.login-news strong {
  display: block;
  color: var(--brand);
  margin-top: 2px;
}

.news-thumb {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(38, 48, 111, 0.14), rgba(185, 21, 27, 0.12)),
    #fff;
  border: 1px solid rgba(38, 48, 111, 0.12);
}

.login-news .see-more {
  min-height: auto;
  display: block;
  padding: 8px 0 0;
  text-align: center;
  background: transparent;
  font-weight: 800;
  color: var(--brand);
}

.login-branches {
  display: none;
}

.contact-card {
  padding: 24px;
  background: var(--brand);
  color: #fff;
}

.contact-card h2 {
  margin: 0 0 6px;
  color: #fff;
  font-size: 24px;
}

.contact-card p {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.92);
}

.contact-card strong {
  color: #fff;
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.filter-label {
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.filter-panel input,
.filter-panel select {
  width: 100%;
  border: 1px solid #c7cbd5;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.primary-btn,
.secondary-btn,
.icon-btn,
.danger-btn {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.primary-btn {
  background: var(--brand);
  color: #fff;
}

.secondary-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--brand);
}

button:disabled,
button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.45;
}

.danger-btn {
  background: #fff;
  border-color: #efb4b4;
  color: var(--danger);
}

.icon-btn {
  width: 38px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 118px 1fr;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(330px, 392px) 58px minmax(0, 1fr);
  align-items: stretch;
  background: #fff;
  border-bottom: 2px solid #c7cbd5;
  overflow: hidden;
}

.top-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  padding: 18px 24px;
  min-width: 0;
}

.top-menu-control {
  display: grid;
  place-items: center;
  background: linear-gradient(90deg, #fff 0 42%, var(--brand) 42% 100%);
  border-left: 1px solid var(--line);
  border-right: 0;
  position: relative;
  z-index: 2;
}

.top-menu-control::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--brand);
  clip-path: polygon(44% 0, 100% 0, 100% 100%, 0 100%);
  z-index: -1;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.top-brand .brand-title {
  font-size: 30px;
  white-space: nowrap;
}

.menu-toggle {
  width: 42px;
  min-width: 42px;
  height: 42px;
  border-color: rgba(21, 92, 171, 0.22);
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(12, 22, 54, 0.14);
  flex: 0 0 auto;
}

.menu-toggle:hover,
.menu-toggle:focus {
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: 0 0 0 3px rgba(21, 92, 171, 0.14), 0 8px 20px rgba(12, 22, 54, 0.18);
}

.menu-bars,
.menu-bars::before,
.menu-bars::after {
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  display: block;
}

.menu-bars {
  position: relative;
}

.menu-bars::before,
.menu-bars::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-bars::before {
  top: -6px;
}

.menu-bars::after {
  top: 6px;
}

.menu-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(135deg);
  transition: transform 160ms ease;
}

.menu-toggle[aria-expanded="false"] .menu-chevron {
  transform: rotate(-45deg);
}

.top-nav {
  display: flex;
  align-items: stretch;
  background: var(--brand);
  padding-left: 0;
  clip-path: none;
  min-width: 0;
  overflow-x: auto;
}

.top-nav.collapsed {
  padding-left: 0;
  clip-path: none;
  justify-content: flex-start;
  overflow: hidden;
}

.top-nav.collapsed .nav-item,
.top-nav.collapsed .nav-group:not(.active) {
  display: none;
}

.nav-item {
  min-width: 92px;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #fff;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 14px 12px 12px;
  font-weight: 700;
}

.nav-item.active {
  background: #fff;
  color: #000;
}

.nav-group {
  position: relative;
  display: grid;
}

.nav-group > .nav-item {
  height: 100%;
}

.nav-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  display: none;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(18, 24, 38, 0.18);
  z-index: 35;
}

.nav-group:hover .nav-menu,
.nav-group:focus-within .nav-menu,
.nav-group.open .nav-menu {
  display: grid;
}

.nav-menu button {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
}

.nav-menu button:hover,
.nav-menu button:focus,
.nav-menu button.active {
  background: #edf4ff;
  color: var(--brand);
}

.nav-icon {
  width: 28px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid currentColor;
  position: relative;
}

.nav-icon::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-top: 2px solid currentColor;
}

.content {
  display: grid;
  grid-template-columns: 464px minmax(0, 1fr);
  min-height: 0;
}

.filter-panel {
  background: #efefef;
  border-right: 2px solid #bfc3cc;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: width 160ms ease, padding 160ms ease;
}

.filter-header {
  display: flex;
  justify-content: flex-end;
}

.filter-panel.collapsed {
  width: 66px;
  padding: 18px 12px;
}

.filter-panel.collapsed .filter-header {
  justify-content: center;
}

.filter-panel.collapsed .filter-content {
  display: none;
}

.content.filters-collapsed {
  grid-template-columns: 66px minmax(0, 1fr);
}

.main-pane.is-loading {
  opacity: 0.7;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.toggle-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.switch {
  width: 54px;
  height: 28px;
  border-radius: 999px;
  border: 0;
  background: #c8cbd2;
  position: relative;
}

.switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
}

.switch.on {
  background: var(--brand);
}

.switch.on::after {
  left: 29px;
}

.main-pane {
  min-width: 0;
  padding: 0 12px 24px;
}

.page-header {
  margin: 0 0 10px;
  background: var(--brand);
  color: #fff;
  padding: 9px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search {
  min-width: 260px;
  border: 1px solid #c7cbd5;
  border-radius: 6px;
  padding: 9px 12px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid #e3e5eb;
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th:last-child,
td:last-child {
  width: 240px;
}

th {
  background: #f2f3f5;
  font-weight: 800;
  white-space: nowrap;
}

td {
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.row-actions .secondary-btn,
.row-actions .danger-btn {
  min-width: 72px;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #e8edf8;
  color: var(--brand-strong);
}

.status.good {
  background: #e5f5ee;
  color: var(--success);
}

.status.warn {
  background: #fff3d8;
  color: var(--warning);
}

.status.bad {
  background: #fde8e8;
  color: var(--danger);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}

.metric-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--brand);
}

.metric-label {
  color: var(--muted);
}

.modal-backdrop,
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 28, 0.42);
  display: none;
  z-index: 20;
}

.modal-backdrop.open,
.drawer-backdrop.open {
  display: block;
}

.modal-backdrop.open {
  display: grid;
  place-items: center;
  z-index: 60;
}

.modal {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  margin: 24px auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.modal-head,
.modal-foot,
.drawer-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-body {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100vh;
  background: #fff;
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.24);
  transform: translateX(100%);
  transition: transform 180ms ease;
  z-index: 30;
  display: grid;
  grid-template-rows: auto 1fr;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-body {
  overflow: auto;
  padding: 18px;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 10px 12px;
  font-weight: 800;
  color: var(--muted);
}

.tab.active {
  color: var(--brand);
  border-bottom: 3px solid var(--brand);
}

.drawer-tab-panel.hidden {
  display: none;
}

.related-list {
  display: grid;
  gap: 10px;
}

.related-list article {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.related-list p {
  margin: 4px 0 0;
}

.related-head,
.related-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.related-head {
  margin-bottom: 10px;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
}

.empty.compact {
  padding: 20px 8px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  min-width: 240px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 160ms ease;
  z-index: 40;
}

.toast.open {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1050px) {
  .login-panel,
  .login-branches {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-rows: auto 1fr;
  }

  .topbar {
    grid-template-columns: 1fr 58px;
  }

  .top-nav {
    grid-column: 1 / -1;
    clip-path: none;
    padding-left: 0;
    overflow-x: auto;
  }

  .top-menu-control {
    border-right: 0;
  }

  .content {
    grid-template-columns: 1fr;
  }

  .content.filters-collapsed {
    grid-template-columns: 1fr;
  }

  .filter-panel.collapsed {
    width: auto;
  }

  .filter-panel {
    border-right: 0;
    border-bottom: 2px solid #bfc3cc;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .login-page {
    padding: 16px;
  }

  .login-panel {
    gap: 22px;
  }

  .login-hero-logo {
    align-items: flex-start;
    gap: 12px;
  }

  .login-hero-logo .mark {
    width: 64px;
    height: 48px;
    flex: 0 0 auto;
  }

  .login-hero-logo .brand-title {
    font-size: 26px;
    white-space: normal;
    overflow-wrap: normal;
    line-height: 1.05;
  }

  .login-hero-logo .brand-subtitle {
    font-size: 18px;
  }

  .login-news a {
    min-height: 62px;
  }

  .login-actions {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 22px;
  }

  .login-card-head h2 {
    font-size: 24px;
  }

  .top-brand .brand-title {
    font-size: 26px;
  }

  .top-brand {
    padding: 14px 16px;
  }

  .brand-lockup {
    gap: 12px;
  }

  .menu-toggle {
    width: 42px;
    min-width: 42px;
    padding: 0;
  }

  .nav-item {
    min-width: 82px;
  }

  .nav-menu {
    left: 0;
    right: auto;
    min-width: min(240px, calc(100vw - 24px));
  }

  .tabs {
    overflow-x: auto;
  }

  .filter-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    min-width: 0;
    width: 100%;
  }

  table {
    min-width: 0;
    table-layout: fixed;
  }

  thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tbody {
    display: grid;
    gap: 10px;
    padding: 10px;
    background: #f3f5f9;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
  }

  th,
  td {
    white-space: normal;
  }

  td {
    display: grid;
    grid-template-columns: minmax(96px, 38%) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 800;
  }

  td.empty {
    display: block;
    width: auto;
  }

  td.empty::before {
    content: none;
  }

  .status {
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
  }

  .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }

  .row-actions button {
    min-width: 0;
    flex: 1 1 74px;
    padding-left: 8px;
    padding-right: 8px;
  }
}
