:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --line: #d9e1ea;
  --line-soft: #e9eef4;
  --text: #172033;
  --muted: #657084;
  --accent: #2364aa;
  --accent-strong: #174a82;
  --green: #127c56;
  --red: #b42318;
  --amber: #9a6700;
  --shadow: 0 16px 40px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(35, 100, 170, 0.10), transparent 42%),
    linear-gradient(315deg, rgba(18, 124, 86, 0.08), transparent 45%),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-logo {
  display: block;
  width: min(210px, 64%);
  height: auto;
  margin: 0 auto 26px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-weight: 800;
  font-size: 15px;
  min-width: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 26px;
  text-align: center;
}

.login-card > .muted {
  text-align: center;
}

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

.form-grid {
  display: grid;
  gap: 14px;
}

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

.field label {
  color: #354052;
  font-weight: 650;
  font-size: 13px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 7px;
  top: 50%;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
}

.password-toggle:hover,
.password-toggle.active {
  background: var(--panel-soft);
  color: var(--accent);
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle .icon-eye,
.password-toggle.active .icon-eye-off {
  display: none;
}

.password-toggle.active .icon-eye {
  display: block;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: -4px;
}

.remember-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.remember-option input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

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

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 100, 170, 0.14);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 86px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: clip;
  background: #172231;
  color: white;
  padding: 12px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 0 2px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

.sidebar-head .brand {
  flex: 1 1 auto;
}

.sidebar-head .brand-text {
  white-space: nowrap;
  font-size: 14px;
}

.brand-text,
.nav-label,
.nav-caret,
.sidebar-foot {
  transition: opacity 140ms ease, transform 140ms ease;
}

.sidebar-toggle {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: #e7eef8;
  display: grid;
  place-items: center;
}

.sidebar-toggle svg,
.nav-caret svg {
  display: block;
}

.sidebar-toggle svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}

.nav {
  display: grid;
  gap: 5px;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 8px 9px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  font-size: 13px;
  font-weight: 650;
}

.nav button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.nav-group {
  border-radius: 8px;
}

.nav-parent {
  min-height: 40px;
}

.nav-group.active .nav-parent {
  background: rgba(96, 165, 250, 0.12);
  color: #eaf3ff;
}

.nav-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.075);
  font-size: 16px;
  line-height: 1;
}

.nav-caret {
  margin-left: auto;
  color: #9ba9bb;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  transform: rotate(0deg);
}

.nav-caret svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 3.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-group.open .nav-caret {
  transform: rotate(90deg);
}

.nav-children {
  display: none;
  padding: 3px 0 5px 35px;
}

.nav-group.open .nav-children {
  display: grid;
  gap: 3px;
}

.nav-child {
  min-height: 31px;
}

.nav-child.active {
  background: #2463eb;
  color: white;
  box-shadow: 0 8px 18px rgba(36, 99, 235, 0.24);
}

.nav-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 99px;
  background: #66a3ff;
  opacity: 0.88;
}

.main {
  min-width: 0;
  padding: 14px 18px 18px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 42px;
  margin-bottom: 8px;
}

.account-menu {
  position: relative;
}

.account-button {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 5px 9px 5px 6px;
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.05);
}

.account-button:hover {
  border-color: #b7c2d0;
}

.account-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #e8f1ff;
  color: var(--accent-strong);
  font-weight: 850;
  font-size: 13px;
}

.account-text {
  display: grid;
  line-height: 1.1;
  text-align: left;
}

.account-text strong {
  font-size: 13px;
}

.account-text small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}

.account-caret {
  color: var(--muted);
  font-size: 13px;
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 150px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  display: none;
  z-index: 12;
}

.account-dropdown.open {
  display: grid;
}

.account-dropdown button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 650;
}

.account-dropdown button:hover {
  background: var(--panel-soft);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.title-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.customer-toolbar {
  flex: 1 1 auto;
  flex-wrap: nowrap;
  min-width: 0;
}

.customer-toolbar .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.customer-toolbar .search-field {
  width: auto;
  flex: 1 1 360px;
  min-width: 220px;
  max-width: 430px;
}

.list-toolbar,
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.list-toolbar {
  border-bottom: 1px solid var(--line-soft);
}

.pagination {
  border-top: 1px solid var(--line-soft);
}

.search-field {
  width: min(430px, 100%);
  flex: 0 1 430px;
}

.search-field input,
.pagination select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--text);
  min-height: 34px;
  padding: 7px 10px;
  outline: none;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.quick-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  min-height: 34px;
  border-radius: 7px;
  padding: 7px 11px;
  font-weight: 700;
  font-size: 13px;
}

.btn:hover {
  border-color: #b7c2d0;
  background: var(--panel-soft);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.btn.primary:hover {
  background: var(--accent-strong);
}

.btn.danger {
  color: var(--red);
}

.btn.ghost {
  background: transparent;
  color: inherit;
  border-color: rgba(255, 255, 255, 0.18);
}

.grid {
  display: grid;
  gap: 14px;
}

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

.stat,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat {
  padding: 14px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 7px;
  font-size: 24px;
}

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

.stat-pair strong small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
}

.panel-body {
  padding: 14px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  font-size: 13px;
}

th {
  background: var(--panel-soft);
  color: #3a4657;
  font-size: 11px;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 750;
  background: #edf2f7;
  color: #344054;
  white-space: nowrap;
}

.badge.admin {
  background: #e8f1ff;
  color: #174a82;
}

.badge.active {
  background: #e7f6ef;
  color: var(--green);
}

.badge.disabled {
  background: #fff0ed;
  color: var(--red);
}

.badge.warn {
  background: #fff6df;
  color: var(--amber);
}

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

.dashboard-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 14px;
}

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

.detail-list {
  display: grid;
  gap: 12px;
}

.detail-item {
  display: grid;
  gap: 5px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.detail-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.detail-item span {
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong {
  font-size: 13px;
  line-height: 1.45;
}

.attachment-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--text);
  text-decoration: none;
}

.attachment-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.attachment-item small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.timeline {
  padding: 14px 16px 16px;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
}

.timeline-item + .timeline-item {
  margin-top: 14px;
}

.timeline-dot {
  width: 9px;
  height: 9px;
  margin-top: 13px;
  border-radius: 99px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(35, 100, 170, 0.12);
}

.timeline-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.timeline-head span {
  color: var(--muted);
  font-size: 12px;
}

.timeline-card p {
  margin: 9px 0 0;
  line-height: 1.55;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 750;
}

.mini-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.mini-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-soft);
}

.mini-row strong {
  font-size: 13px;
}

.mini-row span {
  color: var(--muted);
  font-size: 12px;
}

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

.drawer {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 20;
}

.drawer.open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, 0.38);
}

.drawer-panel {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(520px, 100%);
  background: white;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.drawer-head {
  padding: 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-head h2 {
  margin: 0;
  font-size: 17px;
}

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

.sidebar-collapsed .sidebar {
  padding: 18px 10px;
}

.sidebar-collapsed .sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 0 10px;
  gap: 6px;
}

.sidebar-collapsed .brand {
  justify-content: center;
  width: auto;
}

.sidebar-collapsed .brand-mark {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  font-size: 16px;
}

.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-caret {
  display: none;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-6px);
}

.sidebar-collapsed .sidebar-toggle {
  position: static;
  width: 28px;
  height: 34px;
  flex: 0 0 28px;
  background: transparent;
  border-color: transparent;
  color: #f8fbff;
}

.sidebar-collapsed .sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

.sidebar-collapsed .nav button {
  justify-content: center;
  padding-inline: 0;
  gap: 0;
}

.sidebar-collapsed .nav {
  gap: 18px;
  justify-items: center;
}

.sidebar-collapsed .nav-group {
  width: 64px;
  display: grid;
  justify-items: center;
}

.sidebar-collapsed .nav-parent {
  width: 64px;
  height: 64px;
  min-height: 64px;
  padding: 0;
  border-radius: 14px;
}

.sidebar-collapsed .nav-group.active .nav-parent {
  background: #2f6df6;
  box-shadow: 0 12px 28px rgba(47, 109, 246, 0.32);
}

.sidebar-collapsed .nav-icon {
  width: 44px;
  height: 44px;
  flex-basis: 44px;
  border-radius: 12px;
  background: transparent;
  font-size: 25px;
}

.sidebar-collapsed .nav-children,
.sidebar-collapsed .nav-group.open .nav-children {
  display: none;
}

.sidebar-collapsed .nav-group.active .nav-parent {
  background: rgba(96, 165, 250, 0.18);
}

.alert {
  border-radius: 7px;
  padding: 10px 12px;
  margin: 12px 0;
  background: #fff0ed;
  color: var(--red);
}

.success {
  background: #e7f6ef;
  color: var(--green);
}

.hide {
  display: none !important;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .sidebar {
    z-index: 10;
  }

  .stats,
  .split,
  .dashboard-panels,
  .detail-grid,
  .related-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar,
  .search-field {
    width: 100%;
  }

  .customer-toolbar {
    flex-wrap: wrap;
  }

  .customer-toolbar .search-field {
    max-width: none;
  }

  .stats {
    gap: 10px;
  }
}
