:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #66736d;
  --line: #dce3df;
  --accent: #196b5b;
  --accent-2: #2f6fbb;
  --warn: #b85c18;
  --danger: #b3261e;
  --ok: #247247;
  --soft: #edf5f2;
  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: var(--bg);
  color: var(--ink);
}

.hidden {
  display: none !important;
}

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

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

.danger-button {
  background: #b42318;
  color: #fff;
}

.danger-button:hover {
  background: #912018;
}

.ghost-button {
  background: #e7ece9;
  color: var(--ink);
}

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

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(180deg, #f6f8f7 0%, #eaf1ee 100%);
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 70px rgba(23, 33, 29, 0.12);
}

.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.demo-access {
  display: grid;
  gap: 4px;
  margin-top: 4px;
  padding: 12px;
  border-radius: 8px;
  background: #f6f8f7;
  color: var(--muted);
  font-size: 13px;
}

.demo-access strong {
  color: var(--ink);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  background: #f9fbfa;
  border-right: 1px solid var(--line);
}

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

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

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: contain;
  background: #12142a;
}

.brand span,
.field-label,
.topbar p,
.muted {
  color: var(--muted);
}

.brand strong,
.brand span {
  display: block;
}

.field-label {
  margin-bottom: -8px;
  font-size: 13px;
  font-weight: 700;
}

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

textarea {
  resize: vertical;
}

.nav-tabs {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.nav-tabs button {
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: var(--ink);
}

.nav-tabs button.active {
  background: var(--soft);
  color: var(--accent);
  font-weight: 800;
}

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

.user-box {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.user-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.sales-plan-summary {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-2);
  border-radius: 8px;
  background: var(--panel);
}

.sales-plan-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.sales-plan-heading strong,
.sales-plan-empty strong {
  display: block;
  margin-top: 5px;
  font-size: 26px;
}

.sales-plan-label,
.sales-plan-metrics span,
.plan-current-amount span,
.plan-current-amount small {
  color: var(--muted);
  font-size: 13px;
}

.sales-plan-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.sales-plan-metrics div {
  display: grid;
  gap: 5px;
}

.sales-plan-metrics strong {
  font-size: 17px;
}

.sales-plan-progress,
.table-progress {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #e9eef6;
}

.sales-plan-progress span,
.table-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-2);
}

.table-progress {
  width: 120px;
  height: 7px;
  margin-bottom: 5px;
}

.plan-current-amount {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9f8;
}

.plan-current-amount strong {
  font-size: 20px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.kpi span {
  color: var(--muted);
  font-size: 13px;
}

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 16px;
}

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

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

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

.toolbar {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.toolbar input,
.toolbar select {
  max-width: 260px;
}

.calendar-block {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.calendar-header {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.calendar-header h3 {
  text-align: center;
  font-size: 18px;
  text-transform: capitalize;
}

.icon-button {
  display: grid;
  place-items: center;
  min-height: 38px;
  width: 42px;
  padding: 0;
  background: #e7ece9;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  gap: 6px;
}

.calendar-weekdays {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.calendar-cell {
  display: grid;
  align-content: space-between;
  justify-items: start;
  min-height: 72px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  text-align: left;
}

.calendar-cell:hover {
  border-color: var(--accent);
  filter: none;
}

.calendar-cell.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.calendar-cell span {
  font-weight: 800;
}

.calendar-cell strong {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 13px;
}

.muted-cell {
  background: #f4f6f5;
  border-style: dashed;
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fbfcfb;
}

tr:hover td {
  background: #fbfcfb;
}

.compact-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
}

.list-item strong {
  display: block;
  margin-bottom: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #e9eef6;
  color: #244b80;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.ok {
  background: #e4f3e9;
  color: var(--ok);
}

.pill.warn {
  background: #fff1df;
  color: var(--warn);
}

.pill.danger {
  background: #fdeceb;
  color: var(--danger);
}

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

.row-actions button {
  min-height: 30px;
  padding: 0 10px;
  background: #e7ece9;
  color: var(--ink);
}

.inline-select {
  display: grid;
  gap: 4px;
  max-width: 190px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.client-folders {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.client-folders button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.client-folders button[aria-selected="true"] {
  background: var(--soft);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.folder-count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.clients-table {
  min-width: 1080px;
}

.clients-table td {
  overflow-wrap: break-word;
}

.clients-table td:first-child,
.clients-table td:nth-child(3),
.clients-table td:nth-child(5) {
  min-width: 160px;
}

.clients-table td:nth-child(2) {
  min-width: 100px;
}

.client-actions {
  width: 210px;
  min-width: 210px;
  align-items: center;
}

.client-actions .client-archive-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  flex: 0 0 32px;
  background: #fdeceb;
}

.client-archive-button:hover {
  background: #f9d9d6;
}

.client-archive-date {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

#clientArchiveDialog {
  width: min(460px, calc(100vw - 24px));
}

#clientArchiveDialog p,
#clientArchiveName {
  overflow-wrap: anywhere;
  line-height: 1.5;
}

#clientArchiveDialog button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.client-folders button:focus-visible,
.client-actions button:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
}

@media (max-width: 700px) {
  .clients-table,
  .clients-table tbody,
  .clients-table tr,
  .clients-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .clients-table thead {
    display: none;
  }

  .clients-table tr {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
  }

  .clients-table td {
    padding: 6px 0;
    border: 0;
    overflow-wrap: anywhere;
  }

  .clients-table td:first-child,
  .clients-table td:nth-child(2),
  .clients-table td:nth-child(3),
  .clients-table td:nth-child(5) {
    min-width: 0;
  }

  .clients-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    font-size: 12px;
    color: var(--muted);
  }

  .client-actions {
    width: auto;
    min-width: 0;
  }

  .client-actions button {
    min-height: 38px;
  }
}

.inline-select select {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 13px;
}

.form-section {
  display: grid;
  gap: 12px;
}

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

.section-title h3 {
  font-size: 18px;
}

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

.product-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(140px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.product-row button {
  min-width: 94px;
}

.standards-list {
  display: grid;
  gap: 18px;
  padding: 16px;
}

.standard-topic {
  display: grid;
  gap: 10px;
}

.standard-topic h3 {
  color: var(--accent);
  font-size: 18px;
}

.standard-article {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.standard-article p {
  margin-top: 6px;
  color: var(--muted);
  white-space: pre-wrap;
}

dialog {
  width: min(680px, calc(100vw - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(16, 24, 20, 0.24);
}

dialog::backdrop {
  background: rgba(12, 20, 16, 0.38);
}

.dialog-form {
  display: grid;
  gap: 13px;
  padding: 22px;
}

.history-dialog {
  width: min(1180px, 92vw);
}

.import-preview {
  min-height: 72px;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--soft);
  border-radius: 6px;
  line-height: 1.5;
}

.activity-panel {
  max-width: 1100px;
}

.activity-days {
  padding: 8px 24px 28px;
}

.activity-day + .activity-day {
  margin-top: 28px;
}

.activity-day h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.activity-list {
  border-top: 1px solid var(--border);
}

.activity-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 220px;
  gap: 18px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.activity-row time,
.activity-user small {
  color: var(--muted);
}

.activity-row p {
  margin: 4px 0 0;
  color: var(--muted);
}

.activity-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

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

.promotion-admin-list {
  padding: 0 24px 28px;
}

.promotion-admin-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.promotion-admin-item h3 {
  margin: 10px 0 4px;
}

.promotion-admin-item p {
  margin: 5px 0 0;
}

@media (max-width: 760px) {
  .activity-row {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .activity-user {
    grid-column: 2;
    align-items: flex-start;
    text-align: left;
  }

  .promotion-admin-item {
    grid-template-columns: 1fr;
  }
}

.dialog-form h2 {
  margin-bottom: 4px;
}

.dialog-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.check-row {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--ink) !important;
}

.check-row input {
  width: auto;
  min-height: 0;
}

.form-hint {
  color: var(--danger);
  min-height: 20px;
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.empty {
  padding: 24px;
  color: var(--muted);
}

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

  .sidebar {
    position: static;
  }

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

  .kpi-grid,
  .layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  main,
  .sidebar {
    padding: 16px;
  }

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

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

  .two-cols {
    grid-template-columns: 1fr;
  }

  .product-row,
  .standard-article {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
  }

  .sales-plan-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .sales-plan-metrics {
    grid-template-columns: 1fr;
  }
}
