@import url("https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=Instrument+Serif:ital@0;1&display=swap");

:root {
  --ink: #0f172a;
  --ink-soft: #334155;
  --ink-muted: #64748b;
  --paper: #f8fafc;
  --paper-alt: #f1f5f9;
  --accent: #1d4ed8;
  --accent-mid: #3b82f6;
  --accent-soft: #dbeafe;
  --danger: #b91c1c;
  --warning: #92400e;
  --success: #166534;
  --border: rgba(15, 23, 42, 0.12);
  --sans: "DM Sans", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  background: linear-gradient(180deg, #ffffff 0%, var(--paper) 55%, #eef3fb 100%);
  color: var(--ink-soft);
  line-height: 1.45;
}

html,
body {
  width: 100%;
  max-width: 100%;
}

a {
  color: inherit;
}

.platform-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.platform-nav {
  border-right: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.96);
  backdrop-filter: blur(6px);
  padding: 1.25rem 1rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.platform-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
}

.platform-brand {
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin-bottom: 0;
  line-height: 1;
}

.platform-nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
}

.platform-user-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: #fff;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.42rem 0.7rem;
}

.platform-user-link:hover {
  color: var(--ink);
  border-color: rgba(29, 78, 216, 0.32);
  background: rgba(219, 234, 254, 0.45);
}

.platform-logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 999px;
  border: 1px solid rgba(185, 28, 28, 0.24);
  background: rgba(254, 242, 242, 0.9);
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.42rem 0.7rem;
}

.platform-logout-link:hover {
  border-color: rgba(185, 28, 28, 0.36);
  background: rgba(254, 226, 226, 1);
}

.platform-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: #fff;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1;
  padding: 0.4rem 0.8rem;
}

.platform-nav-toggle::before {
  content: "☰";
  font-size: 0.9rem;
  line-height: 1;
}

.platform-nav[data-mobile-open="true"] .platform-nav-toggle::before {
  content: "✕";
}

.platform-nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.platform-nav-overlay {
  display: none;
}

.platform-nav-link {
  display: block;
  text-decoration: none;
  color: var(--ink-muted);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font-size: 0.92rem;
  font-weight: 500;
}

.platform-nav-link:hover {
  color: var(--ink);
  border-color: rgba(29, 78, 216, 0.24);
  background: rgba(219, 234, 254, 0.5);
}

.platform-nav-link.active {
  color: var(--accent);
  border-color: rgba(29, 78, 216, 0.3);
  background: var(--accent-soft);
}

.platform-main {
  padding: 1.75rem;
  min-width: 0;
}

.module-header h1 {
  font-family: var(--serif);
  margin: 0;
  font-size: clamp(2rem, 3vw, 2.35rem);
  font-weight: 400;
  line-height: 1.1;
  color: var(--ink);
}

.module-subtitle {
  color: var(--ink-muted);
  margin: 0.35rem 0 1.4rem 0;
  font-size: 0.96rem;
  max-width: 70ch;
}

.module-controls {
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-size: 0.72rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

input,
select,
button,
textarea {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(29, 78, 216, 0.5);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

button {
  cursor: pointer;
  background: #fff;
  border-color: rgba(15, 23, 42, 0.2);
  font-weight: 500;
}

button:hover {
  border-color: var(--accent-mid);
  color: var(--accent);
}

button.primary {
  border: none;
  color: #fff;
  background: var(--accent);
}

button.primary:hover {
  color: #fff;
  background: var(--accent-mid);
}

.module-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  min-width: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kpi-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--paper);
  padding: 0.65rem;
}

.kpi-label {
  color: var(--ink-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.kpi-value {
  font-size: 1.28rem;
  color: var(--ink);
  margin-top: 0.2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
}

.table-scroll table {
  min-width: 680px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.35rem;
  vertical-align: top;
}

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

th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--ink-muted);
}

tbody tr:hover td {
  background: rgba(219, 234, 254, 0.45);
}

code {
  color: var(--ink);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  padding: 0.12rem 0.45rem;
  font-size: 0.73rem;
  font-weight: 600;
}

.pill.critical {
  border-color: rgba(185, 28, 28, 0.35);
  color: #991b1b;
  background: rgba(185, 28, 28, 0.08);
}

.pill.high {
  border-color: rgba(146, 64, 14, 0.35);
  color: #92400e;
  background: rgba(217, 119, 6, 0.08);
}

.pill.medium {
  border-color: rgba(217, 119, 6, 0.32);
  color: #b45309;
  background: rgba(245, 158, 11, 0.1);
}

.pill.low {
  border-color: rgba(22, 101, 52, 0.33);
  color: #166534;
  background: rgba(22, 101, 52, 0.09);
}

.state-panel {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 10px;
  background: var(--paper-alt);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.state-panel[data-shared-state="loading"] {
  border-color: rgba(59, 130, 246, 0.32);
}

.state-panel[data-shared-state="error"] {
  border-color: rgba(185, 28, 28, 0.35);
  background: rgba(254, 242, 242, 0.95);
}

.state-panel[data-shared-state="empty"] {
  border-color: rgba(29, 78, 216, 0.22);
}

.state-icon {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.state-copy {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.state-description {
  color: var(--ink-muted);
  font-size: 0.92rem;
  margin: 0;
  overflow-wrap: anywhere;
}

.state-guidance {
  margin-top: 0.1rem;
}

.state-guidance-title {
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.state-guidance ul {
  margin: 0;
  padding-left: 1.1rem;
}

.state-guidance li {
  color: var(--ink-muted);
  font-size: 0.86rem;
  margin: 0.1rem 0;
  overflow-wrap: anywhere;
}

.state-actions {
  margin-top: 0.35rem;
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(560px, 100%);
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.09);
  padding: 1.35rem 1.25rem;
}

.auth-title {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.8rem, 2.6vw, 2.1rem);
  line-height: 1.15;
}

.auth-subtitle {
  margin: 0.4rem 0 1rem 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.auth-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.auth-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  background: #fff;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.52rem 0.85rem;
}

.auth-link:hover {
  border-color: rgba(29, 78, 216, 0.26);
  color: var(--accent);
}

.auth-link.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.auth-link.primary:hover {
  background: var(--accent-mid);
  color: #fff;
}

.auth-note {
  margin-top: 0.85rem;
  color: var(--ink-muted);
  font-size: 0.83rem;
}

@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .platform-nav {
    height: auto;
    position: sticky;
    z-index: 5;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 1rem;
  }

  .platform-nav-header {
    margin-bottom: 0;
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  .platform-nav-actions {
    gap: 0.38rem;
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .platform-user-link {
    padding: 0.35rem 0.58rem;
    font-size: 0.78rem;
  }

  .platform-logout-link {
    padding: 0.35rem 0.58rem;
    font-size: 0.78rem;
  }

  .platform-nav-toggle {
    display: inline-flex;
  }

  .platform-nav-list {
    display: none;
    margin-top: 0.75rem;
    padding-bottom: 0.15rem;
  }

  .platform-nav[data-mobile-open="true"] .platform-nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: min(68vh, 460px);
    overflow-y: auto;
  }

  .platform-nav-link {
    white-space: nowrap;
    font-size: 0.88rem;
    padding: 0.5rem 0.62rem;
  }

  body.platform-nav-open {
    overflow: hidden;
  }

  .platform-nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.28);
    z-index: 4;
  }

  body.platform-nav-open .platform-nav-overlay {
    display: block;
  }
}

@media (max-width: 640px) {
  .platform-main {
    padding: 1rem;
  }

  .platform-brand {
    font-size: 1.45rem;
  }

  .module-header h1 {
    font-size: 1.45rem;
    line-height: 1.2;
  }

  .module-subtitle {
    font-size: 0.92rem;
    line-height: 1.5;
  }

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

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

  .module-controls .field,
  .module-controls button {
    width: 100%;
  }

  .table-scroll table {
    min-width: 560px;
  }
}
