:root {
  --bg: #f3f7ff;
  --bg-alt: #edf3ff;
  --panel: #ffffff;
  --panel-soft: #f6f9ff;
  --line: #d8e3f7;
  --text: #162540;
  --muted: #6b7fa3;
  --brand: #16b892;
  --brand-soft: rgba(22, 184, 146, 0.12);
  --positive: #1f9f73;
  --warning: #b97314;
  --neutral: #3f78d6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  font-family: "Inter", "Noto Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 14% -10%, rgba(22, 184, 146, 0.14), transparent 36%),
    radial-gradient(circle at 100% 10%, rgba(91, 145, 238, 0.14), transparent 32%),
    linear-gradient(165deg, var(--bg), var(--bg-alt));
  overflow: hidden;
}

p,
span,
a,
button,
h1,
h2,
h3,
strong,
li,
td,
th {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.erp-app {
  height: 100%;
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  padding: 12px;
}

.erp-app > * {
  min-width: 0;
}

.sidebar,
.main {
  border: 1px solid rgba(124, 153, 204, 0.32);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
}

.sidebar {
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  min-width: 0;
}

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

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(145deg, #20caa4, #16b892);
  box-shadow: 0 10px 24px rgba(22, 184, 146, 0.3);
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

.menu {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.menu a {
  text-decoration: none;
  border-radius: 10px;
  color: #3f557e;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  min-width: 0;
}

.menu a.active {
  background: var(--brand-soft);
  border-color: rgba(22, 184, 146, 0.28);
  color: #0d7e65;
}

.quick-alert {
  align-self: end;
  border-radius: 12px;
  border: 1px solid rgba(124, 155, 210, 0.34);
  background: var(--panel-soft);
  padding: 10px;
}

.card-kicker {
  font-size: 11px;
  letter-spacing: 0.3px;
  color: var(--muted);
}

.quick-alert ul {
  list-style: none;
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.quick-alert li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: #2f4162;
}

.quick-alert strong {
  color: var(--warning);
}

.main {
  padding: 14px;
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.topbar h1 {
  margin-top: 3px;
  font-size: 22px;
  line-height: 1.2;
  max-width: 680px;
}

.toolbar {
  display: flex;
  min-width: 0;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar button {
  min-width: 0;
  border: 1px solid rgba(129, 161, 216, 0.35);
  border-radius: 999px;
  background: #ffffff;
  color: #3f557d;
  font-size: 11px;
  font-weight: 600;
  padding: 7px 11px;
}

.toolbar button.accent,
.lang-btn.active {
  border-color: rgba(22, 184, 146, 0.5);
  background: rgba(22, 184, 146, 0.12);
  color: #0d7e65;
}

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

.metric-card {
  border-radius: 12px;
  border: 1px solid rgba(126, 158, 212, 0.3);
  background: linear-gradient(180deg, #ffffff, #f7faff);
  padding: 10px;
}

.metric-card p {
  font-size: 11px;
  color: var(--muted);
}

.metric-card h2 {
  margin-top: 5px;
  font-size: 16px;
}

.metric-card span {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
}

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

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

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

.content-grid {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: 1.6fr minmax(250px, 0.8fr);
  gap: 10px;
}

.content-grid > * {
  min-width: 0;
}

.panel {
  min-width: 0;
  min-height: 0;
  border-radius: 14px;
  border: 1px solid rgba(127, 161, 219, 0.28);
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 12px;
  overflow-x: hidden;
}

.panel-head h3 {
  font-size: 15px;
}

.panel-head p {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.channel-bars {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.bar-item {
  display: grid;
  gap: 4px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #425b84;
}

.bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(126, 158, 211, 0.25);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #20caa4, #67d8be);
}

.fill-48 {
  width: 48%;
}

.fill-31 {
  width: 31%;
}

.fill-21 {
  width: 21%;
}

.table-wrap {
  margin-top: 10px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

thead th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 8px;
  border-bottom: 1px solid rgba(121, 154, 211, 0.24);
  background: #f2f7ff;
  position: sticky;
  top: 0;
  white-space: normal;
}

tbody td {
  padding: 9px 8px;
  color: #2e4366;
  border-bottom: 1px solid rgba(109, 143, 198, 0.16);
  white-space: normal;
}

.tag {
  display: inline-flex;
  border-radius: 999px;
  font-size: 10px;
  padding: 4px 7px;
}

.tag.done {
  background: rgba(31, 159, 115, 0.12);
  color: #1b8762;
}

.tag.running {
  background: rgba(63, 120, 214, 0.14);
  color: #3367bc;
}

.tag.review {
  background: rgba(185, 115, 20, 0.14);
  color: #9f6318;
}

.side-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
}

.cash-list {
  display: grid;
  gap: 8px;
}

.cash-list > div {
  border: 1px solid rgba(124, 155, 210, 0.3);
  border-radius: 10px;
  background: #f8fbff;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.cash-list span {
  font-size: 11px;
  color: var(--muted);
}

.cash-list strong {
  font-size: 15px;
}

.positive-value {
  color: var(--positive);
}

.insight {
  align-self: end;
  border-radius: 10px;
  border: 1px solid rgba(22, 184, 146, 0.3);
  background: rgba(22, 184, 146, 0.08);
  padding: 10px;
}

.insight p {
  font-size: 11px;
  color: #2f8f78;
}

.insight strong {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
}

.mobile-nav {
  display: none;
}

@media (max-width: 540px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .erp-app {
    height: auto;
    min-height: 100%;
    width: 100%;
    max-width: 100%;
    grid-template-columns: 1fr;
    padding-bottom: 74px;
  }

  .quick-alert {
    display: none;
  }

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

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

@media (max-width: 420px) {
  .erp-app {
    padding: 10px;
    gap: 10px;
    padding-bottom: 74px;
    overflow-x: hidden;
  }

  .sidebar,
  .main {
    border-radius: 14px;
  }

  .sidebar {
    padding: 10px;
  }

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

  .menu a {
    text-align: center;
    padding: 7px 4px;
    font-size: 11px;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 17px;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar button {
    flex: 1 1 calc(50% - 6px);
    max-width: 100%;
    min-width: 0;
  }

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

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

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 60px;
    border-top: 1px solid rgba(126, 157, 212, 0.32);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    text-align: center;
    align-items: center;
    max-width: 100vw;
  }

  .mobile-nav a {
    text-decoration: none;
    color: #5b7198;
    font-size: 11px;
    font-weight: 600;
    min-width: 0;
  }

  .mobile-nav a.active {
    color: #10977a;
  }
}

body.force-desktop {
  overflow: hidden;
}

body.force-desktop .erp-app {
  height: 100%;
  min-height: 0;
  grid-template-columns: 220px 1fr;
  padding: 12px;
}

body.force-desktop .sidebar,
body.force-desktop .main,
body.force-desktop .panel {
  overflow-x: hidden;
}

body.force-desktop .metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

body.force-desktop .content-grid {
  grid-template-columns: 1.6fr minmax(250px, 0.8fr);
}

body.force-desktop .quick-alert {
  display: block;
}

body.force-desktop .mobile-nav {
  display: none;
}

body.force-mobile {
  overflow-x: hidden;
  overflow-y: auto;
}

body.force-mobile .erp-app {
  height: auto;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  grid-template-columns: 1fr;
  padding-bottom: 74px;
  overflow-x: hidden;
}

body.force-mobile .quick-alert {
  display: none;
}

body.force-mobile .metric-grid {
  grid-template-columns: 1fr;
}

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

body.force-mobile .sidebar,
body.force-mobile .main,
body.force-mobile .panel {
  overflow-x: hidden;
}

body.force-mobile .menu {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.force-mobile table {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}

body.force-mobile .mobile-nav {
  display: grid;
  max-width: 100vw;
}
