/* Weaving ERP - green gradient theme. Change the variables to re-skin. */
:root {
  --brand-900: #053b2e;
  --brand-800: #065f46;
  --brand-700: #047857;
  --brand-600: #059669;
  --brand-500: #10b981;
  --brand-100: #d1fae5;
  --brand-50:  #ecfdf5;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --page: #f3f6f4;
  --sidebar-w: 260px;
  --radius: 12px;
  --grad: linear-gradient(135deg, var(--brand-700), var(--brand-500));
}

html, body { height: 100%; }
body { font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--page); color: var(--ink); font-size: 14.5px; }
h1, h2, h3, h4, h5 { font-weight: 700; letter-spacing: -.01em; }
a { color: var(--brand-700); }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); position: fixed; inset: 0 auto 0 0; z-index: 1040;
  background: linear-gradient(180deg, var(--brand-900), var(--brand-800) 60%, var(--brand-700));
  color: #d7f3e6; display: flex; flex-direction: column; overflow-y: auto; transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.25rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; font-size: 1.2rem; box-shadow: 0 4px 12px rgba(0,0,0,.25); flex: none; }
.brand-text { line-height: 1.15; overflow: hidden; text-overflow: ellipsis; }
.menu { padding: .75rem .6rem; flex: 1; }
.menu-link { display: flex; align-items: center; gap: .7rem; padding: .62rem .8rem; border-radius: 9px; color: #cdeee0; text-decoration: none; font-weight: 500; margin-bottom: 2px; }
.menu-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.menu-link.active { background: var(--grad); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.menu-link .bi:first-child { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.menu-group .caret { margin-left: auto; font-size: .75rem; transition: transform .2s; }
.menu-group:not(.collapsed) .caret { transform: rotate(180deg); }
.submenu { padding: .15rem 0 .45rem 2.3rem; }
.submenu-link { display: block; padding: .38rem .7rem; border-radius: 7px; color: #b5e3cf; text-decoration: none; font-size: .9rem; }
.submenu-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.submenu-link.active { color: #fff; font-weight: 600; background: rgba(255,255,255,.14); }
.sidebar-foot { padding: .8rem 1.25rem; font-size: .75rem; color: #8fcbb0; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-backdrop { display: none; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1030; height: 60px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; }
.topbar-title { font-weight: 600; color: var(--muted); }
.btn-icon { border: 0; background: transparent; padding: .25rem .5rem; }
.fy-switch { display: flex; align-items: center; gap: .4rem; color: var(--muted); margin: 0; }
.fy-switch select { width: auto; border-radius: 8px; }
.user-chip { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); line-height: 1.1; }
.user-chip small { display: block; color: var(--muted); font-size: .72rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; }
.content { padding: 1.5rem 1.5rem 2.5rem; width: 100%; max-width: none; }
.content-bare { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }

/* ---------- page pieces ---------- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: .75rem; margin-bottom: 1.1rem; }
.page-head h1 { font-size: 1.45rem; margin: 0; }
.page-head p { margin: .2rem 0 0; color: var(--muted); }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 600; border-radius: var(--radius) var(--radius) 0 0 !important; }
.btn-brand { background: var(--grad); color: #fff; border: 0; font-weight: 600; }
.btn-brand:hover, .btn-brand:focus { color: #fff; filter: brightness(1.07); box-shadow: 0 4px 14px rgba(5,150,105,.35); }
.btn-outline-brand { border: 1px solid var(--brand-600); color: var(--brand-700); background: #fff; font-weight: 600; }
.btn-outline-brand:hover { background: var(--brand-50); color: var(--brand-800); }
.form-control:focus, .form-select:focus { border-color: var(--brand-500); box-shadow: 0 0 0 .2rem rgba(16,185,129,.18); }
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .25rem; }
.form-label .req { color: #dc2626; }
.form-section { font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-700); border-bottom: 1px solid var(--line); padding-bottom: .3rem; margin: .6rem 0 0; }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { background: var(--brand-50); color: var(--brand-900); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--brand-100); white-space: nowrap; }
.table-hover tbody tr:hover { background: #f7fcf9; }
.badge-soft { background: var(--brand-100); color: var(--brand-800); font-weight: 600; }
.badge-off { background: #f3f4f6; color: #6b7280; font-weight: 600; }
.text-end-num { text-align: right; font-variant-numeric: tabular-nums; }
.row-inactive td { color: #9ca3af; }

.stat { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; }
.stat .ico { width: 46px; height: 46px; border-radius: 12px; background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.stat .num { font-size: 1.55rem; font-weight: 700; line-height: 1; }
.stat .lbl { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.check-item { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem 0; border-bottom: 1px dashed var(--line); }
.check-item:last-child { border-bottom: 0; }
.check-item .bi { font-size: 1.15rem; margin-top: .05rem; }

.perm-table th, .perm-table td { text-align: center; vertical-align: middle; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-table .grp td { background: #f8fafc; font-weight: 700; color: var(--brand-800); text-align: left; }

.login-card { width: 100%; max-width: 410px; border-radius: 16px; overflow: hidden; box-shadow: 0 20px 50px rgba(5,59,46,.25); }
.login-top { background: linear-gradient(135deg, var(--brand-900), var(--brand-700) 60%, var(--brand-500)); color: #fff; padding: 2rem 1.75rem 1.6rem; text-align: center; }
.login-top .brand-mark { margin: 0 auto .8rem; width: 54px; height: 54px; font-size: 1.7rem; background: rgba(255,255,255,.18); }
.login-body { background: #fff; padding: 1.6rem 1.75rem 1.9rem; }
body.login-page { background: radial-gradient(circle at 20% 10%, #d1fae5 0, transparent 40%), radial-gradient(circle at 90% 90%, #a7f3d0 0, transparent 35%), var(--page); }

.select2-container--bootstrap-5 .select2-selection { border-radius: .375rem; }

/* ---------- document sheet (challan / receipt print) ---------- */
.doc-sheet { position: relative; max-width: none; width: 100%; margin: 0; }
.doc-title { text-align: center; font-weight: 700; letter-spacing: .08em; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); padding: .3rem 0; }
.doc-meta td { padding: .1rem .4rem; }
.doc-meta td:first-child { color: var(--muted); width: 38%; }
.doc-sign { margin-top: 3.2rem; }
.sign-line { border-top: 1px solid var(--ink); padding-top: .25rem; margin: 0 .75rem; }
.doc-stamp { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-22deg); font-size: 4rem; font-weight: 800; color: rgba(220,38,38,.18); border: .4rem solid rgba(220,38,38,.18); padding: 0 1.5rem; pointer-events: none; }
.line-grid td { vertical-align: middle; }
.line-grid .select2-container { min-width: 10rem; }
.report-table td, .report-table th { white-space: nowrap; }

/* ---------- fluid layout ---------- */
@media (min-width: 992px) and (max-width: 1399.98px) { :root { --sidebar-w: 232px; } }
@media (min-width: 992px) {
  .sidebar, .main { transition: transform .2s ease, margin-left .2s ease; }
  body.sb-collapsed .sidebar { transform: translateX(-100%); }
  body.sb-collapsed .main { margin-left: 0; }
}
.content { padding-left: clamp(.75rem, 1.6vw, 2rem); padding-right: clamp(.75rem, 1.6vw, 2rem); }
.table-responsive { -webkit-overflow-scrolling: touch; }
.card, .row > * { min-width: 0; }
.topbar { padding: 0 clamp(.6rem, 1.5vw, 1.25rem); }
@media (max-width: 575.98px) {
  .page-head { align-items: stretch; }
  .page-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
  .page-actions .btn { flex: 1 1 auto; }
  .topbar .fy-switch span { display: none; }
  .modal-dialog { margin: .5rem; }
  .table > :not(caption) > * > * { padding: .4rem .5rem; }
  .doc-title { font-size: 1rem; }
  .doc-stamp { font-size: 2.4rem; }
}

/* ---------- small screens ---------- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; }
  .main { margin-left: 0; }
  .content { padding: 1rem .75rem 2rem; }
}

/* ---------- print ---------- */
@media print {
  .sidebar, .topbar, .page-actions, .no-print, .pagination, .btn, form.filters { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; font-size: 12px; }
  .card { border: 0; box-shadow: none; }
  .table thead th { background: #eee !important; color: #000; }
  .doc-sheet { max-width: none; }
  .report-table td, .report-table th { white-space: normal; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ---------- piece labels (cloth checking) ---------- */
.label-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.piece-label { border: 1px dashed #555; border-radius: .25rem; padding: .5rem .6rem; text-align: center; break-inside: avoid; background: #fff; }
.piece-label .lbl-no { font-weight: 700; font-size: 1rem; word-break: break-all; }
.piece-label .lbl-m { font-size: 1.4rem; font-weight: 800; }
@media print { .label-grid { grid-template-columns: repeat(3, 1fr); } .piece-label { border-color: #000; } }
