/*
 * Lailara Design System — EDI Reconciliation Dashboard
 * Tokens from LAILARA_DESIGN_SYSTEM.md v2.0
 *
 * Fonts: Playfair Display (serif) + Source Sans 3 (sans).
 * Place woff2 files in /static/fonts/ for production.
 * @font-face declarations below point to that path.
 */

/* --------------------------------------------------------------------------
 * Web fonts (self-hosted; place woff2 files in dashboard/static/fonts/)
 * -------------------------------------------------------------------------- */
@font-face {
  font-family: 'Playfair Display';
  src: url('/static/fonts/PlayfairDisplay-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Playfair Display';
  src: url('/static/fonts/PlayfairDisplay-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Source Sans 3';
  src: url('/static/fonts/SourceSans3-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Source Sans 3';
  src: url('/static/fonts/SourceSans3-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Source Sans 3';
  src: url('/static/fonts/SourceSans3-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

/* --------------------------------------------------------------------------
 * Design tokens
 * -------------------------------------------------------------------------- */
:root {
  /* Canvas */
  --canvas:          #f5f3ee;

  /* London greyscale */
  --ink:             #0d0d0d;   /* London-5 */
  --text-primary:    #333333;   /* London-20 */
  --text-secondary:  #595959;   /* London-35 */
  --reference:       #666666;   /* London-40 */
  --border:          #d9d9d9;   /* London-85 */
  --surface:         #f2f2f2;   /* London-95 */
  --disabled:        #b3b3b3;   /* London-70 */
  --card-bg:         #1a1a1a;   /* London-10 */

  /* Chicago (accent blue) */
  --navy:            #1f2e7a;   /* Chicago-20 */
  --navy-hover:      #141e52;   /* Chicago-10 */
  --navy-light:      #8e9ad0;   /* Chicago-70 */
  --navy-surface:    #e8eaf4;   /* Chicago-95 */

  /* Brand red — text and 1px rules only */
  --red:             #cc100a;   /* Red-42 */

  /* Hong Kong (teal — matched / positive) */
  --teal:            #158f75;   /* HK-35 */
  --teal-light:      #6dcdb5;   /* HK-70 */
  --teal-surface:    #e4f5f0;   /* HK-95 */
  --teal-text:       #0e6e5a;   /* HK-25 */

  /* Tokyo (berry/rose — risk / exceptions) */
  --rose:            #b82d4a;   /* Tokyo-40 */
  --rose-light:      #e68a9a;   /* Tokyo-70 */
  --rose-surface:    #fbe9ed;   /* Tokyo-95 */
  --rose-text:       #7a0906;   /* Red-18 */

  /* Singapore (orange — warning / expiring dispute) */
  --orange:          #ee8a2a;   /* Singapore-55 */
  --orange-light:    #f6b97c;   /* Singapore-70 */
  --orange-surface:  #fdeee0;   /* Singapore-95 */
  --orange-text:     #7a3d10;   /* Singapore-20 */

  /* Typography */
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --sans:  'Source Sans 3', 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;

  /* Layout */
  --content-max: 900px;
  --section-gap: 60px;
}

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

html { font-size: 16px; }

body {
  background-color: var(--canvas);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--navy-hover); text-decoration: underline; }

/* --------------------------------------------------------------------------
 * Layout
 * -------------------------------------------------------------------------- */
.page-wrapper {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 48px 24px;
}

@media (max-width: 640px) {
  .page-wrapper { padding: 32px 16px; }
}

.section { margin-bottom: var(--section-gap); }

/* --------------------------------------------------------------------------
 * Navigation
 * -------------------------------------------------------------------------- */
.site-nav {
  border-bottom: 1px solid var(--border);
  padding: 16px 0 14px;
  margin-bottom: 40px;
  display: flex;
  align-items: baseline;
  gap: 32px;
}

.site-nav__brand {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.site-nav__brand span {
  color: var(--red);
}

.site-nav__links {
  display: flex;
  gap: 20px;
  list-style: none;
}

.site-nav__links a {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.site-nav__links a:hover,
.site-nav__links a.active {
  color: var(--navy);
  text-decoration: none;
}

/* --------------------------------------------------------------------------
 * Page header
 * -------------------------------------------------------------------------- */
.page-header {
  margin-bottom: 40px;
  border-left: 3px solid var(--red);
  padding-left: 16px;
}

.page-header__eyebrow {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--red);
  margin-bottom: 6px;
}

.page-header__title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 6px;
}

.page-header__sub {
  font-size: 15px;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
 * Summary cards (dollar-ranked exception classes)
 * -------------------------------------------------------------------------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.exception-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 18px 20px;
  position: relative;
}

.exception-card--urgent {
  border-left: 3px solid var(--orange);
}

.exception-card__class {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.exception-card__amount {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--rose);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 4px;
}

.exception-card__amount--zero {
  color: var(--text-secondary);
}

.exception-card__count {
  font-size: 13px;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
 * Filter bar
 * -------------------------------------------------------------------------- */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--surface);
  border-radius: 2px;
}

.filter-bar label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-bar select,
.filter-bar input {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 6px 10px;
  outline: none;
}

.filter-bar select:focus,
.filter-bar input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 2px var(--navy-surface);
}

.btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 2px;
  padding: 7px 16px;
  cursor: pointer;
}

.btn:hover { background: var(--navy-hover); }

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  background: var(--surface);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
 * Exception table
 * -------------------------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 2px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--canvas); }

tbody td {
  padding: 10px 14px;
  vertical-align: top;
  color: var(--text-primary);
}

.td--dollar {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--rose);
  text-align: right;
  white-space: nowrap;
}

.td--zero {
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
 * Exception class chips
 * -------------------------------------------------------------------------- */
.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 2px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.chip--ordered_not_asnd   { background: var(--rose-surface);   color: var(--rose-text); }
.chip--shipped_not_invoiced { background: var(--rose-surface);  color: var(--rose-text); }
.chip--short_pay          { background: var(--rose-surface);   color: var(--rose-text); }
.chip--uom_mismatch       { background: var(--orange-surface); color: var(--orange-text); }
.chip--qty_mismatch       { background: var(--orange-surface); color: var(--orange-text); }
.chip--852_discrepancy    { background: var(--navy-surface);   color: var(--navy); }
.chip--missing_997_ack    { background: var(--surface);        color: var(--text-secondary); }

/* --------------------------------------------------------------------------
 * Dispute urgency indicator
 * -------------------------------------------------------------------------- */
.urgent-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: var(--orange-surface);
  color: var(--orange-text);
  border: 1px solid var(--orange-light);
  padding: 1px 6px;
  border-radius: 2px;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
 * Partner badge
 * -------------------------------------------------------------------------- */
.partner-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 2px;
  background: var(--navy-surface);
  color: var(--navy);
}

/* --------------------------------------------------------------------------
 * 997 section (EDI/Ops secondary layer)
 * -------------------------------------------------------------------------- */
.ops-section {
  margin-top: 48px;
  border-top: 2px solid var(--border);
  padding-top: 32px;
}

.ops-section__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.ops-section__title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}

.ops-section__sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ACK status chips */
.ack-chip--no_ack           { background: var(--rose-surface);   color: var(--rose-text); }
.ack-chip--rejected         { background: var(--rose-surface);   color: var(--rose-text); }
.ack-chip--accepted_with_errors { background: var(--orange-surface); color: var(--orange-text); }
.ack-chip--accepted         { background: var(--teal-surface);   color: var(--teal-text); }

/* --------------------------------------------------------------------------
 * Empty state
 * -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state__icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.empty-state__title {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state__note {
  font-size: 14px;
}

/* --------------------------------------------------------------------------
 * HTMX loading indicator
 * -------------------------------------------------------------------------- */
.htmx-indicator {
  display: none;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 0;
}

.htmx-request .htmx-indicator { display: inline; }
.htmx-request.htmx-indicator  { display: inline; }

/* --------------------------------------------------------------------------
 * Section divider
 * -------------------------------------------------------------------------- */
.section-rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* --------------------------------------------------------------------------
 * Footer
 * -------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0 8px;
  margin-top: 80px;
  font-size: 13px;
  color: var(--text-secondary);
}

.site-footer a { color: var(--text-secondary); }
.site-footer a:hover { color: var(--text-primary); }

/* --------------------------------------------------------------------------
 * Chip modifiers (semantic — used by catalog and chips elsewhere)
 * -------------------------------------------------------------------------- */
.chip--warn {
  background: var(--orange-surface);
  color: var(--orange-text);
  text-transform: none;
}

.chip--info {
  background: var(--navy-surface);
  color: var(--navy);
  text-transform: none;
}

/* --------------------------------------------------------------------------
 * Section title (catalog + any section heading)
 * -------------------------------------------------------------------------- */
.section-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 24px;
}

/* --------------------------------------------------------------------------
 * Failure pattern catalog cards
 * -------------------------------------------------------------------------- */
.pattern-card {
  border-left: 3px solid var(--rose);
  background: #fff;
  border: 1px solid var(--border);
  border-left: 3px solid var(--rose);
  border-radius: 2px;
  padding: 24px;
  margin-bottom: 20px;
}

.pattern-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pattern-card__label {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  display: block;
  margin-bottom: 4px;
}

.pattern-card__key {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 2px;
  font-family: 'Courier New', Courier, monospace;
}

.pattern-card__meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.pattern-card__short {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.55;
  margin: 0 0 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.pattern-card__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .pattern-card__body { grid-template-columns: 1fr; }
}

.pattern-card__col {}

.pattern-card__row-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.pattern-card__text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.55;
  margin: 0;
}

.pattern-card__formula {
  display: inline-block;
  font-size: 13px;
  color: var(--navy);
  background: var(--navy-surface);
  padding: 4px 10px;
  border-radius: 2px;
  font-family: 'Courier New', Courier, monospace;
}

.pattern-card__partner-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.pattern-card__partner-list li {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.pattern-card__partner-list li:last-child { border-bottom: none; }

.pattern-card__example {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.pattern-card__pre {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface);
  padding: 12px 16px;
  border-radius: 2px;
  margin: 6px 0 0;
  white-space: pre-wrap;
  line-height: 1.55;
}

/* --------------------------------------------------------------------------
 * Section title
 * -------------------------------------------------------------------------- */
.section-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 24px;
}

/* --------------------------------------------------------------------------
 * Generic chip variants (catalog page)
 * -------------------------------------------------------------------------- */
.chip--warn { background: var(--orange-surface); color: var(--orange-text); }
.chip--info { background: var(--navy-surface);   color: var(--navy); }

/* --------------------------------------------------------------------------
 * Failure pattern cards (catalog page)
 * -------------------------------------------------------------------------- */
.pattern-card {
  border-left: 3px solid var(--rose);
  background: #fff;
  border-radius: 0 2px 2px 0;
  padding: 24px 28px;
  margin-bottom: 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.pattern-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.pattern-card__label {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-right: 10px;
}

.pattern-card__key {
  font-size: 12px;
  background: var(--surface);
  color: var(--text-secondary);
  padding: 2px 7px;
  border-radius: 2px;
  vertical-align: middle;
}

.pattern-card__meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pattern-card__short {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.pattern-card__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .pattern-card__body { grid-template-columns: 1fr; }
}

.pattern-card__row-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.pattern-card__text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.pattern-card__formula {
  display: block;
  font-size: 13px;
  background: var(--surface);
  padding: 6px 10px;
  border-radius: 2px;
  color: var(--text-primary);
}

.pattern-card__partner-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
}

.pattern-card__partner-list li + li {
  border-top: 1px solid var(--border);
  padding-top: 4px;
  margin-top: 4px;
}

.pattern-card__example {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.pattern-card__pre {
  font-size: 12.5px;
  background: var(--surface);
  border-radius: 2px;
  padding: 12px 14px;
  overflow-x: auto;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre;
}
