:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --line: #dce3ea;
  --text: #19212a;
  --muted: #66717f;
  --green: #188653;
  --green-soft: #e7f6ee;
  --red: #d71920;
  --red-soft: #ffe9e9;
  --yellow: #ffd323;
  --yellow-soft: #fff6c8;
  --blue: #2364aa;
  --blue-soft: #e8f1fb;
  --orange: #c95d00;
  --orange-soft: #fff0de;
  --shadow: 0 12px 34px rgba(24, 33, 42, .10);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); }
body { margin: 0; min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px max(16px, env(safe-area-inset-left)) 12px;
  background: rgba(245, 247, 250, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar h1 { margin: 0; font-size: 24px; letter-spacing: 0; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.icon-link {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 22px;
}

.mobile-shell { max-width: 760px; margin: 0 auto; padding: 14px 14px 42px; }
.worker-panel, .search-panel, .shipment-card, .shipment-view, .table-panel, .detail-panel, .stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(24, 33, 42, .03);
}

.worker-panel { padding: 14px; margin-bottom: 12px; }
.section-title { font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 10px; text-transform: uppercase; }
.worker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.worker-card {
  min-height: 74px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 18px;
  font-weight: 800;
}
.worker-card.active { border-color: var(--blue); background: var(--blue-soft); color: #0c4178; }
.search-panel { padding: 12px; margin-bottom: 12px; }
.active-worker { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 800; }
.ghost {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  color: var(--muted);
}
.search-box {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
}
.search-box input, .dash-search, select, textarea, .edit-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.search-box input { min-height: 54px; padding: 0 14px; font-size: 18px; font-weight: 750; }
.search-box input:focus, .dash-search:focus, select:focus, textarea:focus, .edit-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.quick-row { display: flex; gap: 8px; overflow-x: auto; padding-top: 10px; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 12px;
  font-weight: 800;
}
.chip.active { color: #0c4178; border-color: var(--blue); background: var(--blue-soft); }
.results { display: grid; gap: 10px; }
.shipment-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  text-align: left;
  width: 100%;
}
.shipment-card:active { transform: scale(.995); }
.card-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.recipient { font-size: 17px; font-weight: 850; line-height: 1.25; }
.meta { color: var(--muted); font-size: 14px; line-height: 1.35; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 850;
  background: #eef2f5;
  color: #33404d;
}
.carrier-nova { background: var(--red-soft); color: #941018; }
.carrier-ukr { background: var(--yellow-soft); color: #5a4700; }
.status-new { background: #eef2f5; color: #3d4854; }
.status-in_progress { background: var(--orange-soft); color: var(--orange); }
.status-packed { background: var(--green-soft); color: var(--green); }
.status-handed_over { background: var(--blue-soft); color: var(--blue); }
.progress-line { height: 10px; border-radius: 6px; background: #e9eef3; overflow: hidden; }
.progress-line span { display: block; height: 100%; background: var(--green); }

.shipment-view { padding: 12px; margin-top: 12px; }
.hidden { display: none !important; }
.detail-head { display: grid; gap: 10px; margin-bottom: 12px; }
.tracking { font-size: 26px; font-weight: 900; letter-spacing: 0; }
.primary-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.action {
  border: 0;
  border-radius: 8px;
  padding: 13px 12px;
  min-height: 50px;
  font-weight: 900;
  color: #fff;
  background: var(--blue);
}
.action.green { background: var(--green); }
.action.orange { background: var(--orange); }
.action.secondary { background: #36414d; }
.action:disabled { opacity: .45; cursor: not-allowed; }
.info-grid { display: grid; gap: 8px; margin: 12px 0; }
.info-box { border-left: 4px solid var(--line); padding: 8px 10px; background: #f8fafc; border-radius: 6px; }
.info-box strong { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; margin-bottom: 3px; }
.todo-list { display: grid; gap: 8px; margin: 12px 0; }
.todo {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.todo.done { border-color: #b7e2cb; background: var(--green-soft); }
.todo input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--green); }
.todo-title { font-weight: 850; }
.todo-meta { color: var(--muted); font-size: 12px; }
.asset-btn {
  border: 1px solid var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 8px;
  min-height: 38px;
  padding: 6px 10px;
  font-weight: 850;
}
textarea { min-height: 92px; padding: 10px; resize: vertical; line-height: 1.4; }
.apps-list { display: grid; gap: 8px; margin-top: 12px; }
.app-card { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; }
.app-card h3 { margin: 0 0 6px; font-size: 16px; }
.log-list { display: grid; gap: 6px; margin-top: 10px; }
.log-row { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 6px; }

.dashboard-shell { padding: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-card { padding: 14px; }
.stat-value { font-size: 28px; font-weight: 950; }
.stat-label { color: var(--muted); font-weight: 800; font-size: 13px; }
.mini-bars { display: grid; gap: 8px; margin-top: 10px; }
.mini-row { display: grid; grid-template-columns: 130px 1fr 48px; gap: 8px; align-items: center; font-size: 12px; }
.mini-track { height: 8px; background: #e9eef3; border-radius: 5px; overflow: hidden; }
.mini-track span { display: block; height: 100%; background: var(--green); }
.dashboard-layout { display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 14px; align-items: start; }
.table-panel, .detail-panel { padding: 12px; }
.detail-panel { position: sticky; top: 86px; max-height: calc(100vh - 104px); overflow: auto; }
.dashboard-controls { display: grid; grid-template-columns: 1fr 220px; gap: 8px; margin-bottom: 10px; }
.dash-search, select, .edit-input { min-height: 42px; padding: 0 10px; }
.ship-table { display: grid; gap: 7px; }
.table-row {
  display: grid;
  grid-template-columns: 160px minmax(220px, 1fr) 118px 105px 72px;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.table-row:hover { border-color: var(--blue); }
.table-row > * { min-width: 0; }
.table-row button { text-align: left; border: 0; background: transparent; padding: 0; color: inherit; overflow-wrap: anywhere; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.dashboard-item-row { grid-template-columns: 28px 1fr 70px 36px; }
.delete-btn { border: 0; background: #ffe8e8; color: #a11313; border-radius: 8px; height: 34px; font-weight: 900; }
.empty-state { color: var(--muted); padding: 30px; text-align: center; }
.asset-dialog { width: min(920px, calc(100vw - 20px)); border: 0; border-radius: 8px; padding: 16px; box-shadow: var(--shadow); }
.asset-dialog::backdrop { background: rgba(0,0,0,.58); }
.dialog-close { float: right; width: 38px; height: 38px; border: 0; border-radius: 8px; background: #222; color: #fff; font-size: 24px; }
.asset-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); clear: both; padding-top: 12px; }
.asset-grid img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.asset-grid a { color: var(--blue); font-weight: 850; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .dashboard-layout { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-panel { position: static; max-height: none; }
  .table-row { grid-template-columns: 1fr; }
  .dashboard-controls { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .worker-grid { grid-template-columns: 1fr; }
  .primary-actions { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 21px; }
}
