:root {
  --bg: #ffffff;
  --bg-muted: #f7f8fa;
  --border: #e4e7ec;
  --border-strong: #d5d9e0;
  --text: #16191f;
  --text-muted: #667085;
  --text-soft: #8a92a3;
  --accent: #1a56db;
  --accent-soft: #eaf0fd;
  --sidebar-w: 216px;
  --topbar-h: 56px;
  --radius: 8px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica,
    Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.muted {
  color: var(--text-muted);
}

.right {
  text-align: right;
}

.icon {
  display: block;
  flex: none;
}

/* ---------- layout ---------- */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--bg-muted);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex: none;
}

.sidebar-brand img {
  height: 22px;
  width: auto;
}

.sidebar-nav {
  padding: 10px 0 24px;
}

.nav-group {
  list-style: none;
  margin: 0;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.nav-group:last-child {
  border-bottom: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  color: #3d434f;
  font-size: 13.5px;
  position: relative;
}

.nav-item:hover {
  background: #eceef2;
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav-icon {
  color: #6b7280;
  display: flex;
}

.nav-item.is-active .nav-icon {
  color: var(--accent);
}

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

/* ---------- topbar ---------- */
.topbar {
  height: var(--topbar-h);
  flex: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.env-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.env-clear,
.env-caret {
  color: var(--text-soft);
  display: flex;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-outline {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg-muted);
}

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

.btn-primary:hover {
  background: #1546b8;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-ghost:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.btn-block {
  width: 100%;
  height: 38px;
  font-size: 14px;
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-muted);
}

.badge {
  position: absolute;
  top: 0;
  right: -2px;
  background: #f2c744;
  color: #3d3000;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 3px;
  border-radius: 4px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 6px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #16191f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
}

.user-role {
  font-size: 11px;
  color: var(--text-soft);
  text-transform: capitalize;
}

.logout-form {
  margin: 0;
}

/* ---------- content ---------- */
.content {
  padding: 22px 26px 40px;
  max-width: 1360px;
  width: 100%;
}

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

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-card);
  padding: 14px 16px 10px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.card-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #3d434f;
}

.hint {
  color: var(--accent);
  display: flex;
}

.chart-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 20px;
}

.chart-wrap {
  margin-bottom: 2px;
}

.chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart .grid {
  stroke: #e6e8ee;
  stroke-width: 1;
  stroke-dasharray: 2 3;
  vector-effect: non-scaling-stroke;
}

.chart .axis {
  stroke: #c9cdd6;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart .series {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.chart .axis-label {
  fill: #98a0af;
  font-size: 10px;
  font-family: inherit;
}

.legend {
  list-style: none;
  display: flex;
  gap: 16px;
  margin: 6px 0 4px;
  padding: 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  display: inline-block;
}

.card-footer-link {
  text-align: right;
  margin-top: 8px;
  font-size: 12px;
}

.card-footer-link a {
  color: var(--text-muted);
}

.card-footer-link a:hover {
  color: var(--accent);
}

/* ---------- stat tiles ---------- */
.tile-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}

.tile {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow-card);
  background: var(--bg);
}

.tile-blue {
  background: #e9f0fb;
  border-color: #d7e3f7;
}

.tile-yellow {
  background: #fdf5d3;
  border-color: #f4e7ad;
}

.tile-value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.tile-label {
  font-size: 12.5px;
  color: #4a5261;
  margin-top: 2px;
}

.marker {
  font-size: 11px;
  vertical-align: middle;
}

.marker-ok {
  color: #17a34a;
}

.marker-alert {
  color: #cc2b2b;
}

/* ---------- table ---------- */
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.table-head .section-title {
  margin: 0;
}

.table-card {
  padding: 0;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.data-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: #4a5261;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #f0f1f4;
  font-size: 13px;
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.row-link {
  color: var(--accent);
  font-weight: 600;
}

.row-link:hover {
  text-decoration: underline;
}

.tag {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #eceef2;
  color: #4a5261;
  font-size: 10.5px;
  font-weight: 600;
}

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.pill-planned {
  background: #fdeed4;
  color: #96560a;
}

.pill-scheduled {
  background: #e2f0e6;
  color: #1e6b38;
}

.pill-draft {
  background: #eceef2;
  color: #4a5261;
}

/* ---------- placeholder pages ---------- */
.placeholder-page {
  padding: 40px 4px;
}

.placeholder-page h1 {
  font-size: 26px;
  margin: 0 0 6px;
}

/* ---------- login ---------- */
.login-body {
  background: var(--bg-muted);
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(16, 24, 40, 0.08);
  padding: 30px 30px 26px;
}

.login-logo {
  height: 26px;
  width: auto;
  display: block;
  margin-bottom: 24px;
}

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

.login-sub {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.login-error {
  background: #fdeaea;
  border: 1px solid #f5c9c9;
  color: #9b1c1c;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 12.5px;
  margin-bottom: 16px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #3d434f;
}

.field input {
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.14);
}

.login-note {
  margin: 18px 0 0;
  font-size: 11.5px;
  color: var(--text-soft);
  line-height: 1.5;
}

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .chart-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .tile-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
  }
  .user-meta {
    display: none;
  }
  .content {
    padding: 18px 14px 32px;
  }
}
