/* AwardCert - 3-Mode Theme & Layout (Rule 0-C Compliant) */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html.theme-light {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-sub: #64748b;
  --gold-main: #b8860b;
  --gold-bg: #fffbeb;
  --gold-border: #f59e0b;
  --gold-grad: linear-gradient(135deg, #e5b842 0%, #b8860b 100%);
  --uam-bg: #ffffff;
  --uam-fg: #0f172a;
  --uam-muted: #64748b;
  --uam-border: #e2e8f0;
  --uam-btn-bg: #fffbeb;
  --uam-btn-fg: #b8860b;
  --uam-chip-bg: #fffbeb;
  --uam-chip-fg: #92400e;
  --uam-hover: rgba(184, 134, 11, 0.08);
  --uam-badge-ring: #ffffff;
  --uam-focus: #b8860b;
}

html.theme-dark {
  --bg-page: #18181b;
  --bg-surface: #27272a;
  --bg-card: #27272a;
  --bg-subtle: #3f3f46;
  --border-color: #3f3f46;
  --text-main: #f4f4f5;
  --text-sub: #a1a1aa;
  --gold-main: #d4b86a;
  --gold-bg: #26231d;
  --gold-border: #a68b44;
  --gold-grad: linear-gradient(135deg, #d8bc6a 0%, #b5923c 100%);
  --uam-bg: #27272a;
  --uam-fg: #f4f4f5;
  --uam-muted: #a1a1aa;
  --uam-border: #3f3f46;
  --uam-btn-bg: #26231d;
  --uam-btn-fg: #d4b86a;
  --uam-chip-bg: #26231d;
  --uam-chip-fg: #d4b86a;
  --uam-hover: rgba(212, 184, 106, 0.12);
  --uam-badge-ring: #27272a;
  --uam-focus: #d4b86a;
}

html.theme-oled {
  --bg-page: #000000;
  --bg-surface: #09090b;
  --bg-card: #121212;
  --bg-subtle: #1c1c1e;
  --border-color: #27272a;
  --text-main: #f4f4f5;
  --text-sub: #a1a1aa;
  --gold-main: #d9be6c;
  --gold-bg: #171510;
  --gold-border: #9e843c;
  --gold-grad: linear-gradient(135deg, #d8bc6a 0%, #b3923e 100%);
  --uam-bg: #121212;
  --uam-fg: #f4f4f5;
  --uam-muted: #a1a1aa;
  --uam-border: #27272a;
  --uam-btn-bg: #171510;
  --uam-btn-fg: #d9be6c;
  --uam-chip-bg: #171510;
  --uam-chip-fg: #d9be6c;
  --uam-hover: rgba(217, 190, 108, 0.12);
  --uam-badge-ring: #09090b;
  --uam-focus: #d9be6c;
}

html, body {
  min-height: 100%;
  background: var(--bg-page);
  color: var(--text-main);
  font-family: "M PLUS 1", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button, input, textarea {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
}

.hidden {
  display: none !important;
}

html.ssop-auth-pending #demoStatusBanner {
  display: none !important;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1460px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gold-bg);
  border: 1px solid var(--gold-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-main);
  flex-shrink: 0;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-sub);
  white-space: nowrap;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-sub);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-tab .material-symbols-outlined {
  font-size: 18px;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  background: var(--gold-bg);
  color: var(--gold-main);
  border: 1px solid var(--gold-border);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}

.icon-pill-btn:hover:not(:disabled) {
  border-color: var(--gold-border);
  color: var(--gold-main);
}

.icon-pill-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.icon-pill-btn .material-symbols-outlined {
  font-size: 18px;
}

.ssop-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-sub);
  white-space: nowrap;
}

.ssop-pill.is-full {
  background: var(--gold-bg);
  border-color: var(--gold-border);
  color: var(--gold-main);
}

.ssop-pill.is-readonly {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.5);
  color: #f59e0b;
}

.ssop-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* Banners */
.status-banner {
  max-width: 1460px;
  margin: 12px auto 0;
  padding: 0 16px;
}

.banner-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--gold-border);
  background: var(--gold-bg);
  font-size: 13px;
}

.banner-card.impersonate-banner {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.14);
}

.banner-card.readonly-banner {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

.banner-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.gold-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 10px;
  background: var(--gold-grad);
  color: #111111;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.gold-btn:hover:not(:disabled) {
  filter: brightness(1.06);
}

.gold-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.gold-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ghost-btn:hover:not(:disabled) {
  border-color: var(--gold-border);
  color: var(--gold-main);
}

.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  font-size: 12px;
  font-weight: 700;
}

.danger-btn:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.22);
}

/* Main Shell */
.main-container {
  max-width: 1460px;
  margin: 0 auto;
  padding: 16px;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(360px, 470px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.editor-sidebar-scroll {
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding-right: 4px;
}

.editor-sidebar-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 800;
  color: var(--gold-main);
  margin-bottom: 10px;
}

.panel-title .material-symbols-outlined {
  font-size: 18px;
}

.field-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.text-input, .text-area {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.text-input:focus, .text-area:focus {
  border-color: var(--gold-border);
}

.text-area {
  resize: vertical;
  min-height: 112px;
  line-height: 1.55;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Rule 101 Mutual Consistency Notice */
.consistency-banner {
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--gold-border);
  background: var(--gold-bg);
  color: var(--gold-main);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* Custom Monday-First Award Date Picker */
.date-acc-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-top: 8px;
}

.date-dow-hdr {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-sub);
  padding: 4px 0;
}

.date-dow-hdr.is-sat { color: #60a5fa; }
.date-dow-hdr.is-sun { color: #f87171; }

.date-day-btn {
  padding: 7px 2px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.date-day-btn:hover {
  border-color: var(--gold-border);
}

.date-day-btn.selected {
  background: var(--gold-bg);
  border-color: var(--gold-border);
  color: var(--gold-main);
}

/* Range Sliders */
.range-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.range-input {
  width: 100%;
  accent-color: var(--gold-main);
}

/* Dropzone */
.dropzone {
  border: 1.5px dashed var(--border-color);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.dropzone:hover {
  border-color: var(--gold-border);
  color: var(--gold-main);
}

/* Preview Stage */
.preview-sticky {
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 10px 14px;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.canvas-stage {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  overflow: auto;
}

.cert-canvas {
  max-width: 100%;
  max-height: 72vh;
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.45);
  background: #ffffff;
}

/* Batch View */
.batch-layout {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.batch-list-scroll {
  max-height: 440px;
  overflow-y: auto;
  margin-top: 10px;
}

.batch-list-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.batch-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  text-align: left;
  width: 100%;
}

.batch-item-card.active {
  border-color: var(--gold-border);
  background: var(--gold-bg);
}

/* Saved History View (Rule 17 compliant wrapper) */
.saved-grid-scroll {
  margin-top: 14px;
}

.saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.saved-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.saved-thumb {
  width: 100%;
  aspect-ratio: 1.414 / 1;
  object-fit: contain;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.saved-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.badge-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--gold-border);
  background: var(--gold-bg);
  color: var(--gold-main);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--gold-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dow-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.dow-chip {
  padding: 9px 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.dow-chip.selected {
  background: var(--gold-bg);
  border-color: var(--gold-border);
  color: var(--gold-main);
}

.preview-iframe {
  width: 100%;
  height: 220px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #ffffff;
}

/* Neutral Pending Overlay (Rule 87) */
.ssop-pending-overlay {
  position: fixed;
  inset: 0;
  z-index: 9800;
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Toast */
.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}

.toast-item {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Print Container */
#printSheetContainer {
  display: none;
}

@media print {
  body > *:not(#printSheetContainer) {
    display: none !important;
  }
  #printSheetContainer {
    display: block !important;
  }
  .print-page-item {
    page-break-after: always;
    break-after: page;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .print-page-item:last-child {
    page-break-after: auto;
    break-after: auto;
  }
  .print-page-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
}

@media (max-width: 1020px) {
  .editor-layout, .batch-layout {
    grid-template-columns: 1fr;
  }
  .editor-sidebar-scroll {
    max-height: none;
  }
  .preview-sticky {
    position: static;
  }
}
