/* ============================================================
   CNC ওয়ার্কশপ ম্যানেজমেন্ট — মূল স্টাইলশিট
   ============================================================ */

:root {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --text-dim:  #64748b;
  --brand:     #b45309;
  --brand-2:   #f59e0b;
  --brand-soft:#fef3c7;
  --green:     #059669;
  --green-soft:#d1fae5;
  --red:       #dc2626;
  --red-soft:  #fee2e2;
  --blue:      #2563eb;
  --blue-soft: #dbeafe;
  --teal:      #0d9488;
  --teal-soft: #ccfbf1;
  --purple:    #7c3aed;
  --shadow:    0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.12);
  --radius:    14px;
  --sidebar-w: 246px;
}

html[data-theme="dark"] {
  --bg:        #0b1220;
  --surface:   #131c2e;
  --surface-2: #1a2439;
  --border:    #263349;
  --text:      #e6edf7;
  --text-dim:  #93a3ba;
  --brand:     #f59e0b;
  --brand-2:   #fbbf24;
  --brand-soft:#3a2c0c;
  --green-soft:#0c3a2c;
  --red-soft:  #3d1518;
  --blue-soft: #14243f;
  --teal-soft: #0b3330;
  --shadow:    0 1px 3px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 34px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Hind Siliguri', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- লেআউট ---------------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(175deg, #1a2439 0%, #0f172a 100%);
  color: #cbd5e1;
  position: fixed;
  inset: 0 auto 0 0;
  height: 100vh;
  height: 100dvh;               /* মোবাইলে ঠিকানা-বার লুকালেও উচ্চতা ঠিক থাকে */
  overflow-y: auto;
  overscroll-behavior: contain; /* মেনু স্ক্রল করলে পেছনের পাতা নড়বে না */
  -webkit-overflow-scrolling: touch;
  z-index: 60;
  transition: transform .22s ease;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  position: sticky; top: 0;
  background: #1a2439;
  z-index: 2;
  text-decoration: none;
  transition: background .15s;
}
.brand:hover { background: #223050; text-decoration: none; }
.brand:hover .brand-logo { transform: scale(1.05); }
.brand-logo {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b, #b45309);
  display: grid; place-items: center;
  color: #fff; font-size: 20px; font-weight: 700; line-height: 1;
  transition: transform .15s;
}
/* লোগো ছবি হলে গ্রেডিয়েন্ট পটভূমির দরকার নেই */
img.brand-logo { background: none; object-fit: contain; display: block; }
.brand-txt { min-width: 0; }
.brand-txt b { color: #fff; font-size: 15px; display: block; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-txt span { font-size: 11px; color: #94a3b8; }

/* নিচে বাড়তি জায়গা — ফোনের নেভিগেশন বারের নিচে যেন শেষ আইটেম ঢাকা না পড়ে */
.nav { padding: 10px 10px calc(48px + env(safe-area-inset-bottom, 0px)); }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: #64748b; padding: 14px 10px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px;
  color: #cbd5e1; font-size: 14.5px; margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav a.active { background: linear-gradient(90deg, var(--brand), #92400e); color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(180,83,9,.4); }
.nav a .ic { width: 20px; text-align: center; font-size: 15px; flex: 0 0 20px; }
.nav a .cnt { margin-inline-start: auto; background: #dc2626; color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 999px; font-weight: 700; }

.main { flex: 1; min-width: 0; margin-inline-start: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  cursor: pointer; font-size: 16px; position: relative; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--border); }
.icon-btn .dot { position: absolute; top: 5px; inset-inline-end: 5px; width: 8px; height: 8px;
  background: var(--red); border-radius: 50%; border: 2px solid var(--surface); }

#menuBtn { display: none; }

.content { padding: 18px; flex: 1; }

.userchip { display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 5px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.userchip .av { width: 28px; height: 28px; border-radius: 50%; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.userchip small { color: var(--text-dim); display: block; font-size: 11px; line-height: 1; }
.userchip b { font-size: 13px; line-height: 1.3; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); min-width: 230px; padding: 6px; display: none; z-index: 80;
  max-height: 70vh; overflow-y: auto;
}
.dropdown-menu.open { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; gap: 9px; align-items: flex-start; width: 100%; text-align: start;
  padding: 9px 11px; border-radius: 8px; color: var(--text); font-size: 14px;
  background: none; border: 0; cursor: pointer; font-family: inherit;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }

/* ---------------- কার্ড ---------------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-head h3 { margin: 0; font-size: 15.5px; font-weight: 700; }
.card-head .spacer { margin-inline-start: auto; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

/* ---------------- স্ট্যাট ---------------- */

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 15px; box-shadow: var(--shadow); position: relative; overflow: hidden;
  display: block; color: var(--text);
}
.stat:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-lg); transition: .15s; }
.stat .ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  font-size: 19px; margin-bottom: 10px; }
.stat .lbl { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.stat .val { font-size: 22px; font-weight: 700; line-height: 1.25; margin-top: 2px; }
.stat .sub { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }

.bg-amber { background: var(--brand-soft); color: var(--brand); }
.bg-green { background: var(--green-soft); color: var(--green); }
.bg-red   { background: var(--red-soft);   color: var(--red); }
.bg-blue  { background: var(--blue-soft);  color: var(--blue); }
.bg-teal  { background: var(--teal-soft);  color: var(--teal); }
.bg-gray  { background: var(--surface-2);  color: var(--text-dim); }

.txt-green { color: var(--green); }
.txt-red   { color: var(--red); }
.txt-dim   { color: var(--text-dim); }
.txt-brand { color: var(--brand); }

/* ---------------- টেবিল ---------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
table.tbl th {
  background: var(--surface-2); text-align: start; padding: 10px 12px;
  font-weight: 600; font-size: 12.5px; color: var(--text-dim);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
/* সংখ্যার কলামে হেডারও ডানে থাকবে, না হলে হেডার আর সংখ্যা আলাদা পাশে পড়ে তেরছা দেখায় */
table.tbl th.num, table.tbl td.num, table.tbl tfoot td.num { text-align: end; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); }
.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.empty { padding: 40px 16px; text-align: center; color: var(--text-dim); }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; opacity: .6; }

/* ---------------- ব্যাজ ---------------- */

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-gray  { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }
.badge-blue  { background: var(--blue-soft);  color: var(--blue); }
.badge-amber { background: var(--brand-soft); color: var(--brand); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red   { background: var(--red-soft);   color: var(--red); }
.badge-teal  { background: var(--teal-soft);  color: var(--teal); }

/* ---------------- ফর্ম ---------------- */

.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: var(--text-dim); }
label .req { color: var(--red); }

input[type=text], input[type=number], input[type=date], input[type=time], input[type=month],
input[type=password], input[type=search], input[type=tel], input[type=email], input[type=file],
select, textarea {
  width: 100%; padding: 9px 11px; font-size: 14.5px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(245,158,11,.18);
}
textarea { min-height: 78px; resize: vertical; }
input[readonly], input:disabled, select:disabled { background: var(--surface-2); color: var(--text-dim); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font-size: 14.5px; font-weight: 600;
  font-family: inherit; cursor: pointer; white-space: nowrap; transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; color: #fff; }
.btn-sm  { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn-lg  { padding: 12px 22px; font-size: 16px; }
.btn-light { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-light:hover { background: var(--surface-2); color: var(--text); }
.btn-green { background: var(--green); }
.btn-red   { background: var(--red); }
.btn-blue  { background: var(--blue); }
.btn-teal  { background: var(--teal); }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: end; }
.toolbar .field { flex: 1 1 150px; }

/* ---------------- অ্যালার্ট ---------------- */

.alert { padding: 11px 15px; border-radius: 10px; margin-bottom: 14px; font-size: 14px;
  border: 1px solid transparent; display: flex; gap: 9px; align-items: flex-start; }
.alert-success { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.alert-danger  { background: var(--red-soft);   color: var(--red);   border-color: var(--red); }
.alert-warning { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-2); }
.alert-info    { background: var(--blue-soft);  color: var(--blue);  border-color: var(--blue); }

/* ---------------- পেজিনেশন ---------------- */

.pagination { display: flex; gap: 5px; padding: 12px 16px; flex-wrap: wrap; justify-content: center; }
.pagination a, .pagination span {
  min-width: 34px; height: 34px; padding: 0 9px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: grid; place-items: center; font-size: 13.5px;
}
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination a.active { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 700; }

/* ---------------- মডাল ---------------- */

.modal-bd {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100;
  display: none; align-items: flex-start; justify-content: center; padding: 24px 14px; overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal-bd.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 620px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border); margin: auto;
}
.modal.wide { max-width: 900px; }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .x { margin-inline-start: auto; background: none; border: 0; font-size: 22px;
  cursor: pointer; color: var(--text-dim); line-height: 1; }
.modal-body { padding: 18px; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------------- বিবিধ ---------------- */

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 5px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px; color: var(--text);
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip:hover { text-decoration: none; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 14px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; font-weight: 600; }

.thumb { width: 46px; height: 46px; border-radius: 9px; object-fit: cover;
  border: 1px solid var(--border); background: var(--surface-2); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: 0 0 36px; }

.progress { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand-2); }

.divider { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

.section-title { font-size: 13px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em; margin: 22px 0 10px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.mt-0 { margin-top: 0 } .mb-0 { margin-bottom: 0 }
.text-center { text-align: center }

.fab {
  position: fixed; inset-block-end: 22px; inset-inline-end: 22px; z-index: 55;
  width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: #fff;
  display: none; place-items: center; font-size: 26px; box-shadow: var(--shadow-lg); border: 0;
}

.backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 55; display: none; }

/* সাইডবার খোলা থাকলে পেছনের পাতা স্ক্রল বন্ধ */
body.nav-open { overflow: hidden; }

/* টুলটিপ একটু দ্রুত ও স্পষ্ট দেখানোর জন্য কার্সর ইঙ্গিত */
[title] { cursor: pointer; }
input[title], textarea[title], select[title] { cursor: auto; }
.backdrop.open { display: block; }

/* ---------------- মোবাইল ---------------- */

@media (max-width: 980px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-inline-start: 0; }
  #menuBtn { display: grid; }
  .content { padding: 13px; }
  .topbar { padding: 9px 12px; }
  .topbar h1 { font-size: 16px; }
  .stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .stat { padding: 12px; }
  .stat .val { font-size: 19px; }
  .stat .ic { width: 34px; height: 34px; font-size: 16px; margin-bottom: 7px; }
  .fab { display: grid; }
  .userchip .info { display: none; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; }
  body { font-size: 14.5px; }
}

/* ---------------- প্রিন্ট ---------------- */

@media print {
  .sidebar, .topbar, .no-print, .fab, .backdrop, .pagination { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; font-size: 12px; }
  .card { box-shadow: none !important; border: 0 !important; margin: 0 !important; }
  table.tbl { min-width: 0 !important; }
  table.tbl th, table.tbl td { border: 1px solid #999 !important; padding: 5px 7px !important; }
  a { color: #000 !important; text-decoration: none !important; }
  @page { margin: 12mm; }
}
