/* Dashboard shortcuts */
.service-shortcuts {
  display: grid;
  gap: .9rem;
}
.service-shortcuts > h1 { margin: 0; }
.service-shortcuts-head {
  display: flex;
  gap: .75rem;
  align-items: baseline;
  justify-content: space-between;
}
.service-shortcuts-head h2 { margin: 0; }
.service-shortcut-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
}
.service-shortcut {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr);
  gap: .7rem;
  align-items: center;
  min-height: 4.6rem;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: var(--row-stripe);
  color: var(--text);
  text-decoration: none;
}
.service-shortcut:hover,
.service-shortcut:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}
.service-shortcut-mark {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: .65rem;
  color: #fff;
  font-size: .9rem;
  font-weight: 850;
}
.service-shortcut strong,
.service-shortcut small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}
.service-shortcut strong { line-height: 1.25; }
.service-shortcut small {
  margin-top: .2rem;
  font-size: .9rem;
}
.service-shortcut-files .service-shortcut-mark { background: #087443; }
.service-shortcut-chat .service-shortcut-mark { background: #155eef; }
.service-shortcut-ai-chat .service-shortcut-mark { background: #7f56d9; }
.service-shortcut-ai-bot .service-shortcut-mark { background: #b42318; }

@media (max-width: 980px) {
  .service-shortcut-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .service-shortcuts-head {
    display: grid;
    gap: .2rem;
  }
  .service-shortcut-grid { grid-template-columns: 1fr; }
}

/* Production: pending table + drag affordance */
.pending-table th,
.pending-table td { white-space: nowrap; }
.pending-table tr.dragging { opacity: .45; }
.pending-table tr[draggable="true"] { cursor: move; }
.pending-table tr[draggable="true"] td:first-child::before {
  content: "≡ ";
  color: var(--primary);
  font-weight: 700;
  margin-right: .25rem;
}

/* Production: pending queue cards + currently running */
.queue {
  display: grid;
  gap: .6rem;
  padding-left: 1.4rem;
}
.queue li {
  background: var(--row-stripe);
  border: 1px solid var(--line);
  border-radius: .8rem;
  padding: .8rem;
}
.queue li.dragging { opacity: .45; }
.queue span {
  display: block;
  color: var(--muted);
  margin-top: .2rem;
}

.running {
  border: 2px solid var(--primary);
  border-radius: 1rem;
  padding: 1rem;
  background: color-mix(in srgb, var(--primary) 10%, var(--card));
}
.running strong { font-size: 1.3rem; }
.running span { display: block; margin-top: .25rem; }

/* Orders table */
.order-table { table-layout: fixed; }
.order-table th,
.order-table td { padding: .75rem .7rem; }
.order-table input,
.order-table select { width: 100%; min-width: 0; padding: .55rem .5rem; }
.order-table .order-supplier     { width: 18%; }
.order-table .order-line-summary { width: 11%; }
.order-table .order-date         { width: 15%; }
.order-table .order-total        { width: 15%; }
.order-table .order-status       { width: 10%; }
.order-table .order-actions      { width: 31%; }
.order-table .action-cell {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: flex-start;
  white-space: normal;
}
.order-table .action-cell form { margin: 0; }
.order-table .status-cell { white-space: nowrap; }
.order-table .action-cell button { padding: .55rem .75rem; min-height: 40px; }

.order-details td { background: var(--row-detail); }
.order-details .action-cell {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  white-space: normal;
}
.order-details .action-cell form { margin: 0; }

.order-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
  align-items: start;
}
.order-detail-grid div { display: grid; gap: .35rem; }
.order-detail-grid strong { font-size: .9rem; color: var(--muted); }
.order-detail-grid > div > span {
  min-height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  padding: .65rem;
  background: var(--input-bg);
}

.order-audit ol { margin: 0; padding-left: 1.25rem; }
.order-audit li { margin: .35rem 0; }
.order-audit li span {
  display: block;
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: .95rem;
}

.order-lines-control { display: grid; gap: .55rem; }
.order-lines-add { justify-self: start; }
.order-lines-edit { table-layout: fixed; }
.order-lines-edit th,
.order-lines-edit td { min-width: 0; }
.order-lines-edit input,
.order-lines-edit select { width: 100%; min-width: 0; padding: .55rem .5rem; }
.order-lines-edit .line-product { width: 26%; }
.order-lines-edit .line-qty     { width: 18%; }
.order-lines-edit .line-price   { width: 22%; }
.order-lines-edit .line-memo    { width: 25%; }
.order-lines-edit .line-remove  { width: 9%; }
.order-lines-edit .line-action  { width: 1%; white-space: nowrap; }
.order-lines-edit .line-action button { padding: .55rem .75rem; }
.order-lines-edit [data-order-line-remove]:disabled { visibility: hidden; }

@media (max-width: 760px) {
  .order-detail-grid { grid-template-columns: 1fr; }

  .order-table { display: block; min-width: 0; }
  .order-table colgroup,
  .order-table thead { display: none; }
  .order-table tbody { display: block; }
  .order-table tr.order-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .25rem .75rem;
    border: 1px solid var(--line);
    border-radius: .8rem;
    padding: .75rem .9rem;
    margin-bottom: .75rem;
    background: var(--card);
  }
  .order-table tr.order-main td {
    display: block;
    border: 0;
    padding: .15rem 0;
    text-align: left;
    white-space: normal;
  }
  .order-table tr.order-main td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-weight: 700;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: .15rem;
  }
  .order-table tr.order-main td[data-label="상태"] { grid-column: 1; }
  .order-table tr.order-main td[data-label="작업"] { grid-column: 1 / -1; }
  .order-table tr.order-main td.num { text-align: left; }
  .order-table tr.order-details {
    display: block;
  }
  .order-table tr.order-details > td {
    display: block;
    padding: .5rem 0 1rem;
    border: 0;
  }
}

/* Products table */
.product-table { table-layout: fixed; }
.product-table th,
.product-table td { padding: .75rem .7rem; }
.product-table input,
.product-table select { width: 100%; min-width: 0; padding: .55rem .5rem; }
.product-table .product-name    { width: 48%; }
.product-table .product-stock   { width: 16%; }
.product-table .product-status  { width: 12%; }
.product-table .product-actions { width: 24%; }
.product-table .action-cell {
  display: flex;
  flex-wrap: nowrap;
  gap: .35rem;
  align-items: center;
  white-space: nowrap;
}
.product-table .action-cell form { margin: 0; }
.product-table .status-cell { white-space: nowrap; }
.product-table .action-cell button { padding: .65rem .85rem; min-height: 44px; }

.product-details td { background: var(--row-detail); }
.product-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
  align-items: end;
}

@media (max-width: 760px) {
  .product-detail-grid { grid-template-columns: 1fr; }

  .product-table { display: block; min-width: 0; }
  .product-table colgroup,
  .product-table thead { display: none; }
  .product-table tbody { display: block; }
  .product-table tr.product-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .25rem .75rem;
    border: 1px solid var(--line);
    border-radius: .8rem;
    padding: .75rem .9rem;
    margin-bottom: .75rem;
    background: var(--card);
  }
  .product-table tr.product-main td {
    display: block;
    border: 0;
    padding: .15rem 0;
    white-space: normal;
  }
  .product-table tr.product-main td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-weight: 700;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: .15rem;
  }
  .product-table tr.product-main td[data-label="작업"] { grid-column: 1 / -1; }
  .product-table tr.product-main td.num { text-align: left; }
  .product-table tr.product-details { display: block; }
  .product-table tr.product-details > td {
    display: block;
    padding: .5rem 0 1rem;
    border: 0;
  }
}

/* Suppliers table */
.supplier-table { table-layout: fixed; }
.supplier-table th,
.supplier-table td { padding: .75rem .7rem; }
.supplier-table input { width: 100%; min-width: 0; padding: .55rem .5rem; }
.supplier-table .supplier-name     { width: 32%; }
.supplier-table .supplier-email    { width: 27%; }
.supplier-table .supplier-phone    { width: 17%; }
.supplier-table .supplier-actions  { width: 24%; }
.supplier-table .action-cell {
  display: flex;
  flex-wrap: nowrap;
  gap: .35rem;
  align-items: center;
  white-space: nowrap;
}
.supplier-table .action-cell form { margin: 0; }
.supplier-table .action-cell button { padding: .65rem .85rem; min-height: 44px; }

.supplier-details td { background: var(--row-detail); }
.supplier-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
  align-items: end;
}

@media (max-width: 760px) {
  .supplier-detail-grid { grid-template-columns: 1fr; }

  .supplier-table { display: block; min-width: 0; }
  .supplier-table colgroup,
  .supplier-table thead { display: none; }
  .supplier-table tbody { display: block; }
  .supplier-table tr.supplier-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .25rem .75rem;
    border: 1px solid var(--line);
    border-radius: .8rem;
    padding: .75rem .9rem;
    margin-bottom: .75rem;
    background: var(--card);
  }
  .supplier-table tr.supplier-main td {
    display: block;
    border: 0;
    padding: .15rem 0;
    white-space: normal;
  }
  .supplier-table tr.supplier-main td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-weight: 700;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: .15rem;
  }
  .supplier-table tr.supplier-main td[data-label="작업"] { grid-column: 1 / -1; }
  .supplier-table tr.supplier-details { display: block; }
  .supplier-table tr.supplier-details > td {
    display: block;
    padding: .5rem 0 1rem;
    border: 0;
  }
}
