:root {
  --bg: #f2eee6;
  --ink: #1f2721;
  --muted: #5f695f;
  --line: rgba(32, 48, 38, 0.12);
  --line-strong: rgba(32, 48, 38, 0.22);
  --paper: rgba(255, 250, 242, 0.88);
  --paper-strong: rgba(255, 252, 247, 0.98);
  --sidebar: rgba(28, 42, 34, 0.94);
  --sidebar-line: rgba(214, 222, 211, 0.12);
  --sidebar-text: #f6f1e8;
  --sidebar-muted: #b9c4b8;
  --accent: #c8682d;
  --accent-strong: #a94e1d;
  --accent-soft: rgba(200, 104, 45, 0.14);
  --green: #2f8f57;
  --red: #c44d4d;
  --shadow: 0 28px 80px rgba(54, 44, 28, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(200, 104, 45, 0.18), transparent 26%),
    radial-gradient(circle at bottom right, rgba(63, 120, 88, 0.14), transparent 24%),
    linear-gradient(140deg, #f6f2ea 0%, #ece5d7 48%, #efe8dc 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1520px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 32px;
}

.welcome-screen {
  min-height: calc(100vh - 60px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  gap: 28px;
  align-items: stretch;
}

.welcome-copy,
.login-card,
.sidebar,
.page-header,
.panel {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.welcome-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 251, 244, 0.94), rgba(246, 240, 229, 0.9));
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  font-weight: 800;
}

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

.welcome-copy h1 {
  max-width: 520px;
  font-size: clamp(34px, 4vw, 52px);
  line-height: 1;
  letter-spacing: -0.03em;
}

.lede {
  max-width: 420px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.login-card {
  align-self: center;
  padding: 28px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.96), rgba(248, 242, 233, 0.92));
}

.login-card h2 {
  font-size: 26px;
}

.login-card p:not(.message) {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  min-height: calc(100vh - 60px);
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 24px 18px 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(21, 34, 28, 0.96), rgba(30, 45, 37, 0.98));
  color: var(--sidebar-text);
  position: sticky;
  top: 24px;
  height: calc(100vh - 84px);
}

.sidebar-head h1 {
  font-size: 26px;
  line-height: 1.05;
}

.sidebar-nav {
  margin-top: 24px;
  display: grid;
  gap: 10px;
}

.nav-button {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--sidebar-line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--sidebar-text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.nav-button:hover {
  transform: translateX(2px);
  border-color: rgba(228, 232, 225, 0.2);
}

.nav-button.active {
  background: linear-gradient(135deg, rgba(200, 104, 45, 0.88), rgba(169, 78, 29, 0.94));
  border-color: transparent;
  box-shadow: 0 18px 32px rgba(13, 19, 15, 0.24);
}

.nav-title {
  font-size: 15px;
  font-weight: 800;
}

.nav-caption {
  display: none;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 14px;
}

.viewer-badge {
  display: inline-flex;
  align-items: center;
  min-height: 50px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--sidebar-line);
  color: #f7e7d8;
  line-height: 1.55;
  font-size: 13px;
  font-weight: 700;
}

.workspace-main {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.page-header,
.panel {
  background: var(--paper);
}

.page-header {
  padding: 22px 24px;
  border-radius: 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
}

.page-header h2 {
  font-size: 28px;
  line-height: 1.04;
  letter-spacing: -0.03em;
}

.page-description {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 780px;
}

.panel {
  padding: 22px;
  border-radius: 22px;
  min-width: 0;
}

.view-panel {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.panel-head,
.actions-row,
.generated-row,
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-head h3,
.home-hero h3 {
  font-size: 26px;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

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

.metric-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 252, 247, 0.76);
}

.metric-card strong {
  display: block;
  margin-top: 14px;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.form-panel {
  max-width: 920px;
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.stack-inline {
  display: grid;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid rgba(46, 60, 48, 0.16);
  background: rgba(255, 253, 249, 0.96);
  color: var(--ink);
  border-radius: 16px;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

input:focus {
  border-color: rgba(200, 104, 45, 0.55);
  box-shadow: 0 0 0 4px rgba(200, 104, 45, 0.12);
}

button {
  border: 0;
  border-radius: 16px;
  padding: 13px 18px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff6ef;
}

.ghost-button {
  background: rgba(255, 252, 247, 0.76);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.sidebar-logout {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--sidebar-line);
  color: var(--sidebar-text);
}

.danger-button {
  background: rgba(196, 77, 77, 0.14);
  color: #a53030;
  border: 1px solid rgba(196, 77, 77, 0.24);
}

.generated-card {
  margin-top: 18px;
  padding: 20px;
  border-radius: 22px;
  background: rgba(255, 251, 245, 0.88);
  border: 1px solid rgba(200, 104, 45, 0.2);
}

code,
.license-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f5ede0;
  border: 1px solid rgba(32, 48, 38, 0.12);
  color: var(--accent-strong);
  font-size: 15px;
  min-width: 92px;
}

.hint,
.message {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.message.error {
  color: #b43f3f;
}

.message.success {
  color: #2d7d4d;
}

.table-wrap {
  margin-top: 18px;
  overflow-x: hidden;
  overflow-y: visible;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 253, 250, 0.72);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
}

thead th {
  position: sticky;
  top: 0;
  background: #ece4d6;
  color: var(--ink);
  font-size: 11px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(32, 48, 38, 0.08);
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

th:nth-child(1),
td:nth-child(1) {
  width: 17%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 14%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 10%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 10%;
}

th:nth-child(5),
td:nth-child(5),
th:nth-child(6),
td:nth-child(6),
th:nth-child(7),
td:nth-child(7) {
  width: 9%;
}

th:nth-child(8),
td:nth-child(8) {
  width: 13%;
}

tbody tr:nth-child(odd) {
  background: rgba(255, 252, 248, 0.7);
}

tbody tr:nth-child(even) {
  background: rgba(247, 241, 232, 0.62);
}

.row-selected {
  outline: 1px solid rgba(200, 104, 45, 0.35);
  background: rgba(200, 104, 45, 0.08) !important;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge.active {
  background: rgba(47, 143, 87, 0.14);
  color: var(--green);
}

.badge.inactive {
  background: rgba(196, 77, 77, 0.14);
  color: var(--red);
}

.mini-button {
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.92);
  color: var(--ink);
  border: 1px solid rgba(32, 48, 38, 0.14);
}

.select-button {
  background: rgba(200, 104, 45, 0.1);
  color: var(--accent-strong);
  border: 1px solid rgba(200, 104, 45, 0.22);
}

.license-list {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.license-card {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.82);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.license-card:hover {
  transform: translateY(-1px);
  border-color: rgba(200, 104, 45, 0.28);
}

.license-card.selected {
  border-color: rgba(200, 104, 45, 0.42);
  box-shadow: 0 16px 28px rgba(200, 104, 45, 0.12);
  background: rgba(255, 248, 241, 0.94);
}

.license-card-main {
  min-width: 0;
}

.license-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.license-card-title {
  display: grid;
  gap: 4px;
}

.license-hospital {
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.license-label {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.license-card-meta {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.9);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.meta-chip strong {
  font-weight: 800;
}

.license-card-side {
  display: flex;
  align-items: center;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 29, 23, 0.42);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 24px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 251, 244, 0.98);
  box-shadow: 0 28px 80px rgba(24, 18, 11, 0.24);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-close {
  flex: 0 0 auto;
}

.empty-editor {
  color: var(--muted);
  line-height: 1.7;
  padding: 18px 0 6px;
}

@media (max-width: 1220px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .sidebar-nav {
    grid-template-columns: 1fr;
  }

  .license-card {
    grid-template-columns: 1fr;
  }

  .license-card-side {
    justify-content: flex-start;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw - 16px, 1520px);
    padding: 8px 0 18px;
  }

  .welcome-screen {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .welcome-copy,
  .login-card,
  .page-header,
  .panel,
  .sidebar {
    border-radius: 24px;
  }

  .welcome-copy,
  .login-card,
  .page-header,
  .panel {
    padding: 22px;
  }

  .page-header,
  .panel-head,
  .actions-row,
  .generated-row,
  .status-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-grid,
  .sidebar-nav,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .workspace {
    gap: 16px;
    min-height: auto;
  }

  .table-wrap {
    border-radius: 16px;
  }

  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 720px;
    table-layout: auto;
  }
}

@media (max-width: 640px) {
  .welcome-copy h1,
  .sidebar-head h1,
  .page-header h2 {
    font-size: 24px;
  }

  .page-description,
  .lede,
  .login-card p:not(.message) {
    font-size: 14px;
  }

  .metric-card {
    padding: 16px;
  }

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

  .panel,
  .page-header,
  .welcome-copy,
  .login-card {
    padding: 18px;
  }

  .sidebar {
    padding: 16px;
  }

  .sidebar-nav {
    gap: 8px;
  }

  .license-card-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-shell {
    padding: 12px;
  }

  .modal-card {
    width: 100%;
    max-height: calc(100vh - 24px);
    padding: 18px;
  }

  .modal-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .license-hospital {
    font-size: 20px;
  }

  .nav-button,
  button,
  input {
    width: 100%;
  }

  .actions-row,
  .generated-row,
  .status-row {
    width: 100%;
  }

  code,
  .license-chip {
    width: 100%;
    justify-content: flex-start;
  }

  table {
    min-width: 620px;
  }
}
