:root{--bg:#f1f5f9;--card:#fff;--text:#0f172a;--muted:#64748b;--line:#e2e8f0;--blue:#2563eb;--orange:#f97316;--green:#10b981;--red:#ef4444;--amber:#f59e0b;--slate:#475569}
*{box-sizing:border-box}body{margin:0;font-family:Inter,Arial,sans-serif;background:var(--bg);color:var(--text)}a{text-decoration:none;color:inherit}.app-shell{display:flex;min-height:100vh}.sidebar{width:260px;background:#fff;border-right:1px solid var(--line);padding:24px;position:sticky;top:0;height:100vh}.brand{font-size:22px;font-weight:800;margin-bottom:24px}.userbox{padding:14px;border:1px solid var(--line);border-radius:18px;margin-bottom:20px;background:#f8fafc}.userbox span{display:block;color:var(--muted);font-size:13px;margin-top:4px}.sidebar nav{display:grid;gap:8px}.sidebar nav a{padding:12px 14px;border-radius:14px;color:#334155}.sidebar nav a:hover{background:#f1f5f9}.content{flex:1;padding:28px;max-width:1500px}.page-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:22px}.page-title{font-size:30px;font-weight:800;margin:0}.page-subtitle{color:var(--muted);margin-top:6px}.grid{display:grid;gap:16px}.metrics{grid-template-columns:repeat(4,minmax(0,1fr));margin-bottom:22px}.metric{background:var(--card);border:1px solid var(--line);border-radius:22px;padding:20px;box-shadow:0 4px 14px rgba(15,23,42,.04)}.metric .label{color:var(--muted);font-size:14px}.metric .value{font-size:28px;font-weight:800;margin-top:6px}.card{background:var(--card);border:1px solid var(--line);border-radius:22px;box-shadow:0 4px 14px rgba(15,23,42,.04);margin-bottom:22px;overflow:hidden}.card-header{padding:20px 22px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;gap:16px}.card-title{font-size:20px;font-weight:800}.card-body{padding:20px 22px}.table{width:100%;border-collapse:separate;border-spacing:0}.table th{background:#f8fafc;color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.04em;text-align:left;padding:12px}.table td{border-top:1px solid #eef2f7;padding:12px;vertical-align:top;font-size:14px}.table tr.urgent-row{background:#fff7ed}.badge{display:inline-flex;border-radius:999px;padding:5px 10px;border:1px solid var(--line);font-size:12px;font-weight:700;white-space:nowrap}.badge-normal{background:#f1f5f9;color:#334155}.badge-urgent{background:#ffedd5;color:#c2410c;border-color:#fed7aa}.badge-work{background:#dbeafe;color:#1d4ed8;border-color:#bfdbfe}.badge-done{background:#d1fae5;color:#047857;border-color:#a7f3d0}.badge-pending{background:#fef3c7;color:#a16207;border-color:#fde68a}.badge-danger{background:#fee2e2;color:#b91c1c;border-color:#fecaca}.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:none;border-radius:14px;padding:10px 14px;background:var(--blue);color:#fff;font-weight:700;cursor:pointer;font-size:14px}.btn:hover{filter:brightness(.96)}.btn-secondary{background:#fff;color:#334155;border:1px solid var(--line)}.btn-danger{background:var(--red)}.btn-warning{background:var(--orange)}.btn-green{background:var(--green)}.actions{display:flex;gap:8px;flex-wrap:wrap}.details-row{display:none;background:#f8fafc}.details-row.open{display:table-row}.details-box{padding:18px}.details-title{font-weight:800;margin-bottom:12px}.compact-list{line-height:1.55}.comment-accordion{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin-top:14px}.comment-item{background:#fff;border:1px solid var(--line);border-radius:16px;padding:14px;color:#334155}.form{display:grid;gap:14px;max-width:900px}.form-row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.field label{display:block;font-weight:700;margin-bottom:7px}.field input,.field select,.field textarea{width:100%;padding:12px 13px;border:1px solid var(--line);border-radius:14px;background:#fff;font:inherit}.field textarea{min-height:92px}.modal-backdrop{position:fixed;inset:0;background:rgba(15,23,42,.42);display:none;align-items:center;justify-content:center;padding:20px}.modal-backdrop.open{display:flex}.modal{background:#fff;border-radius:24px;width:min(640px,100%);padding:22px;box-shadow:0 20px 60px rgba(15,23,42,.25)}.modal-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px}.alert{border-radius:16px;padding:14px 16px;margin-bottom:16px}.alert-ok{background:#d1fae5;color:#065f46}.alert-error{background:#fee2e2;color:#991b1b}.settings-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.setting-box{background:#f8fafc;border-radius:16px;padding:14px}.setting-box b{display:block;font-size:18px;margin-top:4px}.login-page{min-height:100vh;display:grid;place-items:center;padding:20px}.login-card{width:min(440px,100%);background:#fff;border:1px solid var(--line);border-radius:28px;padding:28px;box-shadow:0 20px 60px rgba(15,23,42,.08)}@media(max-width:1100px){.sidebar{display:none}.content{padding:18px}.metrics,.settings-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.comment-accordion{grid-template-columns:1fr}.table-wrap{overflow:auto}}@media(max-width:700px){.metrics,.settings-grid,.form-row{grid-template-columns:1fr}.page-head{display:block}}
.metric-link{display:block}.metric-link:hover{transform:translateY(-1px);box-shadow:0 8px 22px rgba(15,23,42,.08)}
.table-input{width:100%;min-width:120px;padding:9px 10px;border:1px solid var(--line);border-radius:10px;background:#fff;font:inherit}.checkline{display:flex;gap:6px;align-items:center}.modal-wide{width:min(1100px,100%)}.field-actions{align-self:end}.item-row{grid-template-columns:repeat(6,minmax(0,1fr));padding:10px;border:1px solid #eef2f7;border-radius:16px;background:#f8fafc;margin-bottom:10px}.edit-item-row{grid-template-columns:repeat(6,minmax(0,1fr))}@media(max-width:1100px){.item-row,.edit-item-row{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:700px){.item-row,.edit-item-row{grid-template-columns:1fr}}
.user-cards{display:grid;gap:14px}.user-edit-card{border:1px solid var(--line);border-radius:18px;padding:16px;background:#f8fafc}.user-edit-title{font-weight:800;margin-bottom:12px}
/* Stage 2.1 visual improvements */
.sidebar nav a.active-nav{background:#eaf1ff;color:#1d4ed8;border:1px solid #bfdbfe;font-weight:800}.tabs .btn-tab.active-tab{background:#eaf1ff;color:#1d4ed8;border-color:#93c5fd;box-shadow:0 3px 12px rgba(37,99,235,.12)}
.item-card{border:1px solid var(--line);border-radius:18px;background:#f8fafc;margin-bottom:14px;padding:16px}.item-card-title{font-size:16px;font-weight:800;margin-bottom:12px;color:#0f172a}.item-fields{grid-template-columns:repeat(2,minmax(0,1fr))}.field-wide{grid-column:span 2}.item-card .field-actions{display:flex;align-items:flex-end}.user-cards{display:grid;gap:18px}.user-edit-card{border:1px solid var(--line);border-radius:20px;padding:18px;background:#fff;box-shadow:0 3px 12px rgba(15,23,42,.04)}.user-edit-title{font-size:16px;font-weight:800;margin-bottom:14px;padding-bottom:10px;border-bottom:1px solid #eef2f7}.user-edit-card:nth-child(even){background:#f8fafc}@media(max-width:900px){.item-fields{grid-template-columns:1fr}.field-wide{grid-column:auto}}
/* Stage 2.4: fixed-height edit modal with internal scrolling and always-visible buttons */
.modal{max-height:92vh;display:flex;flex-direction:column;overflow:hidden}
.modal-head{flex:0 0 auto}
.modal-form-fixed{display:flex;flex-direction:column;gap:0;min-height:0;max-height:calc(92vh - 86px);overflow:hidden}
.modal-scroll-body{overflow-y:auto;min-height:0;padding-right:8px;padding-bottom:14px;display:grid;gap:14px}
.modal-sticky-actions{flex:0 0 auto;margin:0 -22px -22px;padding:14px 22px;background:#fff;border-top:1px solid var(--line);position:sticky;bottom:0;z-index:2}
.modal-scroll-body::-webkit-scrollbar{width:10px}
.modal-scroll-body::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:999px}
.modal-scroll-body::-webkit-scrollbar-track{background:#f8fafc;border-radius:999px}
@media(max-width:700px){.modal{max-height:94vh}.modal-form-fixed{max-height:calc(94vh - 76px)}.modal-sticky-actions{margin-left:-18px;margin-right:-18px;margin-bottom:-18px;padding:12px 18px}}

/* Stage 2.5: comments visible directly inside Details block */
.comment-item summary{cursor:pointer;font-weight:700;list-style:none}
.comment-item summary::-webkit-details-marker{display:none}
.comment-item summary::before{content:'▶ ';color:#64748b}
.comment-item[open] summary::before{content:'▼ '}
.comment-item p{margin:10px 0 0;color:#334155;line-height:1.45;white-space:normal}

/* Stage 2.6: process place highlight */
.place-process{display:inline-flex;align-items:center;border-radius:999px;padding:5px 10px;background:#fef3c7;color:#a16207;border:1px solid #fde68a;font-weight:800;white-space:nowrap}

/* Stage 2.7: order creation date under order number */
.order-number-cell{line-height:1.25}
.order-number-cell b{display:block}
.order-date{display:block;margin-top:4px;color:var(--muted);font-size:12px;font-weight:600;white-space:nowrap}

/* Stage 3.1: simplified warehouse check modal */
.warehouse-check-simple{display:grid;grid-template-columns:1fr 1.4fr 1fr;gap:14px;align-items:end}.warehouse-check-simple .field label{font-size:15px}.warehouse-left-box b{font-size:20px}.modal-head h2{margin:0}@media(max-width:900px){.warehouse-check-simple{grid-template-columns:1fr}}


/* Stage 3.2: polished warehouse check modal */
.warehouse-item-card{background:#fff;border:1px solid #dbe5f2;border-radius:20px;padding:18px 18px 16px;box-shadow:0 8px 24px rgba(15,23,42,.04)}
.warehouse-item-title-row{display:flex;align-items:center;gap:14px;margin-bottom:14px}
.warehouse-item-index{width:34px;height:34px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;background:linear-gradient(180deg,#3b82f6,#2563eb);color:#fff;font-weight:800;box-shadow:0 6px 16px rgba(37,99,235,.25);flex:0 0 auto}
.warehouse-item-title{margin:0;font-size:17px;line-height:1.3}
.warehouse-ordered-row,.warehouse-left-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.warehouse-ordered-row{margin-bottom:16px}
.warehouse-row-icon{width:30px;height:30px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;font-size:16px;line-height:1;background:#eff6ff;border:1px solid #bfdbfe}
.warehouse-row-icon-blue{color:#2563eb;background:#eff6ff;border-color:#bfdbfe}
.warehouse-row-icon-orange{color:#ea580c;background:#fff7ed;border-color:#fed7aa}
.warehouse-ordered-label,.warehouse-left-label{font-size:15px;font-weight:600;color:#334155}
.warehouse-ordered-badge{display:inline-flex;align-items:center;justify-content:center;padding:8px 14px;border-radius:12px;background:#eaf1ff;color:#2563eb;font-weight:800;font-size:16px;min-width:110px}
.warehouse-field label{font-size:15px;font-weight:700;margin-bottom:10px}
.warehouse-input-row{display:flex;align-items:center;gap:12px}
.warehouse-input-row input{flex:1;min-width:0;font-size:16px;padding:13px 14px;border-radius:14px;border:1px solid #dbe5f2;background:#fff}
.warehouse-input-suffix{font-size:16px;font-weight:700;color:#64748b;white-space:nowrap}
.warehouse-divider{height:1px;background:#e5edf6;margin:14px 0 16px}
.warehouse-left-result{font-size:18px;font-weight:900;color:#f97316;white-space:nowrap}
.warehouse-left-value{font-size:20px}
.warehouse-actions{justify-content:space-between;align-items:center}
.warehouse-actions .btn{min-width:220px}
.warehouse-actions .btn-secondary{min-width:auto}
@media(max-width:700px){.warehouse-item-title-row{align-items:flex-start}.warehouse-input-row{flex-wrap:wrap}.warehouse-actions{gap:10px}.warehouse-actions .btn{width:100%}}


/* Stage 3.3: compact queue table and softer badges */
.badge{border-radius:9px;padding:4px 8px;font-size:12px}
.place-process{border-radius:9px;padding:4px 8px;font-size:12px;line-height:1.15}
.queue-table th{font-size:11px;padding:10px 8px;line-height:1.15}
.queue-table td{font-size:13px;padding:10px 8px;line-height:1.3}
.queue-table .compact-list{line-height:1.35}
.queue-table .btn{padding:8px 11px;border-radius:10px;font-size:13px;white-space:nowrap}
.queue-table .order-date{font-size:11px}
.queue-table td:last-child,.queue-table th:last-child{white-space:nowrap;min-width:104px}
.table-wrap{overflow-x:auto}
@media(max-width:1400px){.queue-table th{font-size:10.5px;padding:9px 6px}.queue-table td{font-size:12.5px;padding:9px 6px}.queue-table .btn{padding:7px 9px}}


/* Stage 3.4: cleaner queue preview */
.queue-table th,.queue-table td{padding-left:10px;padding-right:10px}
.queue-table .btn{padding:8px 12px;border-radius:10px}

/* Stage 3.11: left compact dashboard + top section tabs */
.sidebar{display:flex;flex-direction:column;gap:18px}
.userbox{margin-bottom:0}
.side-metrics{border:1px solid var(--line);border-radius:18px;background:#fff;overflow:hidden;box-shadow:0 4px 14px rgba(15,23,42,.03)}
.side-metric{display:flex;align-items:center;gap:12px;padding:15px 14px;border-bottom:1px solid var(--line)}
.side-metric:last-child{border-bottom:none}
.side-metric-icon{width:42px;height:42px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:#eff6ff;color:#2563eb;font-size:22px;flex:0 0 auto}
.side-metric span:not(.side-metric-icon){display:block;color:var(--muted);font-size:14px;line-height:1.25;margin-bottom:5px}
.side-metric b{display:block;color:var(--text);font-size:24px;line-height:1.1;font-weight:900}
.sidebar-bottom{margin-top:auto;display:block!important}
.sidebar-bottom a{display:flex;align-items:center;gap:8px;padding:12px 14px;border-radius:12px;color:#334155;border:1px solid transparent}
.sidebar-bottom a::before{content:'↪';font-size:18px;color:#64748b}
.sidebar-bottom a:hover{background:#f8fafc;border-color:var(--line)}
.top-bar-row{display:flex;align-items:center;gap:16px;margin-bottom:22px}
.top-tabs{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:0;flex:1;border:1px solid var(--line);border-radius:10px;overflow:hidden;background:#fff;box-shadow:0 4px 14px rgba(15,23,42,.03)}
.top-tabs .btn-tab{border:0;border-right:1px solid var(--line);border-radius:0;background:#fff;color:#475569;padding:16px 18px;font-size:15px;min-height:56px;white-space:nowrap}
.top-tabs .btn-tab:last-child{border-right:0}
.top-tabs .btn-tab.active-tab{background:#f8fbff;color:#2563eb;border:1px solid #2563eb;box-shadow:inset 0 0 0 1px rgba(37,99,235,.25);font-weight:900}
.badge{border-radius:6px;padding:4px 8px}
.place-process{border-radius:6px;padding:4px 8px;font-size:12px}
.queue-table .btn-secondary{border-radius:8px;padding:8px 12px}
@media(max-width:1100px){.sidebar{display:none}.top-bar-row{display:block}.top-tabs{display:flex;overflow:auto;margin-bottom:12px}.top-tabs .btn-tab{flex:0 0 auto}}

/* Stage 4.9: visible note for partial production inside details */
.partial-production-note{margin:14px 0 16px;padding:12px 14px;border:1px solid #fed7aa;background:#fff7ed;border-radius:12px;color:#7c2d12}
.partial-production-note-title{font-weight:900;margin-bottom:8px;color:#c2410c}
.partial-production-line{display:flex;gap:10px;align-items:center;flex-wrap:wrap;font-size:13px;line-height:1.35;margin-top:6px}
.partial-production-line span{color:#9a3412;font-weight:700}
.partial-production-line b{color:#0f172a}
.partial-production-line em{font-style:normal;color:#7c2d12}


/* Stage 4.10: visual production flow and framed opened details */
.details-row.open .details-box{
  margin:10px 0 14px;
  border:1px solid #dbe5f2;
  border-radius:14px;
  background:#f8fafc;
  box-shadow:0 4px 14px rgba(15,23,42,.03);
}
.production-flow-summary{
  display:grid;
  grid-template-columns:minmax(130px,1fr) auto minmax(130px,1fr) auto minmax(130px,1fr) auto minmax(130px,1fr);
  gap:14px;
  align-items:center;
  margin:12px 0 16px;
}
.production-flow-summary:has(.production-flow-partial){
  grid-template-columns:minmax(120px,1fr) auto minmax(120px,1fr) auto minmax(120px,1fr) auto minmax(120px,1fr) auto minmax(120px,1fr);
}
.production-flow-item span{
  display:block;
  color:#334155;
  font-size:13px;
  margin-bottom:6px;
}
.production-flow-item b{
  display:block;
  color:#020617;
  font-size:18px;
  line-height:1.2;
  font-weight:900;
}
.production-flow-partial span,
.production-flow-partial b{
  color:#c2410c;
}
.production-flow-arrow{
  color:#64748b;
  font-size:30px;
  line-height:1;
  font-weight:700;
  transform:translateY(8px);
}
@media(max-width:1100px){
  .production-flow-summary,.production-flow-summary:has(.production-flow-partial){display:flex;flex-wrap:wrap;gap:10px 12px}
  .production-flow-arrow{font-size:22px;transform:none}
}
