/* QVDS SMART GARMENT PRODUCTION - STANDARD LITE 1.0 */
:root {
  --navy-900: #0b1f33;
  --navy-800: #0f2942;
  --navy-700: #163a5f;
  --navy-600: #1e4b7a;
  --teal-600: #0d9488;
  --teal-500: #14b8a6;
  --teal-50: #f0fdfa;
  --bg-page: #f3f6fa;
  --bg-card: #ffffff;
  --text-main: #111827;
  --text-muted: #4b5563;
  --border: #d1d9e4;
  --border-input: #6b7280;
  --red-600: #dc2626;
  --red-50: #fef2f2;
  --orange-600: #d97706;
  --orange-50: #fffbeb;
  --green-700: #15803d;
  --green-50: #f0fdf4;
  --blue-700: #1d4ed8;
  --blue-50: #eff6ff;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(15, 41, 66, 0.08);
  --shadow-md: 0 6px 20px rgba(15, 41, 66, 0.12);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  color: var(--text-main);
  background: var(--bg-page);
}

body {
  margin: 0;
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
}

img {
  max-inline-size: 100%;
  display: block;
}

a {
  color: var(--navy-700);
}

:focus-visible {
  outline: 3px solid var(--teal-600);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

/* Header & App Shell */
.app-shell {
  display: flex;
  flex: 1;
  min-block-size: 100dvh;
}

.sidebar {
  inline-size: 256px;
  flex-shrink: 0;
  background: var(--navy-800);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.65rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  margin-bottom: 0.75rem;
}

.brand-logo {
  inline-size: 40px;
  block-size: 40px;
  border-radius: 8px;
  background: var(--teal-600);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
}

.brand-logo img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

.brand-title {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.25;
  color: #fff;
}

.brand-sub {
  font-size: 0.72rem;
  color: #99f6e4;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.68rem 0.85rem;
  border-radius: 8px;
  color: #e2e8f0;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  min-block-size: 44px;
  border-inline-start: 4px solid transparent;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-link[aria-current="page"] {
  background: rgba(20, 184, 166, 0.22);
  color: #ffffff;
  font-weight: 700;
  border-inline-start-color: var(--teal-500);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.78rem;
  color: #cbd5e1;
}

.main-area {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mobile-menu-btn {
  display: none;
  min-block-size: 44px;
  min-inline-size: 44px;
  align-items: center;
  justify-content: center;
  background: var(--navy-800);
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.page-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy-800);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.role-pill {
  background: var(--teal-50);
  color: var(--teal-600);
  border: 1px solid #99f6e4;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
}

.page-content {
  padding: 1.25rem;
  flex: 1;
}

.app-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Mobile Responsive Sidebar Drawer via Popover/Class */
@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
}

/* Cards & Grids */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy-800);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.kpi-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 4px solid var(--navy-700);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
}

.kpi-card:hover {
  border-color: var(--teal-600);
}

.kpi-card.teal { border-top-color: var(--teal-600); }
.kpi-card.green { border-top-color: var(--green-700); }
.kpi-card.orange { border-top-color: var(--orange-600); }
.kpi-card.red { border-top-color: var(--red-600); }

.kpi-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy-800);
  margin-top: 0.25rem;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

/* Alerts & Badges */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  margin-bottom: 0.9rem;
  font-weight: 500;
}
.alert-success { background: var(--green-50); border-color: #86efac; color: var(--green-700); }
.alert-danger  { background: var(--red-50); border-color: #fca5a5; color: var(--red-600); }
.alert-warning { background: var(--orange-50); border-color: #fcd34d; color: #92400e; }
.alert-info    { background: var(--blue-50); border-color: #93c5fd; color: var(--blue-700); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-success { background: var(--green-50); color: var(--green-700); border: 1px solid #86efac; }
.badge-danger  { background: var(--red-50); color: var(--red-600); border: 1px solid #fca5a5; }
.badge-warning { background: var(--orange-50); color: #92400e; border: 1px solid #fcd34d; }
.badge-orange  { background: #fff7ed; color: #c2410c; border: 1px solid #fdba74; }
.badge-info    { background: var(--teal-50); color: var(--teal-600); border: 1px solid #99f6e4; }
.badge-neutral { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  min-block-size: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn-sm {
  min-block-size: 36px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}
.btn-lg {
  min-block-size: 52px;
  font-size: 1.05rem;
  padding: 0.75rem 1.25rem;
}
.btn-primary { background: var(--navy-800); color: #ffffff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-teal { background: var(--teal-600); color: #ffffff; }
.btn-teal:hover { background: #0f766e; }
.btn-success { background: var(--green-700); color: #ffffff; }
.btn-danger { background: var(--red-600); color: #ffffff; }
.btn-warning { background: var(--orange-600); color: #ffffff; }
.btn-outline { background: #ffffff; color: var(--navy-800); border-color: var(--border); }
.btn-outline:hover { background: #f8fafc; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-block-end: 0.85rem;
}

.field label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--navy-800);
}

.field input,
.field select,
.field textarea {
  font: inherit;
  font-size: max(1rem, 1em);
  padding: 0.6rem 0.75rem;
  min-block-size: 46px;
  border: 1.5px solid var(--border-input);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text-main);
}

.field textarea {
  min-block-size: 84px;
  resize: vertical;
}

.field input:user-invalid,
.field select:user-invalid,
.field textarea:user-invalid {
  border-color: var(--red-600);
  background: var(--red-50);
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  inline-size: 100%;
  padding-inline-end: 4.5rem;
}

.password-toggle {
  position: absolute;
  inset-inline-end: 0.4rem;
  min-block-size: 36px;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafc;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* Responsive Tables */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: 72dvh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  container-type: inline-size;
}

table {
  inline-size: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

thead th {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: var(--navy-800);
  color: #ffffff;
  text-align: left;
  padding: 0.65rem 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid var(--navy-900);
}

tbody td, tbody th {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}

tbody tr:hover td, tbody tr:hover th {
  background: #f8fafc;
}

/* Fixed sticky first column for desktop matrix */
.matrix-table thead th.sticky-col {
  inset-inline-start: 0;
  z-index: 4;
}
.matrix-table tbody th.sticky-col {
  position: sticky;
  inset-inline-start: 0;
  z-index: 3;
  background: #ffffff;
  border-inline-end: 2px solid var(--border);
  text-align: left;
  min-inline-size: 220px;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Responsive stacked cards for standard non-matrix tables on narrow containers */
@container (width < 580px) {
  .responsive-cards thead {
    display: none;
  }
  .responsive-cards, .responsive-cards tbody, .responsive-cards tr, .responsive-cards td, .responsive-cards th {
    display: block;
    inline-size: 100%;
  }
  .responsive-cards tr {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-block-end: 0.75rem;
    padding: 0.4rem;
    background: #fff;
  }
  .responsive-cards td {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    text-align: right;
    border-bottom: 1px dashed #e5e7eb;
    padding: 0.45rem 0.5rem;
  }
  .responsive-cards td:last-child {
    border-bottom: 0;
  }
  .responsive-cards td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--navy-800);
    text-align: left;
  }
}

/* Native Modal Dialog */
dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  max-inline-size: min(94dvw, 560px);
  inline-size: 100%;
  box-shadow: var(--shadow-md);
  background: #ffffff;
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(11, 31, 51, 0.55);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.dialog-head h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--navy-800);
}

/* Worker Mobile-First Shell */
.worker-shell {
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  padding-block-end: 74px;
}

.worker-topbar {
  background: var(--navy-800);
  color: #ffffff;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
}

.worker-main {
  max-inline-size: 760px;
  inline-size: 100%;
  margin-inline: auto;
  padding: 1rem;
  flex: 1;
}

.worker-bottom-nav {
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  background: #ffffff;
  border-top: 2px solid var(--border);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  z-index: 30;
}

.worker-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.2rem;
  min-block-size: 60px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  border-top: 3px solid transparent;
}

.worker-nav-item[aria-current="page"] {
  color: var(--teal-600);
  font-weight: 800;
  border-top-color: var(--teal-600);
  background: var(--teal-50);
}

/* Login Guest Layout */
.guest-shell {
  min-block-size: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: linear-gradient(145deg, var(--navy-900) 0%, var(--navy-700) 55%, var(--teal-600) 100%);
}

.guest-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 1.75rem;
  inline-size: min(100%, 440px);
  box-shadow: var(--shadow-md);
}

.thumb-img {
  inline-size: 56px;
  block-size: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f1f5f9;
}

.progress-bar {
  block-size: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  block-size: 100%;
  background: var(--teal-600);
}
.progress-fill.done {
  background: var(--green-700);
}
