:root {
  --blue: #004c97;
  --blue-2: #063a70;
  --yellow: #ffc800;
  --black: #111318;
  --ink: #202631;
  --muted: #6c7584;
  --line: #dbe1ea;
  --bg: #f4f7fb;
  --white: #ffffff;
  --danger: #b42318;
  --success: #087443;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  max-width: 100%;
}

html,
body {
  width: 100%;
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--ink);
}

img,
canvas,
svg,
video {
  display: block;
  max-width: 100%;
}

button,
.button-link,
input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font: inherit;
}

button,
.button-link {
  align-items: center;
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: var(--white);
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  text-decoration: none;
}

button:hover,
.button-link:hover {
  background: var(--blue-2);
}

button.secondary,
#manual-button,
#logout-button,
#clear-filters,
#clear-dashboard-filters {
  background: var(--white);
  color: var(--blue);
  border: 1px solid var(--line);
}

button.compact {
  min-height: 40px;
}

.hidden {
  display: none !important;
}

.login-shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(0, 76, 151, 0.92), rgba(17, 19, 24, 0.78)),
    var(--blue);
}

.login-panel {
  width: 100%;
  background: var(--white);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
  display: grid;
  gap: 20px;
}

.login-logo {
  width: 220px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--black);
  line-height: 1.15;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 16px;
}

.login-form,
.management-form,
.filters {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--black);
  font-size: 15px;
  font-weight: 700;
}

input,
select,
textarea {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  padding: 12px 14px;
  font-size: 16px;
}

.hidden-field {
  display: none;
}

.invalid-field {
  border-color: var(--danger);
  background: #fff8f6;
}

.form-message {
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
  width: 100%;
}

textarea {
  resize: vertical;
}

.login-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  margin: 0;
}

.login-vendor-name {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #edf3fa;
  color: var(--blue-2);
  display: grid;
  align-items: center;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
}

.login-vendor-name.error {
  background: #fff4f2;
  color: var(--danger);
}

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

.sidebar {
  width: 100%;
  background: var(--black);
  color: var(--white);
  padding: 16px;
  display: grid;
  gap: 16px;
}

.brand {
  display: grid;
  gap: 10px;
  font-weight: 800;
}

.brand img {
  width: 170px;
  background: var(--white);
  border-radius: 6px;
  padding: 8px;
}

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

.nav-tab {
  text-align: left;
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.nav-tab.active {
  background: var(--yellow);
  color: var(--black);
}

.user-card {
  display: grid;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.user-card small {
  color: #c8d0db;
}

.workspace {
  width: 100%;
  min-width: 0;
  padding: 16px;
}

.topbar {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar-actions,
.form-actions {
  display: grid;
  gap: 10px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.management-form,
.filters,
.admin-toolbar,
.chart-panel,
.table-wrap {
  width: 100%;
  min-width: 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.form-grid,
.filters,
.admin-toolbar,
.kpi-grid,
.dashboard-grid,
.heatmap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(17, 19, 24, 0.72);
}

.modal-panel {
  width: min(440px, 100%);
  background: var(--white);
  border-radius: 8px;
  padding: 24px;
  display: grid;
  gap: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
}

.admin-toolbar {
  margin-bottom: 16px;
}

.user-form,
#user-kpi-grid {
  margin-bottom: 16px;
}

.admin-table select {
  min-width: 150px;
}

.file-field {
  align-content: start;
}

.filters {
  align-items: end;
  margin-bottom: 16px;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0;
  -webkit-overflow-scrolling: touch;
}

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

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

th {
  background: #edf3fa;
  color: var(--blue-2);
  font-size: 12px;
  text-transform: uppercase;
}

td[contenteditable="true"] {
  background: #fffdf0;
  outline-color: var(--yellow);
}

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

.row-actions button {
  width: auto;
  min-height: 38px;
  padding: 0 12px;
}

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

.edit-button {
  background: var(--yellow);
  color: var(--black);
}

.kpi-grid {
  margin-bottom: 16px;
}

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

.quote-total {
  background: #edf3fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 16px;
}

.quote-total span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.quote-total strong {
  color: var(--blue-2);
  font-size: 28px;
}

.quote-history {
  margin-top: 16px;
}

.kpi strong {
  display: block;
  color: var(--black);
  font-size: 26px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

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

.chart-panel {
  min-height: 300px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.chart-panel canvas {
  width: 100%;
  height: 240px;
}

.heat-cell {
  border-radius: 8px;
  color: var(--black);
  min-height: 84px;
  padding: 12px;
  display: grid;
  align-content: space-between;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.heat-cell strong {
  font-size: 16px;
}

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

@media (min-width: 480px) {
  .login-panel {
    width: min(440px, 100%);
    padding: 28px;
  }
}

@media (min-width: 768px) {
  button {
    width: auto;
    min-height: 42px;
  }

  label {
    font-size: 13px;
  }

  input,
  select,
  textarea {
    min-height: 42px;
    font-size: 14px;
    padding: 10px 12px;
  }

  .login-vendor-name {
    min-height: 42px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
  }

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

  .workspace {
    padding: 24px;
  }

  .topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .topbar-actions,
  .form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .form-grid,
  .filters,
  .admin-toolbar,
  .kpi-grid,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-2,
  .wide {
    grid-column: span 2;
  }

  .heatmap {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }
}

@media (min-width: 1080px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .sidebar {
    min-height: 100vh;
    align-content: space-between;
    padding: 20px;
  }

  .brand img {
    width: 190px;
  }

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

  .form-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }

  .filters {
    grid-template-columns: repeat(6, minmax(130px, 1fr)) auto;
    gap: 14px;
  }

  .admin-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: end;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
}
