:root {
  --brand: #2b6fd6;
  --brand-dark: #1f3c88;
  --text: #1c2434;
  --muted: #6b7486;
  --border: #dde2ea;
  --bg: #f3f6fb;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

form {
  margin: 0;
}

/* the hidden attribute must win over display rules (used by the form to switch sections) */
[hidden] {
  display: none !important;
}

/* Language switcher */
.language-switcher {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.language-switcher button {
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}
.language-switcher button.active {
  color: #fff;
  background: var(--brand);
}

/* Login page */
.login-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 15% 20%, rgba(74, 163, 232, 0.25), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(43, 58, 143, 0.22), transparent 45%),
    var(--bg);
}
.login-page .lang {
  position: absolute;
  top: 16px;
  right: 16px;
}
.login-wrap {
  width: 100%;
  max-width: 400px;
}
.card {
  padding: 40px 36px 32px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px rgba(16, 24, 40, 0.08);
}
.logo {
  display: block;
  height: 32px;
  max-width: 100%;
  margin: 0 auto 28px;
  object-fit: contain;
}
.title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  letter-spacing: -0.01em;
}
.subtitle {
  margin: 6px 0 24px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}
.alert {
  margin-bottom: 18px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.45;
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 10px;
}
.field {
  display: block;
  margin-bottom: 16px;
}
.label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
}
.field input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input::placeholder {
  color: #a3abb9;
}
.field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(43, 111, 214, 0.15);
}
.password {
  position: relative;
  display: block;
}
.password input {
  padding-right: 80px;
}
.toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--brand);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.toggle:hover {
  background: rgba(43, 111, 214, 0.08);
}
.submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 46px;
  margin-top: 8px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(43, 111, 214, 0.25);
  transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
}
.submit:hover {
  box-shadow: 0 8px 20px rgba(43, 111, 214, 0.35);
}
.submit:active {
  transform: translateY(1px);
}
.submit:disabled {
  opacity: 0.7;
  cursor: default;
}
.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.submit.loading .spinner {
  display: inline-block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.powered {
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
@media (max-width: 480px) {
  .card {
    padding: 32px 22px 24px;
  }
}

/* Logged-in pages: top bar (logo | partner, language, logout) and the page links under it */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: #fff;
}
.topbar .brand {
  flex-shrink: 0;
  text-decoration: none;
}
.topbar .brand img {
  display: block;
  height: 28px;
  width: auto;
}
.topbar .spacer {
  flex: 1;
}
.topbar .user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
  font-size: 14px;
  line-height: 1.3;
  color: var(--text);
  text-align: right;
}
.topbar .user strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .user-name {
  font-size: 12px;
  color: var(--muted);
}
.topbar .logout {
  flex-shrink: 0;
  padding: 6px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.topbar .logout:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.subnav {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  overflow-x: auto;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.subnav a {
  padding: 10px 12px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.subnav a:hover {
  color: var(--brand);
}
.subnav a.active {
  color: var(--brand);
  font-weight: 600;
  border-bottom-color: var(--brand);
}
.content {
  padding: 24px;
}
@media (max-width: 560px) {
  .topbar {
    gap: 8px;
    padding: 10px 16px;
  }
  .topbar .brand img {
    height: 18px;
  }
  .topbar .language-switcher button {
    padding: 3px 7px;
  }
  /* partner on its own line under logo, language and logout */
  .topbar {
    flex-wrap: wrap;
    row-gap: 6px;
  }
  .topbar .user {
    order: 10;
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    width: 100%;
    font-size: 13px;
    text-align: left;
  }
  .topbar .user-name::before {
    content: '· ';
  }
  .topbar .logout {
    padding: 5px 8px;
    font-size: 13px;
  }
  .subnav {
    padding: 0 8px;
  }
  .content {
    padding: 16px;
  }
}

/* Messages */
.notice {
  margin-bottom: 18px;
  padding: 12px 16px;
  font-size: 14px;
  color: #05603a;
  background: #ecfdf3;
  border: 1px solid #abefc6;
  border-radius: 10px;
}
.content > .alert,
.page > .alert {
  margin-bottom: 18px;
}

/* Buttons */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 20px;
  line-height: 1.2;
  text-align: center;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 10px;
  cursor: pointer;
}
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border: none;
  box-shadow: 0 6px 16px rgba(43, 111, 214, 0.25);
}
.btn-primary:disabled {
  opacity: 0.7;
  cursor: default;
}
.btn-primary.loading .spinner {
  display: inline-block;
}
.btn-secondary {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--brand);
  color: var(--brand);
}

/* Form page */
.page {
  max-width: 880px;
  margin: 0 auto;
}
.page-header h1 {
  margin: 8px 0 4px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.page-header p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}
.form-section {
  margin-bottom: 20px;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.form-section h2 {
  margin: 0 0 18px;
  font-size: 16px;
  font-weight: 600;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 20px;
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.form .field input,
.form .field select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form .field select:disabled {
  color: #a3abb9;
  background: #f7f8fa;
}
.form .field input:focus,
.form .field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(43, 111, 214, 0.15);
}
.form .has-error input,
.form .has-error select,
.form input.invalid {
  border-color: #f04438;
}
.field-error {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #b42318;
}
.hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.optional {
  font-weight: 400;
  color: var(--muted);
}
.numbers {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}
.form .numbers input {
  padding: 0 8px;
  text-align: center;
}
.segmented {
  display: inline-flex;
  margin-bottom: 16px;
  padding: 4px;
  gap: 4px;
  background: #f3f6fb;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.segmented label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
}
.segmented label:has(input:checked) {
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
  font-weight: 600;
}
.choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.choices .field-error {
  grid-column: 1 / -1;
}
.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-size: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.choice:has(input:checked) {
  border-color: var(--brand);
  background: rgba(43, 111, 214, 0.06);
}
.choices.has-error .choice {
  border-color: #fecdca;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin: 8px 0 32px;
}
.btn-inline {
  margin-top: 4px;
}

@media (max-width: 720px) {
  .grid,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .numbers {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .form-section {
    padding: 18px 16px;
  }
  .form-actions {
    flex-direction: column-reverse;
  }
}

/* List page */
.page-wide {
  max-width: 1240px;
}
.page-header-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.filters {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)) auto;
  gap: 0 14px;
  align-items: end;
  margin-bottom: 16px;
  padding: 18px 20px 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.filter-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.list-total {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.empty p {
  margin: 0 0 16px;
}
.table-card {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.list-table th {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.list-table td {
  padding: 14px 16px;
  vertical-align: top;
  border-bottom: 1px solid #eef1f5;
}
.list-table tbody tr:last-child td {
  border-bottom: none;
}
.list-table tbody tr:hover td {
  background: #fafbfd;
}
.list-table .sub {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: nowrap;
}
.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  border-radius: 999px;
}
.badge-pending { color: #475467; background: #f2f4f7; }
.badge-feasible { color: #067647; background: #dcfae6; }
.badge-partial { color: #b54708; background: #fef0c7; }
.badge-not_feasible { color: #b42318; background: #fee4e2; }
.badge-connected { color: #175cd3; background: #d1e9ff; }
.badge-cancelled { color: #667085; background: #f2f4f7; text-decoration: line-through; }
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 20px 0 32px;
  font-size: 14px;
  color: var(--muted);
}

@media (max-width: 960px) {
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-search,
  .filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .page-header-actions {
    flex-direction: column;
  }
  .filters {
    grid-template-columns: 1fr;
  }
  /* table rows become cards */
  .table-card {
    background: none;
    border: none;
  }
  .list-table thead {
    display: none;
  }
  .list-table,
  .list-table tbody,
  .list-table tr,
  .list-table td {
    display: block;
    width: 100%;
  }
  .list-table tr {
    margin-bottom: 12px;
    padding: 6px 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
  }
  .list-table td {
    padding: 8px 16px;
    border-bottom: none;
  }
  .list-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
  }
  .list-table tbody tr:hover td {
    background: none;
  }
}

/* Required fields */
.req {
  margin-left: 2px;
  font-weight: 600;
  color: #d92d20;
}
.form-legend {
  margin: -8px 0 16px;
  font-size: 12px;
  color: var(--muted);
}

/* Searchable select (public/js/select-search.js) */
.ss {
  position: relative;
}
.ss-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}
.form .field .ss-input {
  padding-right: 36px;
  cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%236b7486' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.form .field .ss-input::placeholder {
  color: #a3abb9;
}
.ss-open .ss-input {
  cursor: text;
}
.form .field .ss-input:disabled {
  cursor: default;
  color: #a3abb9;
  background-color: #f7f8fa;
}
.form .has-error .ss-input {
  border-color: #f04438;
}
.ss-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.12);
}
.ss-option {
  padding: 8px 10px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
}
.ss-option.ss-active {
  background: rgba(43, 111, 214, 0.1);
}
.ss-option.ss-selected {
  font-weight: 600;
  color: var(--brand);
}
.ss-empty {
  padding: 8px 10px;
  font-size: 14px;
  color: var(--muted);
}

/* List header buttons */
.header-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.btn-secondary .icon {
  flex-shrink: 0;
}
.refreshing .icon {
  animation: spin 0.8s linear infinite;
}
@media (max-width: 720px) {
  .header-actions {
    width: 100%;
    margin-bottom: 16px;
  }
  .page-header-actions p {
    margin-bottom: 12px;
  }
  .header-actions .btn-primary {
    flex: 1;
  }
}

/* Customers list: search only */
.filters-simple {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
}
.list-table .badge + .badge {
  margin-left: 4px;
}
.list-table td .badge {
  margin-bottom: 4px;
}
@media (max-width: 720px) {
  .filters-simple {
    grid-template-columns: 1fr;
  }
}
