:root {
  color-scheme: light;
  --ink: #10212b;
  --muted: #667784;
  --line: #d9e4ea;
  --soft: #f3f7f9;
  --navy: #0f3d4c;
  --teal: #13737a;
  --green: #00b050;
  --green-dark: #2f8f59;
  --red: #d4232d;
  --amber: #f4b340;
  --white: #ffffff;
  --shadow: 0 16px 40px rgba(15, 61, 76, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #edf3f6;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

body.locked {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  overflow-x: hidden;
}

.login-cover {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(15, 61, 76, 0.68), rgba(19, 115, 122, 0.42)),
    linear-gradient(rgba(15, 61, 76, 0.34), rgba(15, 61, 76, 0.62)),
    url("./assets/concrete-wall-bg.png") center / cover no-repeat,
    #0f3d4c;
}

.login-cover.hidden {
  display: none;
}

.login-panel {
  width: min(920px, 100%);
  background: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.78fr);
}

.login-copy {
  display: grid;
  align-content: center;
  min-height: 520px;
  padding: 34px;
  background:
    linear-gradient(145deg, rgba(15, 61, 76, 0.94), rgba(19, 115, 122, 0.86)),
    var(--navy);
  color: var(--white);
}

.login-copy h2 {
  max-width: 390px;
  font-size: 36px;
  line-height: 1.05;
}

.login-copy > p {
  max-width: 420px;
  margin-top: 14px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.5;
}

.login-benefits {
  display: grid;
  gap: 8px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.login-benefits li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 700;
}

.login-benefits li::before {
  content: "";
  width: 9px;
  height: 9px;
  background: var(--green);
}
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand-mark.large {
  width: 58px;
  height: 58px;
  background: var(--navy);
  color: var(--white);
  border: 0;
  font-size: 20px;
}

.logo.large {
  display: block;
  width: 58px;
  height: 58px;
}

.login-brand h1 {
  font-size: 24px;
}

.login-brand p {
  color: inherit;
  opacity: 0.72;
  margin-top: 4px;
}

.login-form {
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 34px;
}

.login-form > div {
  display: grid;
  gap: 4px;
  margin-bottom: 4px;
}

.login-form > div strong {
  font-size: 22px;
}

.login-form > div span {
  color: var(--muted);
  line-height: 1.35;
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-weight: 700;
}

.access-request {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--green-dark);
  font-weight: 800;
  text-decoration: none;
}

.sidebar {
  background: var(--navy);
  color: var(--white);
  padding: 20px 16px;
  min-width: 0;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
}

.logo {
  display: block;
  width: 44px;
  height: 44px;
}

.brand strong,
.brand small {
  display: block;
  overflow-wrap: anywhere;
}

.brand small {
  color: rgba(255, 255, 255, 0.72);
  margin-top: 3px;
}

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

.nav-tab {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  text-align: left;
  padding: 12px 14px;
}

.nav-tab.active,
.nav-tab:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
}

.workspace {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 16px;
}

.topbar p,
.panel-header span,
.thermometer-head span {
  color: var(--muted);
  margin-top: 4px;
}

.top-actions {
  display: flex;
  flex: 1 1 560px;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
  max-width: 100%;
}

.date-filter {
  align-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  display: inline-flex;
  gap: 7px;
  min-height: 40px;
  padding: 0 10px;
}

.date-filter span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.date-filter input {
  border: 0;
  width: 145px;
  min-height: 38px;
  padding: 0;
}

.period-bar {
  align-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  max-width: 100%;
}

.period-bar strong {
  color: var(--ink);
  flex: 0 0 auto;
  margin-right: 4px;
}

.period-bar .primary,
.period-bar .ghost {
  flex: 0 0 auto;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  padding: 10px 11px;
  min-height: 40px;
}

textarea {
  resize: vertical;
}

.primary,
.ghost,
.icon-button {
  border: 1px solid transparent;
  min-height: 40px;
  padding: 10px 14px;
  font-weight: 700;
}

.primary {
  background: var(--green-dark);
  color: var(--white);
}

.ghost,
.icon-button {
  background: var(--white);
  border-color: var(--line);
  color: var(--ink);
}

.compact {
  padding-left: 10px;
  padding-right: 10px;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 24px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi,
.panel,
.thermometer-panel {
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 96px;
  display: grid;
  align-content: center;
  text-align: center;
  border-top: 8px solid var(--teal);
}

.kpi-action {
  border-right-color: var(--line);
  border-bottom-color: var(--line);
  border-left-color: var(--line);
  color: var(--ink);
}

.kpi-action:hover,
.kpi-action:focus-visible {
  transform: translateY(-1px);
  outline: 2px solid rgba(47, 143, 89, 0.24);
  outline-offset: 2px;
}

.kpi.warning {
  border-top-color: var(--amber);
}

.kpi.success {
  border-top-color: var(--green-dark);
}

.kpi.danger {
  border-top-color: var(--red);
}

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

.kpi strong {
  font-size: 22px;
  margin-top: 7px;
}

.thermometer-panel {
  padding: 16px;
  margin-bottom: 14px;
}

.thermometer-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.thermometer-head strong {
  font-size: 24px;
}

.thermometer {
  position: relative;
  height: 28px;
  background: var(--red);
  overflow: hidden;
  border: 1px solid #b61c25;
}

.thermo-fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  transition: width 180ms ease;
}

.thermo-over {
  position: absolute;
  inset: 0;
  display: none;
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.22) 8px, transparent 8px, transparent 16px);
}

.thermometer.over .thermo-over {
  display: block;
}

.scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 0.8fr);
  gap: 14px;
}

.panel {
  padding: 14px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

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

.hidden {
  display: none !important;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
}

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

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

th {
  background: var(--navy);
  color: var(--white);
  font-size: 12px;
  text-transform: uppercase;
}

td:first-child,
th:first-child,
td:nth-child(2),
th:nth-child(2) {
  text-align: left;
}

.status-pill {
  display: inline-flex;
  min-width: 78px;
  justify-content: center;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.open {
  color: var(--red);
  background: #fde3e5;
}

.status-pill.closed {
  color: var(--green-dark);
  background: #daf4e3;
}

.status-pill.lost {
  color: #9a5b00;
  background: #fff1cc;
}

.danger-text {
  color: var(--red);
  font-weight: 700;
}

.success-text {
  color: var(--green-dark);
  font-weight: 700;
}

.status-chart {
  display: grid;
  place-items: center;
  gap: 18px;
  min-height: 260px;
}

.donut {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: conic-gradient(var(--green-dark) 0deg, var(--green-dark) 0deg, var(--red) 0deg);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 42px;
  background: var(--white);
  border-radius: 50%;
}

.legend {
  display: flex;
  gap: 16px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
}

.dot.open {
  background: var(--red);
}

.dot.closed {
  background: var(--green-dark);
}

.dot.lost {
  background: var(--amber);
}

.industry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
}

.industry-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.industry-form label {
  display: grid;
  gap: 6px;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.user-form label {
  display: grid;
  gap: 6px;
}

.form-message {
  min-height: 22px;
  margin-top: 10px;
  color: var(--green-dark);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  color: #166534;
  background: #dcfce7;
}

.badge.neutral {
  color: var(--ink);
  background: #eaf2f5;
}

.badge.blocked {
  color: #991b1b;
  background: #fee2e2;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.empty-row {
  padding: 18px !important;
  color: var(--muted);
  text-align: center !important;
}

.industry-card {
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 12px;
}

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

.industry-card label {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  background: var(--soft);
  color: var(--muted);
  padding: 18px;
}

dialog {
  width: min(720px, calc(100% - 24px));
  border: 0;
  padding: 0;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

dialog::backdrop {
  background: rgba(15, 33, 43, 0.38);
}

#recordForm {
  padding: 18px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dialog-actions {
  margin-top: 16px;
}

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

label:not(.date-filter) {
  display: grid;
  gap: 6px;
  font-weight: 700;
  color: var(--ink);
}

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

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
  }

  .brand {
    margin: 0;
  }

  .nav-tabs {
    display: flex;
    overflow-x: auto;
  }

  .nav-tab {
    white-space: nowrap;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 14px;
  }

  .topbar,
  .thermometer-head,
  .period-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .panel-actions,
  .top-actions select,
  .date-filter,
  .date-filter input,
  .top-actions button {
    width: 100%;
  }

  .kpi-grid,
  .industry-grid,
  .industry-form,
  .user-form,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  h1 {
    font-size: 22px;
  }

  .login-panel {
    width: min(520px, 100%);
  }

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

  .login-copy {
    min-height: auto;
    padding: 24px;
  }

  .login-copy h2 {
    font-size: 28px;
  }

  .login-form {
    padding: 24px;
  }

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

  .sidebar {
    align-items: stretch;
    flex-direction: column;
  }
}
