:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #eef3f2;
  --line: #d9e1df;
  --text: #17211f;
  --muted: #687773;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #b45309;
  --danger: #b42318;
  --ok: #177245;
  --shadow: 0 12px 30px rgba(17, 35, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

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

button {
  border: 0;
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(180, 83, 9, 0.08)),
    var(--bg);
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

.login-panel h1,
.page-title h1 {
  margin: 16px 0 6px;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

.page-title h1 {
  margin: 0;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  background: #10201d;
  color: white;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-title {
  font-weight: 750;
  line-height: 1.15;
}

.sidebar-subtitle {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  margin-top: 2px;
}

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

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.8);
  background: transparent;
  padding: 9px 10px;
  text-align: left;
}

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

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.user-chip {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

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

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

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.content-stack {
  display: grid;
  gap: 16px;
}

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

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

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

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

.stat,
.panel,
.login-panel {
  background: var(--panel);
}

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

.stat {
  padding: 16px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-value {
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
  font-weight: 760;
  letter-spacing: 0;
}

.stat-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  padding: 16px;
  overflow: hidden;
}

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

.panel h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.panel h2 {
  font-size: 18px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

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

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 94px;
  resize: vertical;
}

select[multiple] {
  min-height: 142px;
  padding: 6px;
}

select[multiple] option {
  padding: 6px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--brand);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 7px;
  padding: 8px 13px;
  color: white;
  background: var(--brand);
  font-weight: 700;
}

.btn:hover {
  background: var(--brand-dark);
}

.btn.secondary {
  color: var(--text);
  background: var(--panel-soft);
}

.btn.secondary:hover {
  background: #e2ebe8;
}

.btn.danger {
  background: var(--danger);
}

.btn.full {
  width: 100%;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.member-table {
  display: block;
}

.mobile-card-list {
  display: none;
}

.mobile-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

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

.mobile-card-head > div:not(.mobile-rank) {
  flex: 1;
  min-width: 0;
}

.mobile-card-title {
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.mobile-rank {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--brand-dark);
  font-weight: 800;
}

.mobile-metric {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

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

.mobile-metric strong {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.mobile-card .progress {
  width: 100%;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

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

.progress {
  width: 150px;
  height: 8px;
  border-radius: 999px;
  background: #e6ecea;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  max-width: 100%;
  background: var(--brand);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  color: var(--ok);
  background: rgba(23, 114, 69, 0.12);
}

.badge.warn {
  color: var(--accent);
  background: rgba(180, 83, 9, 0.12);
}

.badge.danger {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.12);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: 360px;
  border-radius: 8px;
  background: #10201d;
  color: white;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

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

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

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 760;
}

.salary-slip {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(190px, 1fr);
  border: 2px solid #101918;
  background: white;
  max-width: 860px;
}

.salary-main {
  border-right: 2px solid #101918;
}

.salary-month {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-bottom: 2px solid #101918;
  background: #20d8d4;
  font-size: 30px;
  letter-spacing: 0;
}

.salary-branch-row {
  min-height: 86px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 2px solid #101918;
  background: #dceaf3;
}

.salary-branch-row > div {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  font-size: 22px;
  text-align: center;
  border-right: 2px solid #101918;
}

.salary-branch-row > div:last-child {
  border-right: 0;
}

.salary-name-row {
  display: grid;
  grid-template-columns: 126px 1fr;
  border-bottom: 2px solid #101918;
}

.salary-name-row > div,
.salary-name-row > strong {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 7px 12px;
}

.salary-name-row > div {
  justify-content: center;
  background: #dceaf3;
  border-right: 2px solid #101918;
}

.salary-name-row > strong {
  justify-content: flex-end;
  font-size: 18px;
}

.salary-lines {
  display: grid;
}

.salary-line {
  display: grid;
  grid-template-columns: 126px 1fr;
  min-height: 40px;
}

.salary-line > div {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  font-size: 20px;
}

.salary-line > div:first-child {
  justify-content: center;
  border-right: 2px solid #101918;
  background: #dceaf3;
  font-size: 16px;
  font-weight: 800;
}

.salary-line > div:last-child {
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
  font-size: 24px;
}

.salary-line.danger > div {
  color: #c1121f;
}

.salary-line.net > div {
  background: #c9f1cf;
  font-weight: 800;
}

.salary-logo-panel {
  display: grid;
  place-items: center;
  min-height: 430px;
  background: #dceaf3;
}

.salary-logo {
  width: 136px;
  height: 136px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border-radius: 50%;
  background: #2d2d2d;
  color: white;
}

.salary-logo-bars {
  display: flex;
  gap: 5px;
}

.salary-logo-bars span {
  width: 21px;
  height: 40px;
  background: white;
}

.salary-logo-bars span:first-child {
  background: #20d8d4;
}

.salary-logo small {
  color: rgba(255, 255, 255, 0.75);
  font-size: 10px;
}

.hide {
  display: none !important;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .salary-slip {
    grid-template-columns: 1fr;
  }

  .salary-main {
    border-right: 0;
    border-bottom: 2px solid #101918;
  }

  .salary-logo-panel {
    min-height: 180px;
  }
}

@media (max-width: 680px) {
  .main {
    padding: 14px;
  }

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

  .nav,
  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 20px;
  }

  .salary-month {
    min-height: 62px;
    font-size: 24px;
  }

  .salary-branch-row,
  .salary-name-row,
  .salary-line {
    grid-template-columns: 108px 1fr;
  }

  .salary-branch-row {
    grid-template-columns: 1fr;
  }

  .salary-branch-row > div {
    min-height: 54px;
    border-right: 0;
    border-bottom: 2px solid #101918;
    font-size: 18px;
  }

  .salary-branch-row > div:last-child {
    border-bottom: 0;
  }

  .salary-line > div:first-child {
    font-size: 13px;
  }

  .salary-line > div:last-child {
    font-size: 20px;
  }

  .role-sales .sidebar {
    gap: 12px;
    padding: 12px;
  }

  .role-sales .sidebar-head {
    padding-bottom: 10px;
  }

  .role-sales .brand-mark {
    width: 36px;
    height: 36px;
  }

  .role-sales .sidebar-title {
    font-size: 15px;
  }

  .role-sales .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .role-sales .nav button {
    justify-content: center;
    min-height: 36px;
    padding: 8px;
    text-align: center;
    font-size: 13px;
  }

  .role-sales .main {
    padding: 10px;
  }

  .role-sales .topbar {
    gap: 10px;
    margin-bottom: 12px;
  }

  .role-sales .page-title h1 {
    font-size: 22px;
  }

  .role-sales .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .role-sales .topbar-actions input,
  .role-sales .topbar-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .role-sales .content-stack {
    gap: 12px;
  }

  .role-sales .grid.cols-4,
  .role-sales .grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .role-sales .stat {
    min-height: 92px;
    padding: 12px;
  }

  .role-sales .stat-label {
    font-size: 11px;
  }

  .role-sales .stat-value {
    font-size: 22px;
    overflow-wrap: anywhere;
  }

  .role-sales .stat-note {
    font-size: 12px;
  }

  .role-sales .panel {
    padding: 12px;
  }

  .role-sales .panel-head {
    align-items: flex-start;
    margin-bottom: 10px;
  }

  .role-sales .panel h2 {
    font-size: 16px;
    line-height: 1.25;
  }

  .role-sales .member-table {
    display: none;
  }

  .role-sales .mobile-card-list {
    display: grid;
    gap: 10px;
  }

  .role-sales .salary-slip {
    width: 100%;
    max-width: 100%;
    border-width: 1px;
  }

  .role-sales .salary-main {
    border-bottom-width: 1px;
  }

  .role-sales .salary-month {
    min-height: 56px;
    gap: 8px;
    border-bottom-width: 1px;
    font-size: 20px;
  }

  .role-sales .salary-branch-row > div {
    min-height: 46px;
    padding: 10px;
    border-bottom-width: 1px;
    font-size: 16px;
  }

  .role-sales .salary-name-row,
  .role-sales .salary-line {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .role-sales .salary-name-row {
    border-bottom-width: 1px;
  }

  .role-sales .salary-name-row > div,
  .role-sales .salary-name-row > strong {
    min-height: 34px;
    padding: 6px 8px;
  }

  .role-sales .salary-name-row > div,
  .role-sales .salary-line > div:first-child {
    border-right-width: 1px;
  }

  .role-sales .salary-name-row > strong {
    justify-content: flex-end;
    text-align: right;
    font-size: 15px;
    overflow-wrap: anywhere;
  }

  .role-sales .salary-line {
    min-height: 36px;
  }

  .role-sales .salary-line > div {
    padding: 6px 8px;
  }

  .role-sales .salary-line > div:first-child {
    font-size: 12px;
  }

  .role-sales .salary-line > div:last-child {
    font-size: 18px;
    overflow-wrap: anywhere;
  }

  .role-sales .salary-logo-panel {
    min-height: 112px;
  }

  .role-sales .salary-logo {
    width: 96px;
    height: 96px;
  }

  .role-sales .salary-logo-bars span {
    width: 15px;
    height: 30px;
  }
}

@media (max-width: 400px) {
  .role-sales .topbar-actions,
  .role-sales .grid.cols-4,
  .role-sales .grid.cols-3 {
    grid-template-columns: 1fr;
  }
}
