:root {
  --ink: #17202a;
  --muted: #667085;
  --line: #d7dde5;
  --brand: #0e5a8a;
  --brand-dark: #093b5c;
  --accent: #d79b2b;
  --bg: #f4f7fa;
  --panel: #ffffff;
  --danger: #b42318;
  --warning: #b54708;
  --good: #027a48;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}
button, input, select, textarea { font: inherit; }
button, .button {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 9px 13px;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--brand-dark); }
button.secondary {
  background: #fff;
  color: var(--brand);
}
button.danger-button {
  background: var(--danger);
  border-color: var(--danger);
}
button.small-button {
  padding: 5px 8px;
  font-size: 12px;
}
a { color: var(--brand); }
.app-shell { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: #101820;
  color: #fff;
  padding: 20px 16px;
  overflow-y: auto;
  max-height: 100vh;
}
.brand-block { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand-block span { display: block; color: #b8c2cc; font-size: 13px; margin-top: 3px; }
.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #101820;
  border-radius: 6px;
  font-weight: 800;
  letter-spacing: 0;
}
.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 4px;
  border: 1px solid rgba(16, 24, 32, .12);
}
.login-panel .brand-logo {
  width: 72px;
  height: 72px;
}
.search-box input {
  width: 100%;
  border: 1px solid #34495d;
  background: #0b1118;
  color: #fff;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 14px;
}
.section-nav details { border-top: 1px solid #2e3a46; padding: 8px 0; }
.section-nav summary {
  list-style: none;
  display: grid;
  grid-template-columns: 28px 1fr 30px;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #e8eef4;
  font-size: 13px;
  text-transform: uppercase;
}
.section-nav summary::-webkit-details-marker { display: none; }
.section-nav summary span {
  height: 24px;
  display: grid;
  place-items: center;
  background: #25313d;
  border-radius: 4px;
  color: var(--accent);
  font-weight: 700;
}
.section-nav summary em {
  color: #9aa7b4;
  font-style: normal;
  text-align: right;
}
.section-nav small { display: block; color: #9aa7b4; padding: 10px 0 6px 38px; }
.doc-link {
  width: 100%;
  border: 0;
  background: transparent;
  color: #cfd8e2;
  text-align: left;
  padding: 8px 8px 8px 38px;
  border-radius: 6px;
  line-height: 1.25;
}
.doc-link:hover, .doc-link.active { background: #23313f; color: #fff; }
.client-doc-link strong {
  display: block;
  font-weight: 700;
}
.client-doc-link small {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #9aa7b4;
  font-size: 12px;
  margin-top: 4px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--good);
  flex: 0 0 auto;
}
.status-dot.expiring {
  background: var(--warning);
}
.status-dot.expired {
  background: var(--danger);
}
.workspace { padding: 24px; min-width: 0; }
.topbar, .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.topbar h1, .panel-head h2 { margin: 0; }
.topbar p, .panel-head p { color: var(--muted); margin: 5px 0 0; }
.user-strip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.user-strip span { color: var(--muted); font-size: 13px; }
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0;
}
.metrics div, .document-panel, .detail-panel, .client-management {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.metrics div { padding: 16px; }
.metrics span { display: block; color: var(--muted); font-size: 13px; }
.metrics strong { display: block; font-size: 28px; margin-top: 6px; }
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
}
.client-management {
  margin-bottom: 18px;
  overflow: hidden;
}
.panel-head.compact {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.client-table-wrap {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th, .data-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}
.data-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  background: #f8fafc;
}
.data-table td span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.compact-table {
  margin-top: 14px;
  font-size: 13px;
}
.document-selector {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: #f8fafc;
}
.document-selector details {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.document-selector details:last-child {
  border-bottom: 0;
}
.document-selector summary {
  display: grid;
  grid-template-columns: 28px 1fr 36px;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  font-weight: 700;
}
.document-selector summary span {
  height: 24px;
  display: grid;
  place-items: center;
  background: #e8eef4;
  color: var(--brand);
  border-radius: 4px;
}
.document-selector summary em {
  color: var(--muted);
  font-style: normal;
  text-align: right;
}
.document-selector label {
  display: block;
  padding: 7px 0 7px 36px;
  font-weight: 400;
}
.document-selector small {
  display: block;
  color: var(--muted);
  margin: 2px 0 0 22px;
}
.document-panel { min-height: calc(100vh - 190px); display: flex; flex-direction: column; }
.panel-head { padding: 16px; border-bottom: 1px solid var(--line); }
.viewer-actions { display: flex; gap: 8px; }
.disabled, button:disabled {
  opacity: .5;
  pointer-events: none;
}
#pdfViewer {
  width: 100%;
  flex: 1;
  min-height: 640px;
  border: 0;
  background: #eef2f6;
}
.mobile-pdf-preview {
  flex: 1;
  min-height: 640px;
  overflow: auto;
  background: #eef2f6;
  padding: 12px;
}
.mobile-pdf-preview img {
  display: block;
  width: min(100%, 900px);
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 8px 24px rgba(16, 24, 32, .14);
}
.mobile-pdf-preview p {
  margin: 10px auto 0;
  width: min(100%, 900px);
  color: var(--muted);
  font-size: 13px;
}
.detail-panel { padding: 16px; align-self: start; }
.detail-panel h2, .detail-panel h3 { margin: 0 0 12px; }
.detail-panel h3 { margin-top: 20px; font-size: 15px; }
dl { display: grid; grid-template-columns: 120px 1fr; gap: 10px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 99px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}
.pill.good { background: #ecfdf3; color: var(--good); }
.pill.warning { background: #fffaeb; color: var(--warning); }
.pill.danger { background: #fef3f2; color: var(--danger); }
.history-list div {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}
.history-list span, .history-list small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.alert-list button {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.alert-list button.warning { border-left: 4px solid var(--warning); }
.alert-list button.danger { border-left: 4px solid var(--danger); }
.alert-list span { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
dialog {
  width: min(620px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}
.wide-dialog {
  width: min(1050px, calc(100vw - 24px));
}
dialog::backdrop { background: rgba(16, 24, 32, .55); }
dialog form { padding: 18px; display: grid; gap: 12px; }
dialog header { display: flex; justify-content: space-between; align-items: center; }
dialog h2 { margin: 0; }
.client-dialog {
  padding: 18px;
}
.user-admin-dialog {
  padding: 18px;
}
.user-admin-dialog > header {
  margin-bottom: 12px;
}
.user-admin-dialog form + form {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}
.user-admin-dialog h3, .client-dialog h3 {
  margin: 0 0 10px;
}
.client-dialog > header {
  margin-bottom: 12px;
}
.dialog-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.dialog-tabs button {
  background: transparent;
  color: var(--ink);
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 10px 12px;
}
.dialog-tabs button.active {
  border-bottom-color: var(--brand);
  color: var(--brand);
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}
.form-grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.toggle-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.toggle-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
.checkbox-label input {
  width: auto;
}
.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.inline-form, .notification-form {
  display: grid;
  gap: 12px;
}
.inline-form {
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr) minmax(140px, .7fr) auto;
  align-items: end;
}
.inline-form .form-message {
  grid-column: 1 / -1;
}
label { display: grid; gap: 6px; font-weight: 700; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}
.form-message { margin: 0; color: var(--muted); }
.good-text { color: var(--good); }
.bad-text { color: var(--danger); }
.logo-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.logo-preview span {
  color: var(--muted);
}
.account-summary {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.account-summary dl {
  grid-template-columns: 100px 1fr;
  gap: 8px 12px;
  font-size: 14px;
}
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #101820 0%, #17364a 55%, #f4f7fa 55%);
}
.login-panel {
  width: min(430px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 24px 70px rgba(16, 24, 32, .24);
}
.login-panel h1 { margin: 16px 0 6px; }
.login-panel p { color: var(--muted); margin-top: 0; }
.login-form { display: grid; gap: 14px; margin: 18px 0; }
.login-form button { width: 100%; }
.notice { padding: 10px 12px; border-radius: 6px; margin: 14px 0; }
.notice.danger { background: #fef3f2; color: var(--danger); }
.client-viewer {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.client-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 22px;
  background: #101820;
  color: #fff;
}
.client-viewer-header .user-strip span {
  color: #cfd8e2;
}
.client-viewer-header a {
  color: #fff;
}
.client-viewer-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 0;
  flex: 1;
  min-height: 0;
}
.client-menu {
  background: #101820;
  color: #fff;
  padding: 0 16px 20px;
  overflow: auto;
}
.client-menu input {
  width: 100%;
  margin: 6px 0 14px;
  border-color: #34495d;
  background: #0b1118;
  color: #fff;
}
.client-pdf-panel {
  min-height: calc(100vh - 84px);
  border-radius: 0;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
}
.client-document-summary {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}
.client-document-summary dl {
  grid-template-columns: repeat(4, auto 1fr);
  gap: 6px 12px;
  align-items: center;
}
@media (max-width: 980px) {
  .app-shell, .content-grid, .client-viewer-grid { grid-template-columns: 1fr; }
  .sidebar { max-height: none; }
  .topbar, .panel-head { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: 1fr; }
  .form-grid.two, .inline-form { grid-template-columns: 1fr; }
  .client-viewer-header { align-items: flex-start; flex-direction: column; }
  .client-document-summary dl { grid-template-columns: 110px 1fr; }
}
