:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1b2430;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #ff6a00;
  --primary-dark: #d95a00;
  --primary-soft: #fff1e6;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --neutral-bg: #e2e8f0;
  font-size: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Arial, sans-serif;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: #0f1729;
  color: #cbd5e1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar-title { color: #fff; font-weight: 700; font-size: 13px; line-height: 1.3; }
.sidebar-sub { color: #94a3b8; font-size: 11px; }

.sidenav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-height: 0;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 11px;
  background: none;
  border: none;
  padding: 10px 12px;
  border-radius: 9px;
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  white-space: normal;
  line-height: 1.3;
}

.side-link:hover { background: #1c2740; color: #fff; }

.side-link.active {
  background: #2563eb;
  color: #fff;
  font-weight: 700;
}

.side-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: currentColor;
}

.side-group { display: flex; flex-direction: column; }

.side-group-toggle {
  display: flex;
  align-items: center;
  gap: 11px;
  background: none;
  border: none;
  padding: 10px 12px;
  border-radius: 9px;
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.side-group-toggle:hover { background: #1c2740; color: #fff; }
.side-group-toggle span { flex: 1; }

.side-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: currentColor;
  transition: transform .15s ease;
}

.side-group.open .side-chevron { transform: rotate(180deg); }
.side-group.has-active .side-group-toggle { color: #fff; font-weight: 700; }

.side-group-items {
  display: none;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 2px 14px;
  padding-left: 10px;
  border-left: 1px solid rgba(255,255,255,.1);
}

.side-group.open .side-group-items { display: flex; }

.side-sublink { font-size: 12.5px; padding: 8px 10px; }
.side-sublink .side-icon { width: 15px; height: 15px; }

.side-bottom {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: 12px;
}

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topheader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 8px 6px 6px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #1e293b;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.user-name { font-size: 12.5px; font-weight: 700; line-height: 1.2; }
.user-role { font-size: 10.5px; color: var(--muted); }

main#view {
  padding: 22px 24px 60px 24px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

.footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 16px;
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  .sidenav { flex-direction: row; flex-wrap: wrap; }
}

h1.page-title {
  font-size: 20px;
  margin: 0 0 4px 0;
}

.page-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 18px 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

select, input[type="text"], input[type="number"], input[type="date"], input[type="search"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}

select:focus, input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.btn:hover { border-color: var(--primary); color: var(--primary-dark); }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-danger { color: var(--bad); border-color: var(--bad-bg); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }

.btn-sm { padding: 5px 9px; font-size: 12.5px; border-radius: 6px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card .name {
  font-weight: 700;
  font-size: 14px;
}

.stat-card .nums {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
}

.stat-card .nums b { color: var(--text); font-size: 15px; }

.bar-track {
  height: 8px;
  border-radius: 4px;
  background: var(--neutral-bg);
  overflow: hidden;
}

.bar-fill { height: 100%; border-radius: 4px; }
.bar-fill.good { background: var(--good); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.bad { background: var(--bad); }
.bar-fill.neutral { background: var(--muted); }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.neutral { background: var(--neutral-bg); color: var(--muted); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13.5px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

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

thead th {
  background: #fafbfd;
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .3px;
  position: sticky;
  top: 0;
}

tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: none; }

td input[type="number"] {
  width: 68px;
  padding: 5px 6px;
  text-align: right;
}

tr.total-row td { font-weight: 700; background: #fafbfd; }

.section {
  margin-bottom: 28px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 10px 0;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 22px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.modal:has(.sheet-products) { max-width: 860px; }

.modal h2 { margin: 0 0 16px 0; font-size: 17px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid .full { grid-column: 1 / -1; }

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

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

.badge-outlet, .badge-agent {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 600;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }

.list-manage {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-manage-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.list-manage-row input { flex: 1; border: none; background: transparent; font-size: 14px; }
.list-manage-row input:focus { outline: none; }

.admin-row-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.admin-row-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }

.import-drop {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }

.progress-mini { font-size: 11px; color: var(--muted); }

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #16213e 0%, #0b0f1a 70%);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 34px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,.35);
}

.login-logo {
  width: 96px;
  height: 96px;
  border-radius: 20px;
  object-fit: cover;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

.login-title { margin: 0 0 6px 0; font-size: 19px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px 0; }

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.login-error {
  background: var(--bad-bg);
  color: var(--bad);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
}

.login-submit { width: 100%; padding: 11px; font-size: 14px; margin-top: 4px; }

.page-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head-row .page-title, .page-head-row .page-sub { margin-bottom: 0; }


.obj-locked {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--neutral-bg);
  font-weight: 600;
  font-size: 13.5px;
}

.obj-weeks-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.obj-week-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.obj-week-field label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.obj-week-field input {
  width: 100%;
  text-align: center;
  padding: 7px 4px;
}

.sheet-context { margin-bottom: 18px; }

.sheet-products {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 4px;
}

.sheet-product {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-product-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sheet-product-name { font-weight: 700; font-size: 13.5px; }

.sheet-product-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sheet-product-fields label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  flex: 1 1 90px;
}

.sheet-product-fields input {
  width: 100%;
  padding: 6px 7px;
  text-align: center;
}

.sheet-comment {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.eval-criteria {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.eval-criterion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}

.eval-criterion select { width: 70px; text-align: center; }

.sheet-comment textarea {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  resize: vertical;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}

.module-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: #eef2ff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-bottom: 4px;
}

.module-icon svg { width: 26px; height: 26px; fill: #2563eb; }

.module-code {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .5px;
}

.module-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }

.module-sep {
  width: 100%;
  border-top: 1px dashed var(--border);
  margin-bottom: 10px;
}

.module-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.module-link {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: center;
}

.module-link:hover { border-color: #2563eb; color: #2563eb; background: #eef2ff; }
