/* Order Management demo — builds on ../styles.css tokens */

.demo-body { background: var(--ivory); font-size: 15px; }
.demo-top { background: var(--paper); border-bottom: 1px solid var(--line); }
.demo-top-inner { max-width: 1320px; margin: 0 auto; padding: 0 20px; height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.demo-back { display: flex; align-items: center; gap: 12px; text-decoration: none; font-size: 13px; letter-spacing: .08em; color: var(--ink-soft); }
.demo-back img { height: 24px; width: auto; }
.demo-back:hover { color: var(--green); }
.demo-actions { display: flex; gap: 8px; }

.mini {
  font: 500 12px var(--sans); letter-spacing: .08em; padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--green); background: var(--green); color: var(--ivory); cursor: pointer; white-space: nowrap;
}
.mini:hover { background: var(--ink); }
.mini.ghost { background: transparent; color: var(--green); }
.mini.ghost:hover { background: var(--ivory-2); }
.mini.sm { padding: 5px 10px; font-size: 11px; }

.demo-banner { background: var(--green); color: #DDE3D8; font-size: 13px; text-align: center; padding: 10px 20px; }
.demo-banner strong { color: var(--gold); font-weight: 500; }

.demo-wrap { max-width: 1320px; margin: 0 auto; padding: 28px 20px 60px; display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 24px; align-items: start; }
.demo-title { font-size: clamp(32px, 4vw, 44px); font-weight: 400; margin-bottom: .4em; }

.demo-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.demo-tabs button {
  font: 400 13px var(--sans); letter-spacing: .08em; background: none; border: none; padding: 12px 14px; cursor: pointer;
  color: var(--sage); border-bottom: 2px solid transparent; white-space: nowrap;
}
.demo-tabs button[aria-selected="true"] { color: var(--green); border-bottom-color: var(--green); font-weight: 500; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1 1 220px; }
input[type=text], input[type=search], input[type=number], input[type=date], select {
  font: 400 15px var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; min-height: 42px; width: 100%;
}
.toolbar select { width: auto; }
input:focus, select:focus { outline: none; border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(46, 69, 58, .12); }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); cursor: pointer; white-space: nowrap; }

.table-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
.data th { text-align: left; font-weight: 500; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--sage); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data td { padding: 10px 14px; border-bottom: 1px solid #ECEDE6; vertical-align: middle; }
.data tr:last-child td { border-bottom: none; }
.data tr.flash td { animation: flash 1.6s ease; }
.data tr.archived td { color: var(--sage); }
.data td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.data .sub { display: block; font-size: 12px; color: var(--sage); }
.data select.status { width: auto; min-height: 34px; padding: 5px 8px; font-size: 13px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
@keyframes flash { 0% { background: #E2E8DE; } 100% { background: transparent; } }
.empty { color: var(--sage); font-style: italic; padding: 16px 0; }

.form { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 24px; max-width: 620px; }
.field { margin-bottom: 16px; flex: 1; }
.field label { display: block; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 6px; }
.field .opt { text-transform: none; letter-spacing: 0; color: var(--sage); }
.field-row { display: flex; gap: 16px; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; max-width: none; margin-bottom: 16px; padding: 18px; }
.inline-form .field { margin: 0; }

/* Feed */
.feed { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.feed-head { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 500; }
.feed-head .hash { color: var(--sage); margin-right: 2px; }
.feed-sub { font-weight: 300; font-size: 12px; color: var(--sage); margin-left: 6px; }
.feed-list { overflow-y: auto; padding: 8px 0; }
.msg { padding: 10px 16px; font-size: 14px; }
.msg + .msg { border-top: 1px solid #F0F0EA; }
.msg-head { display: flex; gap: 8px; align-items: baseline; }
.msg-bot { font-weight: 500; }
.msg-time { font-size: 11px; color: var(--sage); }
.msg-text { color: var(--ink-soft); margin-top: 2px; }
.msg-text b { color: var(--ink); font-weight: 500; }
.thread { margin: 8px 0 0 4px; padding-left: 12px; border-left: 2px solid var(--sage-soft); }
.thread .reply { font-size: 13px; color: var(--ink-soft); padding: 3px 0; }
.thread .reply .msg-time { margin-left: 6px; }
.thread-count { font-size: 12px; color: var(--green-2); margin-top: 6px; }
.msg.new { animation: flash 1.6s ease; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--ivory); padding: 12px 20px; border-radius: var(--radius); font-size: 14px;
  transition: opacity .3s, transform .3s var(--ease); z-index: 60; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Delivery note */
.note-doc { font-size: 14px; color: var(--ink); clear: both; padding-top: 8px; }
.note-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 2px solid var(--ink); padding-bottom: 16px; margin-bottom: 20px; }
.note-head h2 { font-size: 34px; margin: 0; }
.note-head .meta { text-align: right; font-size: 13px; color: var(--ink-soft); }
.note-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.note-parties h4 { font: 500 11px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--sage); margin: 0 0 4px; }
.note-parties p { margin: 0; color: var(--ink); }
.note-doc table { width: 100%; border-collapse: collapse; margin-bottom: 28px; }
.note-doc th { text-align: left; font: 500 11px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); border-bottom: 1px solid var(--ink); padding: 8px 6px; }
.note-doc td { padding: 10px 6px; border-bottom: 1px solid var(--line); }
.note-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 40px; }
.note-sign div { border-top: 1px solid var(--ink); padding-top: 6px; font-size: 12px; color: var(--ink-soft); }
.note-actions { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }

@media print {
  body.printing > *:not(#note-dialog) { display: none !important; }
  body.printing #note-dialog { position: static; box-shadow: none; width: 100%; max-height: none; }
  body.printing .case-close, body.printing .note-actions { display: none !important; }
}

@media (max-width: 960px) {
  .demo-wrap { grid-template-columns: minmax(0, 1fr); }
  .feed { position: static; max-height: 420px; }
}
@media (max-width: 640px) {
  .field-row, .inline-form { flex-direction: column; align-items: stretch; }
  .note-parties { grid-template-columns: 1fr; }
  #tab-orders .data th:nth-child(5), #tab-orders .data td:nth-child(5),
  #tab-notes .data th:nth-child(4), #tab-notes .data td:nth-child(4) { display: none; }
  .demo-back span { display: none; }
}
