:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #17211f;
  --muted: #66736f;
  --line: #dce4e1;
  --brand: #146d62;
  --brand-dark: #0e4e47;
  --soft: #e9f4f1;
  --warn: #b42318;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
}

button,
input,
select {
  font: inherit;
}

.pid-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, #dff1ed, transparent 32%), var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(16, 24, 40, 0.12);
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  font-size: 12px;
}

h1,
h2,
p {
  margin-top: 0;
}

.login-card h1 {
  margin: 18px 0 8px;
  font-size: 24px;
}

.login-card p,
small {
  color: var(--muted);
}

.login-form,
.filter-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #46524f;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(20, 109, 98, 0.12);
}

.primary-btn,
.ghost-btn {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
}

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

.primary-btn:hover {
  background: var(--brand-dark);
}

.ghost-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.ghost-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.error-line {
  margin: 0;
  border: 1px solid #f3b4ad;
  color: var(--warn);
  background: #fff3f1;
  border-radius: 6px;
  padding: 10px 12px;
}

#pid-root {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 246px 1fr;
}

.pid-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #10211d;
  color: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-title {
  display: flex;
  gap: 12px;
  align-items: center;
}

.sidebar-title strong {
  display: block;
  font-size: 16px;
}

.sidebar-title small {
  color: #b6c8c3;
}

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

.pid-sidebar nav button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: #d9e7e3;
  border-radius: 7px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.pid-sidebar nav button small {
  display: block;
  color: #8da39d;
  margin-top: 3px;
}

.pid-sidebar nav button.active {
  background: #e9f4f1;
  color: #10211d;
}

.pid-sidebar nav button.active small {
  color: #49605a;
}

.logout-btn {
  margin-top: auto;
}

.pid-main {
  padding: 24px;
  min-width: 0;
}

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

.topbar h1 {
  margin: 0;
  font-size: 25px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.topbar-actions,
.form-actions,
.pager {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card,
.filter-panel,
.table-card,
.dashboard-table {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.05);
}

.metric-card {
  padding: 14px;
  display: grid;
  gap: 6px;
}

.metric-card span {
  color: var(--muted);
  font-weight: 700;
}

.metric-card strong {
  font-size: 22px;
}

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

.dashboard-panel {
  margin-bottom: 14px;
}

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

.dashboard-head h2 {
  margin-bottom: 4px;
  font-size: 16px;
}

.dashboard-head p {
  margin: 0;
  color: var(--muted);
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.dashboard-metrics .metric-card {
  box-shadow: none;
}

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

.dashboard-table {
  overflow: hidden;
}

.dashboard-table table {
  min-width: 520px;
}

.dashboard-grid .dashboard-table:first-child table {
  min-width: 760px;
}

.mini-table-wrap {
  max-height: 320px;
  overflow: auto;
}

.mini-table-wrap.months {
  max-height: 320px;
}

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

.filter-head h2 {
  margin-bottom: 4px;
  font-size: 16px;
}

.filter-head p {
  margin: 0;
  color: var(--muted);
}

.filter-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  align-items: end;
}

.table-card {
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.table-toolbar span {
  color: var(--muted);
}

.pid-table-wrap {
  overflow: auto;
  max-height: calc(100vh - 360px);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 960px;
}

th,
td {
  border-bottom: 1px solid #edf1ef;
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbfa;
  color: #394642;
  font-weight: 800;
}

th small {
  display: block;
  font-weight: 600;
  margin-top: 2px;
}

tbody tr:hover {
  background: var(--soft);
}

.pager {
  padding: 12px 16px;
}

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

.page-error {
  margin-bottom: 12px;
}

@media (max-width: 980px) {
  #pid-root {
    grid-template-columns: 1fr;
  }

  .pid-sidebar {
    position: static;
    height: auto;
  }

  .metrics,
  .filter-grid,
  .dashboard-metrics,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 620px) {
  .pid-main {
    padding: 16px;
  }

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

  .topbar {
    display: grid;
  }
}
