:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbe3ea;
  --line-soft: #edf2f7;
  --primary: #0d8f83;
  --primary-dark: #086f65;
  --sidebar: #071c2f;
  --sidebar-2: #0b2a41;
  --green-soft: #dff7ea;
  --green-text: #087044;
  --blue-soft: #e7f0ff;
  --blue-text: #1d5bbf;
  --purple-soft: #eee8ff;
  --purple-text: #6a3ecf;
  --orange-soft: #fff0dd;
  --orange-text: #d86b12;
  --red-soft: #fdeaea;
  --red-text: #c72c2c;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  --sidebar-width: 252px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 800;
}

button,
input,
select {
  font: inherit;
}

.icon {
  flex: none;
  width: 18px;
  height: 18px;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-flip {
  transform: scaleX(-1);
}

/* ---------- shell / sidebar ---------- */

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

.sidebar-overlay {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  z-index: 30;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 12px;
  background: linear-gradient(180deg, #061829 0%, #08233a 60%, #061829 100%);
  color: white;
  overflow-y: auto;
}

.sidebar-close {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 10px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: white;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  color: #1bbfb3;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.1;
}

.brand small {
  margin-top: 3px;
  color: #b8c9d8;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 5px;
  padding: 20px 0;
}

.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 8px;
  color: #cfe0eb;
  font-size: 14px;
  font-weight: 700;
  user-select: none;
}

.nav a .icon {
  color: #7ea3b8;
}

.nav a.active {
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: 0 12px 22px rgba(13, 143, 131, 0.28);
}

.nav a.active .icon {
  color: white;
}

.nav a:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.nav-section {
  margin: 22px 10px 8px;
  color: #23c7b7;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-footer {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  color: #b8c9d8;
  font-size: 14px;
  font-weight: 700;
  user-select: none;
}

.sidebar-footer a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.sidebar-footer form {
  margin: 0;
}

.sidebar-footer form button {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #b8c9d8;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  user-select: none;
}

.sidebar-footer form button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 14px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-user > .avatar,
.avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-weight: 900;
  font-size: 14px;
}

.sidebar-user strong,
.sidebar-user small {
  display: block;
}

.sidebar-user small {
  margin-top: 2px;
  color: #b8c9d8;
}

/* ---------- topbar ---------- */

.content {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  min-height: 66px;
  gap: 18px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.menu-button {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.menu-button .icon {
  width: 22px;
  height: 22px;
}

.topbar-title {
  margin-right: auto;
  font-size: 21px;
  font-weight: 900;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid #cdd7e1;
  border-radius: 8px;
  background: white;
  color: var(--text);
  font-weight: 700;
  user-select: none;
}

.date-chip .icon {
  color: var(--muted);
}

.icon-only-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 1px solid #cdd7e1;
  border-radius: 999px;
  background: white;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.icon-only-button:hover {
  background: var(--surface-soft);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 3px 8px 3px 3px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.user-menu:hover {
  background: var(--surface-soft);
}

.user-menu .icon {
  color: var(--muted);
}

.user-menu-name {
  font-weight: 800;
}

/* ---------- page basics ---------- */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 22px 24px 14px;
}

.page-header h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.page-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

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

h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 4px;
  font-size: 18px;
}

h2 .icon {
  color: var(--primary);
}

h3 {
  font-size: 16px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid #b9c7d3;
  border-radius: 8px;
  background: white;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
  user-select: none;
}

.button.primary {
  border-color: var(--primary);
  background: linear-gradient(180deg, #0e9c8f 0%, #086f65 100%);
  color: white;
  box-shadow: 0 12px 22px rgba(13, 143, 131, 0.2);
}

.button.subtle {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.button.danger-outline {
  border-color: #f2b9b9;
  color: #d52f2f;
}

/* ---------- metrics ---------- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 0 24px 18px;
}

.metric {
  position: relative;
  min-height: 116px;
  padding: 20px 18px 18px 88px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: var(--shadow);
}

.metric i {
  position: absolute;
  left: 18px;
  top: 22px;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  font-style: normal;
}

.metric i .icon {
  width: 24px;
  height: 24px;
}

.metric span {
  display: block;
  color: #1e293b;
  font-size: 14px;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 6px;
  color: var(--primary);
  font-size: 30px;
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.metric-teal i { background: var(--green-soft); color: var(--green-text); }
.metric-blue i { background: var(--blue-soft); color: var(--blue-text); }
.metric-purple i { background: var(--purple-soft); color: var(--purple-text); }
.metric-orange i { background: var(--orange-soft); color: var(--orange-text); }
.metric-blue strong { color: #2672d9; }
.metric-purple strong { color: var(--purple-text); }
.metric-orange strong { color: var(--orange-text); }

/* ---------- panels ---------- */

.panel,
.filter-bar,
.form-grid,
.empty-state,
.entry-summary,
.people-panel,
.presence-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  box-shadow: var(--shadow);
}

.panel {
  margin: 0 24px 18px;
  padding: 18px;
}

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

.panel-header p {
  margin: 0;
  color: var(--muted);
}

/* ---------- site cards ---------- */

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

.site-card {
  min-height: 280px;
  padding: 14px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, white 0%, #fbfdfe 100%);
  box-shadow: 0 7px 18px rgba(15, 23, 42, 0.06);
}

.site-illustration {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 66px;
  margin: 0 -14px 12px;
  padding: 8px 0 0;
  background: linear-gradient(180deg, #f2fbf9 0%, #eaf7f4 100%);
  border-bottom: 1px solid var(--line-soft);
}

.skyline {
  width: 86%;
  height: 60px;
  fill: none;
  stroke: var(--primary);
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: 0.55;
}

.pin {
  display: block;
  width: 22px;
  height: 28px;
  margin-bottom: 8px;
  border-radius: 14px 14px 14px 3px;
  background: var(--primary);
  transform: rotate(-45deg);
}

.pin-icon {
  color: var(--primary);
}

.site-card h3 {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 42px;
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.3;
}

.site-card h3 .icon {
  margin-top: 1px;
}

.site-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.site-line span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.site-line .icon {
  color: var(--muted);
}

.site-line strong {
  color: var(--primary);
  font-size: 20px;
}

.company-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.company-pills span,
.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid #bce8c9;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-text);
  font-size: 12px;
  font-weight: 900;
}

.company-pills span:nth-child(4n+2) {
  border-color: #bcd6f7;
  background: var(--blue-soft);
  color: var(--blue-text);
}

.company-pills span:nth-child(4n+3) {
  border-color: #d8c9f7;
  background: var(--purple-soft);
  color: var(--purple-text);
}

.company-pills span:nth-child(4n+4) {
  border-color: #f7d9ad;
  background: var(--orange-soft);
  color: var(--orange-text);
}

.status-pill.is-inactive {
  border-color: #f2c6c6;
  background: var(--red-soft);
  color: var(--red-text);
}

.site-card a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 22px;
  text-align: center;
}

/* ---------- filters / forms ---------- */

.filter-bar,
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
  margin: 0 24px 18px;
  padding: 16px;
}

.filter-bar.report-filter {
  display: flex;
  flex-wrap: wrap;
}

.filter-bar.report-filter label {
  flex: 1 1 150px;
  min-width: 130px;
}

.filter-bar.report-filter button {
  flex: none;
}

.filter-bar.entry-filter {
  grid-template-columns: 220px minmax(320px, 1fr) auto auto;
}

label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cad6e1;
  border-radius: 7px;
  background: white;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(13, 143, 131, 0.35);
  outline-offset: 1px;
  border-color: var(--primary);
}

textarea {
  min-height: 180px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}

input[type="time"] {
  min-width: 112px;
}

input[type="number"] {
  min-width: 105px;
}

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

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

/* ---------- entries workspace ---------- */

.entry-workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  margin: 0 24px 18px;
}

.people-panel,
.presence-panel {
  min-width: 0;
}

.people-panel {
  padding: 22px 18px 12px;
}

.people-panel h2 {
  margin-bottom: 18px;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field .icon {
  position: absolute;
  left: 15px;
  color: var(--muted);
  pointer-events: none;
}

.search-field .search-box {
  padding-left: 40px;
}

.search-box {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #cad6e1;
  border-radius: 8px;
  background: white;
  color: var(--text);
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.filter-pills button {
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.filter-pills button.active,
.filter-pills button:hover {
  border-color: var(--primary);
  background: var(--green-soft);
  color: var(--green-text);
}

.people-list {
  overflow: auto;
  max-height: 510px;
  margin: 14px -18px 10px;
  border-top: 1px solid var(--line-soft);
}

.person-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: white;
  cursor: pointer;
  text-align: left;
  user-select: none;
}

.person-row[hidden],
.person-row.is-hidden {
  display: none;
}

.person-row:hover {
  background: #effaf8;
}

.person-row.is-selected {
  background: #f1f5f9;
  color: var(--muted);
  cursor: default;
}

.person-code {
  color: var(--muted);
  font-weight: 800;
}

.person-row span {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-row strong {
  display: inline-flex;
  min-width: 42px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green-text);
  font-size: 12px;
}

.presence-panel {
  overflow: hidden;
}

.table-title {
  padding: 20px 20px 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.content > .table-wrap {
  margin: 0 24px 24px;
}

.presence-panel .table-wrap,
.panel .table-wrap {
  border-left: 0;
  border-right: 0;
  border-radius: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #fafcfe;
}

td details summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 800;
  font-size: 12px;
  user-select: none;
}

td details pre {
  max-width: 360px;
  margin: 6px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.presence-table td,
.presence-table th {
  border-right: 1px solid var(--line-soft);
}

.presence-table td:last-child,
.presence-table th:last-child {
  border-right: 0;
}

.presence-empty-cell {
  height: 140px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.remove-row-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
  color: #b42318;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.remove-row-button:hover {
  background: #fee2e2;
}

.info-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 16px 18px;
  border-top: 1px solid #bdd4ff;
  background: #eef5ff;
  color: #1551c9;
  font-weight: 700;
}

.entry-summary {
  display: flex;
  align-items: center;
  gap: 42px;
  margin: 0 24px 24px;
  padding: 22px;
}

.entry-summary div {
  display: grid;
  gap: 3px;
}

.entry-summary strong {
  color: var(--primary);
  font-size: 24px;
}

.entry-summary span {
  color: var(--muted);
}

.entry-summary .button {
  margin-left: auto;
}

/* ---------- report paper ---------- */

.report-paper {
  overflow-x: auto;
  margin: 0 24px 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.report-paper > h2 {
  display: block;
  min-width: 1180px;
  margin: 0;
  padding: 22px 14px 18px;
  border: 2px solid #111;
  border-bottom: 0;
  text-align: center;
  font-size: 22px;
}

.report-columns {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(235px, 1fr);
  min-width: 1180px;
  border: 2px solid #111;
  background: white;
}

.report-site {
  min-height: 560px;
  border-right: 2px solid #111;
}

.report-site:last-child {
  border-right: 0;
}

.report-site h3 {
  display: block;
  margin: 0;
  padding: 9px 6px;
  border-bottom: 2px solid #111;
  background: #f7f7f7;
  color: #000;
  text-align: center;
  font-size: 16px;
}

.report-site table td {
  padding: 6px 7px;
  border: 0;
  color: #000;
  font-size: 14px;
  line-height: 1.25;
}

.report-site .code {
  width: 30px;
  text-align: right;
}

.report-site .company {
  width: 56px;
  text-align: right;
}

.report-site .hours {
  width: 36px;
  text-align: right;
  font-weight: 900;
}

.report-summary .metric,
.metric.compact {
  min-height: 112px;
  padding: 24px 24px 24px 88px;
}

.metric.compact strong {
  font-size: 34px;
}

.empty-state {
  margin: 0 24px 24px;
  padding: 24px;
  color: var(--muted);
  font-weight: 800;
}

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

.flat {
  box-shadow: none;
}

.actions-cell {
  display: flex;
  gap: 6px;
  align-items: center;
}

.actions-cell form {
  margin: 0;
}

.table-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 32px;
  padding: 0 10px;
  border: 1px solid #b9c7d3;
  border-radius: 6px;
  background: white;
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  user-select: none;
}

.table-button:hover {
  background: var(--surface-soft);
}

.table-button.danger {
  border-color: #f2b9b9;
  color: #d52f2f;
}

.table-button.danger:hover {
  background: var(--red-soft);
}

/* ---------- modal ---------- */

.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 24, 38, 0.55);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(15, 23, 42, 0.4);
  border-radius: 12px;
  background: white;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}

.modal-header {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  cursor: pointer;
}

.modal-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
  display: grid;
  gap: 16px;
  align-content: start;
}

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

.modal-actions {
  flex: none;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: white;
}

.modal-hint {
  margin: -6px 0 0;
  font-size: 13px;
}

.modal-divider {
  height: 1px;
  background: var(--line);
}

.modal-body h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.modal-body h3 .icon {
  color: var(--primary);
}

.modal-body > p.muted {
  margin: -8px 0 0;
}

/* ---------- permission matrix ---------- */

.permission-matrix th:not(:first-child),
.permission-matrix td:not(:first-child) {
  text-align: center;
}

.permission-matrix input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ---------- auth (login) ---------- */

.auth-body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #061829 0%, #08233a 60%, #061829 100%);
}

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

.auth-lang {
  position: fixed;
  top: 20px;
  right: 20px;
}

.auth-card {
  width: min(420px, 100%);
  padding: 36px 32px;
  border-radius: 16px;
  background: white;
  box-shadow: 0 30px 80px rgba(2, 10, 20, 0.45);
}

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

.auth-brand .brand-mark {
  width: 40px;
  height: 40px;
  flex: none;
  color: var(--primary);
}

.auth-brand strong,
.auth-brand small {
  display: block;
}

.auth-brand strong {
  font-size: 17px;
}

.auth-brand small {
  margin-top: 2px;
  color: var(--muted);
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.auth-card > p.muted {
  margin: 0 0 22px;
}

.auth-error {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid #f2c6c6;
  border-radius: 8px;
  background: var(--red-soft);
  color: var(--red-text);
  font-weight: 700;
  font-size: 14px;
}

/* ---------- SQL console ---------- */

.sql-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 24px 18px;
  padding: 16px 18px;
  border: 1px solid #f7d9ad;
  border-radius: 10px;
  background: var(--orange-soft);
  color: var(--orange-text);
  font-weight: 700;
  font-size: 14px;
}

.sql-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 24px 18px;
  padding: 16px 18px;
  border: 1px solid #f2c6c6;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red-text);
}

.sql-error strong {
  display: block;
  margin-bottom: 4px;
}

.sql-error p {
  margin: 0;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form .button {
  margin-top: 6px;
  width: 100%;
}

/* ---------- responsive: tablet ---------- */

@media (max-width: 1280px) {
  .site-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 1200px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .entry-workspace {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 960px) {
  .site-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* off-canvas sidebar */
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: min(var(--sidebar-width), 84vw);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 24px 60px rgba(2, 10, 20, 0.4);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: grid;
    place-items: center;
    position: absolute;
    top: 16px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: white;
    cursor: pointer;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    background: rgba(6, 16, 27, 0.55);
  }

  .sidebar-overlay[hidden] {
    display: none;
  }

  .menu-button {
    display: inline-flex;
  }

  .topbar-title {
    font-size: 18px;
  }

  .user-menu-name {
    display: none;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 10px 16px;
    flex-wrap: wrap;
    row-gap: 10px;
  }

  .topbar-title {
    order: 1;
    flex: 1 1 auto;
  }

  .topbar-actions {
    order: 2;
    width: 100%;
    justify-content: space-between;
  }

  .date-chip span {
    display: none;
  }

  .button.primary span {
    display: inline;
  }

  .page-header,
  .metric-grid,
  .panel,
  .filter-bar,
  .entry-workspace,
  .entry-summary,
  .report-paper,
  .empty-state,
  .content > .table-wrap {
    margin-left: 14px;
    margin-right: 14px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .page-header,
  .filter-bar,
  .form-grid,
  .filter-bar.entry-filter,
  .metric-grid,
  .site-grid {
    grid-template-columns: 1fr !important;
  }

  .filter-bar.report-filter {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar.report-filter label,
  .filter-bar.report-filter button {
    width: 100%;
  }

  .page-header {
    display: grid;
  }

  .page-header .button {
    width: 100%;
  }

  .metric {
    padding-left: 100px;
  }

  .entry-summary {
    display: grid;
    text-align: left;
  }

  .entry-summary .button {
    margin-left: 0;
    width: 100%;
  }

  .panel-header {
    flex-direction: column;
  }

  .panel-header .button {
    width: 100%;
  }

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

  .modal-actions {
    display: grid;
  }
}
