/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  background: #f4f6f9;
  color: #222;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ===== Top Navigation ===== */
.topnav {
  background: #1a3a5c;
  color: #fff;
  height: 50px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 24px;
  flex-shrink: 0;
  z-index: 10;
}

.topnav-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-badge {
  background: #2a9d8f;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 3px;
}

.app-name {
  font-size: 14px;
  font-weight: 500;
  opacity: 0.9;
  white-space: nowrap;
}

.topnav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.topnav-links a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.topnav-links a:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  padding: 4px;
  position: relative;
  display: flex;
  align-items: center;
}

.icon-btn .badge {
  position: absolute;
  top: -2px;
  right: -4px;
  background: #e74c3c;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
}

.avatar-chip {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

/* ===== Layout ===== */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 200px;
  background: #1e4068;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 16px 0;
}

.sidebar-section-label {
  color: rgba(255,255,255,0.4);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 16px 8px;
}

.sidebar-link {
  display: block;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  padding: 8px 16px;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.sidebar-link.active {
  background: rgba(42,157,143,0.25);
  color: #fff;
  border-left: 3px solid #2a9d8f;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* ===== Policy Header Band ===== */
.policy-header {
  background: #fff;
  border-bottom: 1px solid #dde2e8;
  padding: 14px 24px;
}

.policy-header-fields {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  align-items: center;
}

.policy-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.field-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7a8d;
}

.field-value {
  font-size: 13px;
  font-weight: 500;
  color: #1a2a3a;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
}

.status-badge.in-force {
  background: #e6f7f2;
  color: #1a7a5a;
  border: 1px solid #b3e6d4;
}

/* ===== Action Toolbar ===== */
.action-toolbar {
  background: #fff;
  border-bottom: 1px solid #dde2e8;
  padding: 10px 24px;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: #1a3a5c;
  color: #fff;
  border-color: #1a3a5c;
}

.btn-primary:hover { background: #122c47; border-color: #122c47; }

.btn-secondary {
  background: #fff;
  color: #1a3a5c;
  border-color: #c5cdd8;
}

.btn-secondary:hover { background: #f0f4f8; }

.btn-outline {
  background: transparent;
  color: #1a3a5c;
  border-color: #b0bac8;
  font-size: 12px;
}

.btn-outline:hover { background: #edf1f7; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.process-doc-btn {
  margin-left: auto;
  padding: 7px 18px;
}

/* ===== Tab Bar ===== */
.tab-bar {
  background: #fff;
  border-bottom: 2px solid #dde2e8;
  padding: 0 24px;
  display: flex;
  gap: 0;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 10px 16px;
  font-size: 13px;
  color: #6b7a8d;
  cursor: pointer;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: #1a3a5c; }

.tab.active {
  color: #1a3a5c;
  border-bottom-color: #2a9d8f;
  font-weight: 600;
}

/* ===== Tab Content ===== */
.tab-content {
  flex: 1;
  padding: 20px 24px;
}

.tab-panel { display: block; }
.tab-panel.hidden { display: none; }

.placeholder-text {
  color: #8a9bb0;
  font-style: italic;
}

/* ===== Documents Table ===== */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

.doc-table th {
  background: #f0f4f8;
  color: #4a5a6b;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #dde2e8;
}

.doc-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #edf1f7;
  color: #2a3a4a;
  font-size: 13px;
}

.doc-table tr:last-child td { border-bottom: none; }
.doc-table tr:hover td { background: #f8fafc; }

.doc-icon { margin-right: 4px; }

/* ===== Demo Config ===== */
.demo-config {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 100;
}

.demo-config-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #c5cdd8;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  color: #4a5a6b;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  transition: background 0.15s;
}

.demo-config-toggle:hover { background: #f0f4f8; }

.demo-config-panel {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid #c5cdd8;
  border-radius: 6px;
  padding: 14px 16px;
  margin-top: 6px;
  width: 380px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.demo-config-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #4a5a6b;
  margin-bottom: 10px;
}

.config-field {
  margin-bottom: 10px;
}

.config-field:last-child {
  margin-bottom: 0;
}

.config-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #3a4a5a;
  margin-bottom: 5px;
}

.config-input,
.config-select,
.config-textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #c5cdd8;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  color: #1a2a3a;
  outline: none;
  transition: border-color 0.15s;
}

.config-input:focus,
.config-select:focus,
.config-textarea:focus {
  border-color: #2a9d8f;
}

.config-textarea {
  resize: vertical;
}

.config-radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.config-radio-row:last-child {
  margin-bottom: 0;
}

.config-radio-row input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #2a9d8f;
}

.config-radio-row label {
  font-size: 12px;
  font-weight: 600;
  color: #3a4a5a;
  cursor: pointer;
}

.config-hint {
  font-size: 11px;
  color: #8a9bb0;
  margin-top: 6px;
  line-height: 1.4;
}

.config-error {
  color: #c0392b;
  font-size: 11px;
  margin-top: 4px;
  line-height: 1.4;
}

/* ===== Drawer Backdrop ===== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10,20,40,0.45);
  z-index: 200;
  transition: opacity 0.25s;
}

/* ===== Drawer ===== */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 66vw;
  height: 100vh;
  background: #fff;
  z-index: 201;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  background: #1e3350;
  color: #fff;
  padding: 0 20px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.drawer-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.drawer-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 3px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.drawer-close:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.drawer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ===== Spinner ===== */
.drawer-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #fff;
  color: #6b7a8d;
  font-size: 13px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e0e6ee;
  border-top-color: #2a9d8f;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#sortspoke-iframe {
  flex: 1;
  width: 100%;
}

/* ===== Placeholder ===== */
.drawer-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  color: #8a9bb0;
  font-size: 14px;
  line-height: 1.6;
  background: #f8fafc;
}

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.toast {
  background: #1a3a5c;
  color: #fff;
  padding: 11px 16px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  animation: toastIn 0.2s ease-out;
}

.toast.toast-success { background: #1a6b4a; }
.toast.toast-info    { background: #1a3a5c; }
.toast.toast-error   { background: #c0392b; }

.toast-icon { font-size: 15px; flex-shrink: 0; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}
