:root {
  --bg: #000000;
  --fg: #ffffff;
  --success: #00ff66;
  --warning: #ffd400;
  --line: #ffffff;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono CJK SC", monospace;
  font-size: 13px;
  line-height: 1.25;
  overflow: hidden;
}
.hidden { display: none !important; }

.tui-screen {
  min-height: 100vh;
  width: 100vw;
  background: var(--bg);
  color: var(--fg);
  padding: 6px 8px;
}

.tui-frame {
  min-height: calc(100vh - 12px);
  border: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 7px 10px;
}

.tui-header,
.tui-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.clock, .employee { color: var(--fg); }
.tui-body { padding: 10px 0; line-height: 1.25; position: relative; min-height: 0; overflow: hidden; }
#system-title { margin: 0 0 5px 0; font-size: 18px; color: var(--fg); text-align: center; }
.current-page { text-align: right; margin: 0 0 6px 0; }
p { margin: 4px 0; color: var(--fg); }
.panel { width: 100%; max-width: 1200px; min-height: 0; }
.action-list { display: grid; gap: 4px; margin-top: 8px; }
.last-refresh { margin-top: 18px; }
.submenu { display: grid; gap: 6px; margin-top: 0; padding-left: 28px; grid-column: 1 / -1; }
.submenu-button { opacity: 0.98; }

.function-button,
.query-input {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 0 8px;
  margin: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.query-input {
  width: min(560px, 100%);
  cursor: text;
  outline: none;
  background: var(--bg);
  caret-color: var(--fg);
}

.function-button .cursor-marker {
  width: 16px;
  color: var(--fg);
}

.function-button.is-active,
.function-button:focus-visible,
.query-input.is-active,
.query-input:focus-visible {
  color: var(--success);
  background: transparent;
  border-color: transparent;
  outline: none;
  box-shadow: none;
  transform: none;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.function-button.is-active .cursor-marker,
.function-button:focus-visible .cursor-marker {
  color: var(--success);
  visibility: visible;
  opacity: 1;
}

.menu-button { min-width: 220px; }
.modal-button { min-width: auto; }
.inline-button { min-width: 84px; }

.message.general { color: var(--fg); }
.message.success { color: var(--success); }
.message.error { color: var(--warning); }
.command-prompt {
  margin: 2px 0 6px;
  min-height: 1.2em;
  color: var(--success);
  white-space: pre-wrap;
}

#freight-panel {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 14px;
  min-height: 0;
}

.freight-top,
.freight-stats,
.freight-table-section {
  border: 1px solid transparent;
}

.field-label {
  display: block;
  margin-bottom: 6px;
}

.query-shell {
  position: relative;
  width: min(720px, 100%);
  border-bottom: 1px solid var(--line);
  padding: 3px 0;
}

.filter-shell {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(720px, 100%);
}

.freight-filter .field-label {
  margin-bottom: 0;
  white-space: nowrap;
}

#freight-filter {
  flex: 1 1 auto;
  min-width: 0;
}

.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px var(--line) inset;
  background: var(--bg);
  display: grid;
  z-index: 10;
}

.suggestion-item {
  background: transparent;
  color: var(--fg);
  border: none;
  text-align: left;
  font: inherit;
  padding: 6px 8px;
  cursor: pointer;
}

.suggestion-item.empty {
  cursor: default;
}

.suggestion-item.active,
.suggestion-item:hover,
.suggestion-item:focus-visible {
  color: var(--success);
  outline: none;
}

.freight-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
  font-size: 14px;
}

.info-tag {
  min-height: 38px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.35);
  padding-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 12px;
}

.freight-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  font-size: 17px;
}

.stat-card {
  min-height: 48px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.freight-table-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.freight-summary {
  font-size: 14px;
}

.table-scroll {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
}

.table-scroll:focus-visible,
.table-scroll.is-active {
  outline: 1px solid var(--success);
  outline-offset: -1px;
}

.freight-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.freight-table th,
.freight-table td {
  border-bottom: 1px solid rgba(255,255,255,0.2);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.freight-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg);
  color: var(--success);
}

.package-no-cell {
  direction: rtl;
  max-width: 260px;
  overflow: hidden;
  text-align: right !important;
  text-overflow: clip;
  unicode-bidi: plaintext;
}

#delivery-cargo-table th:first-child,
#delivery-selected-table th:first-child {
  text-align: right;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.7);
}

.modal-box {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--fg);
  background: var(--bg);
  color: var(--fg);
  padding: 18px;
}

.modal-box h2 { margin: 0 0 14px 0; text-align: center; }
.modal-box label { display: grid; gap: 4px; margin: 12px 0; }
.modal-box input {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--fg);
  padding: 8px;
  font: inherit;
}
.modal-box input:focus-visible { outline: 1px solid var(--success); }
.modal-actions { display: flex; gap: 18px; justify-content: flex-end; margin-top: 14px; }


#delivery-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  min-height: 0;
}

.delivery-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 8px 12px;
  align-items: start;
  width: 100%;
}

.delivery-field {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.delivery-field .query-shell,
.delivery-field .query-input {
  width: 100%;
  min-width: 0;
}

.delivery-section-separator,
.delivery-section-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 5px 0 1px;
  color: var(--fg);
  font-size: 13px;
  font-weight: 600;
}

.delivery-section-separator::after,
.delivery-section-heading::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border-color, #3a3a3a);
}

.delivery-bottom-actions {
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.delivery-placeholder {
  color: var(--fg-dim);
}

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

@media (max-width: 720px) {
  .tui-header, .tui-footer { align-items: flex-start; flex-direction: column; }
  .current-page { text-align: left; }
  .freight-stats { grid-template-columns: 1fr; }
}

.delivery-cargo-panel,
.delivery-selected-panel {
  margin-top: 0.5rem;
  border: 1px solid var(--border-color, #3a3a3a);
  padding: 0.5rem;
}

.delivery-cargo-panel .table-scroll,
.delivery-selected-panel .table-scroll {
  height: 365px;
  max-height: 365px;
}
.delivery-selected-panel h3,
.delivery-cargo-panel h3 {
  margin: 0 0 0.35rem;
  font-size: 13px;
}

.delivery-selected-stats {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.4rem;
  font-size: 13px;
}

.delivery-selected-stat {
  white-space: nowrap;
}

.delivery-row-selected td {
  color: #38f27a;
  font-weight: 700;
  background: rgba(56, 242, 122, 0.08);
}
.delivery-selected-row td {
  background: transparent;
}
