:root {
  --ink: #172033;
  --muted: #667085;
  --line: #d9e2ef;
  --bg: #eef3f8;
  --panel: #ffffff;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #2451d1;
  --warn: #b54708;
  --danger: #b42318;
  --ok: #138a54;
  --shadow: 0 16px 42px rgba(23, 32, 51, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, .08), transparent 32%),
    linear-gradient(315deg, rgba(36, 81, 209, .08), transparent 28%),
    var(--bg);
  color: var(--ink);
}
button, input, select { font: inherit; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .72; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-panel {
  width: min(430px, 100%);
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(217, 226, 239, .9);
  border-radius: 12px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.brand-mark {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  border-radius: 10px;
}
.login-panel h1 { margin: 16px 0 4px; font-size: 1.45rem; }
.login-panel p { margin: 0 0 18px; color: var(--muted); }
.login-panel label { display: grid; gap: 6px; margin-bottom: 12px; font-weight: 700; font-size: .9rem; }
.login-panel input,
td input,
td select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}
.login-panel input:focus,
td input:focus,
td select:focus {
  outline: 3px solid rgba(15, 118, 110, .14);
  border-color: rgba(15, 118, 110, .62);
}
.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  font-weight: 600;
}
.check-row input { width: auto; }

.login-panel button,
.primary-btn,
.ghost-btn,
.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}
.login-panel button,
.primary-btn {
  color: #fff;
  background: var(--primary);
}
.login-panel button:hover,
.primary-btn:hover { background: var(--primary-dark); }
.login-panel button { width: 100%; margin-top: 4px; }
.link-btn {
  color: var(--primary-dark);
  background: #e7f6f3;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #101828;
  color: #fff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.sidebar-brand span {
  display: block;
  color: rgba(255, 255, 255, .62);
  font-size: .82rem;
}
.sidebar-nav { display: grid; gap: 6px; }
.sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 11px;
  color: rgba(255, 255, 255, .72);
  background: transparent;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}
.sidebar-nav button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar-nav button.active {
  color: #fff;
  background: rgba(255, 255, 255, .14);
  box-shadow: inset 3px 0 0 #5eead4;
}
.ghost-btn {
  margin-top: auto;
  color: #fff;
  background: rgba(255, 255, 255, .1);
}
.ghost-btn:hover { background: rgba(255, 255, 255, .16); }

.workspace {
  width: min(1360px, 100%);
  padding: 24px;
  min-width: 0;
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}
.topbar p {
  margin: 0 0 4px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: .76rem;
  font-weight: 900;
}
.topbar h1 { margin: 0; font-size: clamp(1.35rem, 2vw, 1.9rem); }
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .86);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 700;
}
.user-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 170px;
  margin-bottom: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, .1), rgba(36, 81, 209, .08)),
    #fff;
  box-shadow: var(--shadow);
}
.overview-hero h2 {
  margin: 6px 0 8px;
  font-size: clamp(1.6rem, 3vw, 2.45rem);
}
.overview-hero p {
  max-width: 700px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}
.eyebrow {
  color: var(--primary-dark);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}
.status-orb {
  display: grid;
  place-items: center;
  flex: 0 0 84px;
  width: 84px;
  height: 84px;
  border-radius: 16px;
  color: var(--ok);
  background: #e8f8f0;
  font-size: 2.3rem;
}
.status-orb--warn {
  color: var(--warn);
  background: #fff4e5;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.summary-grid div,
.panel {
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(217, 226, 239, .92);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.summary-grid div { padding: 16px; }
.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}
.summary-grid strong { display: block; margin-top: 4px; font-size: 1.45rem; }

.overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.panel {
  padding: 16px;
  min-width: 0;
  overflow: hidden;
}
.panel--single { max-width: 1180px; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.panel h2 { margin: 0 0 4px; font-size: 1.08rem; }
.panel p { margin: 0; color: var(--muted); font-size: .9rem; }

.compact-list,
.list {
  display: grid;
  gap: 8px;
}
.compact-row,
.list-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}
.compact-row small,
.list-row small,
td small {
  display: block;
  color: var(--muted);
  font-size: .78rem;
}
.compact-row em,
.list-row em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
  font-size: .8rem;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, .1);
}
.status-dot--on {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(19, 138, 84, .12);
}
.status-dot--off {
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(181, 71, 8, .12);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-color: #9aa7bd transparent;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: .75rem;
  text-transform: uppercase;
}
tr:last-child td { border-bottom: 0; }

.contract-list { display: grid; gap: 8px; }
details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-width: 0;
  overflow: hidden;
  background: #fff;
}
summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-weight: 800;
}
summary span {
  flex: 0 0 auto;
  color: var(--muted);
}
details ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: .86rem;
  overflow-wrap: anywhere;
}
details li {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.feedback {
  border: 1px solid #fedf89;
  background: #fffbeb;
  color: #93370d;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-weight: 700;
}
.feedback--error {
  border-color: #fecdca;
  background: #fff7f7;
  color: var(--danger);
}
.d-none { display: none; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 14px 34px rgba(23, 32, 51, .2);
  font-weight: 800;
}
.toast--error { background: var(--danger); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .sidebar-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ghost-btn { margin-top: 0; }
  .summary-grid,
  .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .workspace { padding: 14px; }
  .topbar,
  .topbar-actions,
  .overview-hero {
    align-items: flex-start;
    flex-direction: column;
  }
  .topbar-actions { width: 100%; }
  .topbar-actions .primary-btn,
  .user-pill { width: 100%; max-width: none; }
  .summary-grid,
  .overview-grid,
  .sidebar-nav { grid-template-columns: 1fr; }
  .status-orb {
    width: 64px;
    height: 64px;
    flex-basis: 64px;
    font-size: 1.8rem;
  }
}
