:root {
  --bg: #f7f8f5;
  --panel: #ffffff;
  --panel-soft: #fef7f8;
  --ink: #243033;
  --muted: #687274;
  --line: #dde4de;
  --rose: #bb5867;
  --rose-dark: #963f4d;
  --teal: #2f7370;
  --teal-soft: #e5f2ef;
  --sage: #748c65;
  --sun: #d89b3d;
  --danger: #b64545;
  --shadow: 0 18px 45px rgba(36, 48, 51, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(187, 88, 103, 0.1), transparent 34rem),
    linear-gradient(135deg, #f7f8f5 0%, #eef4f1 100%);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  min-height: 100vh;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  width: min(1040px, 100%);
  overflow: hidden;
  border: 1px solid rgba(36, 48, 51, 0.08);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.installer-card {
  grid-template-columns: 1fr;
  max-width: 760px;
}

.login-visual {
  position: relative;
  min-height: 560px;
  background: #dfe8e3;
}

.login-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-visual__label {
  position: absolute;
  right: 20px;
  bottom: 20px;
  width: min(330px, calc(100% - 40px));
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
}

.login-visual__label strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.2rem;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  min-width: 0;
  padding: 38px;
}

.login-topline,
.topbar,
.section-header,
.toolbar,
.form-row,
.inline-actions,
.staff-line {
  display: flex;
  align-items: center;
}

.login-topline,
.section-header,
.toolbar {
  justify-content: space-between;
  gap: 14px;
}

.brand-block h1,
.section-header h2,
.form-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-block h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  line-height: 1.05;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.brand-block p,
.login-visual__label p,
.section-header p,
.empty-state,
.hint,
.muted {
  color: var(--muted);
}

.brand-block p {
  margin: 12px 0 0;
  font-size: 1rem;
  max-width: 34ch;
  overflow-wrap: anywhere;
}

.language-select,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.language-select {
  width: auto;
  min-width: 128px;
  padding: 0 12px;
}

.language-form,
.inline-form,
.topbar form {
  margin: 0;
}

.inline-form {
  display: inline-flex;
}

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

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

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

.field label {
  font-weight: 700;
  color: #304044;
}

.field input,
.field select,
.field textarea {
  padding: 10px 12px;
}

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

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--rose);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.button:hover {
  background: var(--rose-dark);
}

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

.button.secondary:hover {
  background: #f4f7f4;
}

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

.button.compact {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.92rem;
}

.message {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.message.success {
  color: var(--teal);
}

.account-list {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.account-list p {
  margin: 0;
}

.account-list code {
  display: inline-block;
  max-width: 100%;
  padding: 2px 5px;
  border-radius: 4px;
  background: #fff;
  color: var(--rose-dark);
  overflow-wrap: anywhere;
  white-space: normal;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 70px;
  padding: 12px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 248, 245, 0.92);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.05rem, 3vw, 1.4rem);
  overflow-wrap: anywhere;
}

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

.role-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--teal-soft);
  color: #1d5855;
  font-size: 0.85rem;
  font-weight: 800;
}

.main {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 34px) 44px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.86fr) minmax(0, 1.14fr);
  gap: 18px;
  align-items: start;
}

.admin-grid {
  display: grid;
  gap: 18px;
}

.panel,
.form-panel {
  border: 1px solid rgba(36, 48, 51, 0.08);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(36, 48, 51, 0.06);
}

.panel {
  padding: 18px;
}

.form-panel {
  padding: 20px;
}

.form-panel h2 {
  margin-bottom: 16px;
  font-size: 1.18rem;
}

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

.stat-tile {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.stat-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.stat-tile strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.05rem, 2.5vw, 1.35rem);
  line-height: 1.15;
}

.target-panel {
  margin-top: 18px;
}

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

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

.target-card--hot {
  border-color: rgba(216, 155, 61, 0.55);
  background: #fffaf0;
}

.target-card--done {
  border-color: rgba(47, 115, 112, 0.35);
  background: var(--teal-soft);
}

.target-card__top,
.target-card__meta {
  display: flex;
  gap: 10px;
}

.target-card__top {
  align-items: center;
  justify-content: space-between;
}

.target-card__top span {
  color: var(--teal);
  font-size: 0.86rem;
  font-weight: 800;
}

.target-card--hot .target-card__top span {
  color: #9a681c;
}

.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  margin: 12px 0;
  background: #edf1ee;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.target-card--hot .progress-bar span {
  background: var(--sun);
}

.target-card__meta {
  flex-direction: column;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.target-card p {
  margin: 0;
  color: var(--muted);
}

.target-summary {
  white-space: pre-line;
}

.toolbar {
  align-items: end;
  flex-wrap: wrap;
}

.toolbar-fields {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-fields .field {
  min-width: 170px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(76px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.segmented button {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.is-active {
  background: var(--teal);
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
}

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

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

th {
  color: #3c4b4f;
  font-size: 0.82rem;
  text-transform: uppercase;
}

td {
  color: #2d3b3f;
}

.amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.inline-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.form-row {
  gap: 12px;
}

.form-row .field {
  flex: 1;
}

.staff-line {
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.staff-line:last-child {
  border-bottom: 0;
}

.staff-line strong {
  display: block;
}

.staff-line span {
  color: var(--muted);
  font-size: 0.92rem;
}

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

.rule-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.rule-box h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.rule-box ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.empty-state {
  margin: 16px 0 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--bg);
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(36, 48, 51, 0.42);
}

.modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal__header,
.modal__body {
  padding: 18px;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.modal__header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal__body {
  display: grid;
  gap: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 980px) {
  .login-card,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 280px;
  }

  .stat-grid,
  .target-grid,
  .commission-rules {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .login-page {
    padding: 12px;
    place-items: stretch;
  }

  .login-card {
    min-height: calc(100vh - 24px);
  }

  .login-panel,
  .form-panel,
  .panel {
    padding: 16px;
  }

  .login-visual__label {
    right: 12px;
    bottom: 12px;
    width: calc(100% - 24px);
    padding: 14px;
  }

  .login-topline,
  .topbar,
  .section-header,
  .toolbar,
  .form-row {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-block h1 {
    max-width: 15ch;
  }

  .brand-block p {
    max-width: 30ch;
  }

  .topbar__meta,
  .toolbar-fields,
  .inline-actions {
    justify-content: flex-start;
  }

  .language-select,
  .toolbar-fields .field,
  .button {
    width: 100%;
  }

  .form-grid.two,
  .stat-grid,
  .target-grid,
  .commission-rules {
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 12px;
    background: #fff;
  }

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

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

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

@media (max-width: 420px) {
  .brand-block h1 {
    font-size: 1.55rem;
  }

  td {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
