/* ============================================
   SIGNAL DESK — Print Shop Dashboard
   Design tokens + all styles
   ============================================ */

:root {
  /* --- Palette --- */
  --bg:          #FAF7F2;
  --surface:     #FFFFFF;
  --text:        #1A1A1A;
  --text-muted:  #6B6560;
  --text-faint:  #A09890;
  --accent:      #1B4965;
  --accent-light:#E8F0F5;
  --accent-dark: #13344A;
  --terracotta:  #D4622A;
  --terracotta-light: #FBF0EB;
  --green:       #2D7A4F;
  --green-light: #E8F5EE;
  --amber:       #B8860B;
  --amber-light: #FDF6E3;
  --red:         #B33A3A;
  --red-light:   #FDECEC;
  --border:      #E8E2DA;
  --border-light:#F0ECE6;

  /* --- Typography --- */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body:    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono:    "SF Mono", Menlo, Consolas, monospace;

  --fs-xs:   0.75rem;
  --fs-sm:   0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md:   1.0625rem;
  --fs-lg:   1.375rem;
  --fs-xl:   1.75rem;
  --fs-2xl:  2.25rem;

  --fw-normal: 400;
  --fw-medium: 500;
  --fw-bold:   700;

  /* --- Spacing --- */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  /* --- Radii --- */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  /* --- Motion --- */
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 500ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* --- Breakpoints --- */
  --bp-sm: 40rem;
  --bp-md: 56rem;
  --bp-lg: 72rem;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: var(--fw-normal);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.2;
}

/* ============================================
   Registration Marks (signature element)
   ============================================ */
.reg-mark {
  position: fixed;
  width: 24px;
  height: 24px;
  z-index: 100;
  pointer-events: none;
  opacity: 0.18;
}

.reg-mark::before,
.reg-mark::after {
  content: '';
  position: absolute;
  background: var(--accent);
}

.reg-mark::before {
  width: 1px;
  height: 24px;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}

.reg-mark::after {
  width: 24px;
  height: 1px;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

.reg-mark--tl { top: 12px; left: 12px; }
.reg-mark--tr { top: 12px; right: 12px; }
.reg-mark--bl { bottom: 12px; left: 12px; }
.reg-mark--br { bottom: 12px; right: 12px; }

@media (min-width: 56rem) {
  .reg-mark { width: 32px; height: 32px; }
  .reg-mark::before { height: 32px; }
  .reg-mark::after  { width: 32px; }
  .reg-mark--tl { top: 20px; left: 20px; }
  .reg-mark--tr { top: 20px; right: 20px; }
  .reg-mark--bl { bottom: 20px; left: 20px; }
  .reg-mark--br { bottom: 20px; right: 20px; }
}

/* ============================================
   Header
   ============================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
  gap: var(--sp-4);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.header__logo {
  flex-shrink: 0;
}

.header__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--accent-dark);
  letter-spacing: -0.02em;
}

.header__subtitle {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: var(--fw-medium);
}

.header__time {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.header__date {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
}

.header__clock {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  color: var(--accent);
  font-weight: var(--fw-bold);
}

/* ============================================
   Dashboard Layout
   ============================================ */
.dashboard {
  max-width: var(--bp-lg);
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

/* ============================================
   KPI Cards
   ============================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-5);
}

@media (min-width: 40rem) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 56rem) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-6);
  display: flex;
  gap: var(--sp-4);
  align-items: flex-start;
  transition: border-color var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  border-radius: 3px 0 0 3px;
}

.kpi-card--orders::before  { background: var(--accent); }
.kpi-card--revenue::before { background: var(--green); }
.kpi-card--machines::before { background: var(--terracotta); }
.kpi-card--pending::before { background: var(--amber); }

.kpi-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(27, 73, 101, 0.08);
}

.kpi-card__icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-card--orders .kpi-card__icon  { background: var(--accent-light); color: var(--accent); }
.kpi-card--revenue .kpi-card__icon { background: var(--green-light); color: var(--green); }
.kpi-card--machines .kpi-card__icon { background: var(--terracotta-light); color: var(--terracotta); }
.kpi-card--pending .kpi-card__icon { background: var(--amber-light); color: var(--amber); }

.kpi-card__body {
  min-width: 0;
}

.kpi-card__label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
  margin-bottom: var(--sp-1);
}

.kpi-card__value {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.kpi-card__change {
  font-size: var(--fs-xs);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-top: var(--sp-2);
  font-weight: var(--fw-medium);
}

.kpi-card__change--up   { color: var(--green); }
.kpi-card__change--down { color: var(--green); }
.kpi-card__change--idle { color: var(--text-muted); }

/* ============================================
   Chart Section
   ============================================ */
.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-8);
  overflow: hidden;
}

.chart-section__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
  gap: var(--sp-4);
}

.chart-section__title {
  font-size: var(--fs-lg);
  color: var(--text);
}

.chart-section__subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

.chart-legend {
  display: flex;
  gap: var(--sp-5);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.chart-legend__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.chart-legend__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.chart-legend__dot--revenue { background: var(--accent); }
.chart-legend__dot--orders  { background: var(--terracotta); opacity: 0.45; }

.chart-container {
  width: 100%;
  aspect-ratio: 16 / 7;
  min-height: 220px;
  max-height: 360px;
  position: relative;
}

.chart-container canvas {
  width: 100%;
  height: 100%;
  display: block;
}

@media (max-width: 40rem) {
  .chart-section { padding: var(--sp-5); }
  .chart-container {
    aspect-ratio: 4 / 3;
    min-height: 200px;
  }
}

/* ============================================
   Orders Table
   ============================================ */
.orders-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.orders-section__header {
  padding: var(--sp-6) var(--sp-8) var(--sp-4);
}

.orders-section__title {
  font-size: var(--fs-lg);
  color: var(--text);
}

.orders-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  min-width: 580px;
}

.orders-table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: var(--fs-xs);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
}

.orders-table td {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.orders-table tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}

.orders-table tbody tr:hover {
  background: var(--accent-light);
}

.orders-table tbody tr:last-child td {
  border-bottom: none;
}

.order-id {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--accent);
  font-weight: var(--fw-medium);
}

.client-name {
  font-weight: var(--fw-medium);
  color: var(--text);
}

.job-type {
  color: var(--text-muted);
}

.job-qty {
  font-family: var(--font-mono);
  text-align: right;
}

.job-value {
  font-family: var(--font-mono);
  font-weight: var(--fw-medium);
  text-align: right;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.status-badge--printing {
  background: var(--accent-light);
  color: var(--accent);
}

.status-badge--queued {
  background: var(--amber-light);
  color: var(--amber);
}

.status-badge--ready {
  background: var(--green-light);
  color: var(--green);
}

.status-badge--delivered {
  background: var(--green-light);
  color: var(--green);
}

.status-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge--printing .status-badge__dot {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

@media (max-width: 40rem) {
  .orders-section__header { padding: var(--sp-4) var(--sp-5) var(--sp-3); }
  .orders-table th,
  .orders-table td { padding: var(--sp-3); }
}

/* ============================================
   Footer
   ============================================ */
.footer {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  font-size: var(--fs-xs);
  color: var(--text-faint);
  border-top: 1px solid var(--border-light);
}

/* ============================================
   Entry animations
   ============================================ */
.kpi-card,
.chart-section,
.orders-section {
  opacity: 0;
  transform: translateY(16px);
  animation: fadeUp var(--dur-slow) var(--ease-out) forwards;
}

.kpi-card:nth-child(1) { animation-delay: 0ms; }
.kpi-card:nth-child(2) { animation-delay: 80ms; }
.kpi-card:nth-child(3) { animation-delay: 160ms; }
.kpi-card:nth-child(4) { animation-delay: 240ms; }
.chart-section         { animation-delay: 320ms; }
.orders-section        { animation-delay: 420ms; }

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Focus-visible for keyboard navigation
   ============================================ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================
   Print-friendly: hide decorative marks
   ============================================ */
@media print {
  .reg-mark { display: none; }
  .kpi-card,
  .chart-section,
  .orders-section {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
