/* ==========================================
   MINI-ERP MODERN DESIGN SYSTEM & STYLES
   ========================================== */

:root {
  --bg: #0b1329;
  --card: #151f38;
  --tx: #f8fafc;
  --mu: #94a3b8;
  --ac: #f97316;
  --bd: #24324f;
  --bg-progress: #1e293b;
  --bd-progress: rgba(255, 255, 255, 0.08);
  --sidebar-w: 250px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.35), 0 2px 6px -1px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f1f4f8;
    --card: #ffffff;
    --tx: #0f172a;
    --mu: #64748b;
    --ac: #ea580c;
    --bd: #e2e8f0;
    --bg-progress: #e2e8f0;
    --bd-progress: #cbd5e1;
    --shadow-card: 0 4px 16px -2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 4px rgba(15, 23, 42, 0.06);
  }
}

:root[data-theme="light"] {
  --bg: #f1f4f8;
  --card: #ffffff;
  --tx: #0f172a;
  --mu: #64748b;
  --ac: #ea580c;
  --bd: #e2e8f0;
  --bg-progress: #e2e8f0;
  --bd-progress: #cbd5e1;
  --shadow-card: 0 4px 16px -2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 4px rgba(15, 23, 42, 0.06);
}

html,
body {
  height: 100%;
  margin: 0;
  scroll-padding-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--tx);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Layout Structure */
#erpApp {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

#erpSidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  transition: width 0.2s ease-in-out, transform 0.2s ease-in-out;
  overflow-x: hidden;
  box-shadow: var(--shadow-sm);
}

#erpMainContainer {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  transition: margin-left 0.2s ease-in-out;
}

/* Collapsible Sidebar States & Tooltip Support */
body.sidebar-collapsed #erpSidebar {
  width: 68px;
  overflow: hidden;
}

body.sidebar-collapsed #erpMainContainer {
  margin-left: 68px;
}

body.sidebar-collapsed .sidebar-header {
  padding: 18px 0;
  justify-content: center;
}

body.sidebar-collapsed .sidebar-logo-icon {
  margin: 0 auto;
}

body.sidebar-collapsed .sidebar-header-text,
body.sidebar-collapsed .nav-item > span:not(.nav-icon):not(.nav-badge),
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .sidebar-section-title {
  display: none !important;
}

body.sidebar-collapsed .nav-item {
  justify-content: center !important;
  padding: 12px 0 !important;
  width: 100% !important;
  position: relative;
}

body.sidebar-collapsed .nav-item .nav-icon {
  display: inline-flex !important;
  font-size: 20px !important;
  margin: 0 !important;
  width: auto !important;
}

body.sidebar-collapsed .sidebar-footer {
  justify-content: center;
  padding: 14px 0;
  width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

body.sidebar-collapsed .sidebar-avatar {
  margin: 0 auto;
  max-width: 36px;
  max-height: 36px;
  flex-shrink: 0;
}

body.sidebar-collapsed .nav-item:hover::after {
  content: attr(data-title);
  position: absolute;
  left: 74px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--card);
  color: var(--tx);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--bd);
  z-index: 99999;
  pointer-events: none;
}

/* Sidebar Components */
.sidebar-header {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--bd);
}

.sidebar-logo-icon {
  width: 58px;
  height: 42px;
  background: #ffffff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 2px 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.sidebar-brand-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--tx);
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: var(--mu);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.sidebar-section-title {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--mu);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--tx);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.nav-item:hover {
  background: rgba(249, 115, 22, 0.08);
  color: var(--ac);
}

.nav-item.active {
  background: var(--ac);
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.nav-item .nav-icon {
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 99px;
  line-height: 1;
}

.nav-item.active .nav-badge {
  background: #ffffff;
  color: var(--ac);
}

/* Sidebar Mini Planlama Takvimi & Hatırlatıcı */
.sidebar-calendar-widget {
  margin: 12px 6px 6px;
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 10px;
  box-shadow: var(--shadow-sm);
  transition: opacity 0.2s;
}

body.sidebar-collapsed .sidebar-calendar-widget {
  display: none !important;
}

.sidebar-cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.cal-nav-btn {
  background: transparent;
  border: 1px solid var(--bd);
  border-radius: 6px;
  color: var(--tx);
  cursor: pointer;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  transition: all 0.15s;
}

.cal-nav-btn:hover {
  background: var(--card);
  border-color: var(--ac);
  color: var(--ac);
}

.sidebar-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.cal-day-hdr {
  font-size: 9px;
  font-weight: 800;
  color: var(--mu);
  padding: 2px 0 4px;
}

.cal-day-cell {
  position: relative;
  font-size: 11px;
  font-weight: 600;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  color: var(--tx);
  transition: all 0.12s;
  user-select: none;
}

.cal-day-cell:hover {
  background: var(--card);
  border: 1px solid var(--bd);
  transform: scale(1.06);
}

.cal-day-cell.today {
  border: 1.5px solid var(--ac) !important;
  font-weight: 800;
  color: var(--ac);
}

.cal-day-cell.other-month {
  opacity: 0.28;
}

.cal-dot {
  position: absolute;
  bottom: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

.cal-dot.urgent {
  background: #ef4444;
  box-shadow: 0 0 5px #ef4444;
}

.cal-dot.due-soon {
  background: #f59e0b;
}

.cal-dot.normal {
  background: #10b981;
}

.cal-popover {
  position: fixed;
  z-index: 100000;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  max-width: 290px;
  width: 280px;
  font-size: 12px;
  backdrop-filter: blur(8px);
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--bd);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(249, 115, 22, 0.15);
  color: var(--ac);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--mu);
}

/* Header Bar */
#erpHeader {
  height: 64px;
  background: var(--card);
  border-bottom: 1px solid var(--bd);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 900;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.collapse-btn {
  background: none;
  border: none;
  color: var(--tx);
  font-size: 18px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.collapse-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 99px;
  background: rgba(22, 163, 74, 0.15);
  color: #16a34a;
  border: 1px solid rgba(22, 163, 74, 0.3);
  font-weight: 700;
}

/* General Layout & Content */
.erp-content {
  flex: 1;
  padding: 24px 28px;
}

.w {
  max-width: 100%;
  margin: 0;
  padding: 0;
}

h1 {
  font-size: 22px;
  margin: 4px 0 14px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.tab {
  padding: 9px 16px;
  border: 1px solid var(--bd);
  background: var(--card);
  color: var(--tx);
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
}

.tab.on {
  background: var(--ac);
  color: #fff;
  border-color: var(--ac);
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35);
}

.tab:hover {
  border-color: var(--ac);
}

.card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s ease-in-out;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.st {
  flex: 1;
  min-width: 90px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 10px 8px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.st:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.st b {
  display: block;
  font-size: 26px;
  color: var(--ac);
  font-weight: 800;
}

.st span {
  font-size: 11.5px;
  color: var(--mu);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.st small {
  display: block;
  color: var(--mu);
  font-size: 11px;
  font-weight: 600;
}

[data-theme="light"] .st {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .st small {
  color: #475569 !important;
  font-weight: 600;
}

[data-theme="light"] .st span {
  color: #334155;
  font-weight: 700;
}

form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

/* Order Edit Form overrides */
.order-edit-form {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  width: 100% !important;
}

.order-edit-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
  gap: 12px !important;
  width: 100% !important;
}

.order-edit-field {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
}

.order-edit-field label {
  font-size: 11.5px !important;
  font-weight: 700 !important;
  color: var(--mu) !important;
  margin: 0 !important;
}

.order-edit-field input {
  border-radius: 8px !important;
  height: 38px !important;
  padding: 8px 12px !important;
  margin: 0 !important;
}

input,
select,
textarea,
button.b {
  padding: 10px 12px;
  border: 1px solid var(--bd);
  border-radius: 99px;
  background: var(--bg);
  color: var(--tx);
  font-size: 14px;
  width: 100%;
  transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ac);
}

button,
button.b,
.tab,
.x {
  transition: all 0.2s ease-in-out;
}

button:active,
button.b:active,
.tab:active,
.x:active {
  transform: scale(0.97);
}

button.b {
  background: linear-gradient(180deg, var(--ac), color-mix(in srgb, var(--ac) 85%, #000));
  color: #fff;
  border: 0;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(249, 115, 22, 0.3);
  border-radius: 9px;
}

button.b:hover {
  filter: brightness(1.06);
}

button.b:active {
  filter: brightness(0.95);
}

.tw {
  overflow-x: auto;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--bd);
  white-space: nowrap;
}

#dashDsOrdersTable tr td:nth-child(1),
.tw table th:nth-child(1) {
  min-width: 95px;
}

#dashDsOrdersTable tr td:nth-child(2),
.tw table th:nth-child(2) {
  min-width: 130px;
}

#dashDsOrdersTable tr td:nth-child(3),
.tw table th:nth-child(3) {
  min-width: 110px;
}

#dashDsOrdersTable tr td:nth-child(4),
.tw table th:nth-child(4) {
  min-width: 105px;
}

#dashDsOrdersTable tr td:nth-child(5),
.tw table th:nth-child(5) {
  min-width: 115px;
  text-align: right;
  padding-right: 14px;
}

th {
  color: var(--mu);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td select {
  padding: 5px;
  width: auto;
}

.x {
  background: none;
  border: 1px solid #dc2626;
  border-radius: 6px;
  color: #dc2626;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 10px;
}

.x:hover {
  background: #dc2626;
  color: #fff;
}

.x.p {
  border-color: var(--ac);
  color: var(--ac);
}

.x.p:hover {
  background: var(--ac);
  color: #fff;
}

.em {
  color: var(--mu);
  text-align: center;
  padding: 18px;
}

.g {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.sk {
  border: 1px solid var(--bd);
  border-top: 4px solid var(--bd);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  background: var(--card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sk h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.sk .n {
  font-size: 40px;
  font-weight: 800;
  line-height: 1.25;
}

.sk small {
  display: block;
  color: var(--mu);
  font-size: 11.5px;
}

.sk .t {
  font-size: 12px;
  font-weight: 700;
  margin-top: 4px;
}

.sk.g0 {
  border-top-color: #16a34a;
}
.sk.g0 .n,
.sk.g0 .t {
  color: #16a34a;
}

.sk.y {
  border-top-color: #eab308;
  background: rgba(234, 179, 8, 0.1);
}
.sk.y .n,
.sk.y .t {
  color: #ca8a04;
}

.sk.r {
  border-top-color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
  animation: p 1.4s infinite;
}
.sk.r .n,
.sk.r .t {
  color: #dc2626;
}

@keyframes p {
  50% {
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.3);
  }
}

.al {
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
}
.al.r {
  background: rgba(220, 38, 38, 0.15);
  color: #dc2626;
  border: 1px solid #dc2626;
}
.al.y {
  background: rgba(234, 179, 8, 0.18);
  color: #ca8a04;
  border: 1px solid #eab308;
}

/* Marquee Ticker */
.ticker-wrapper {
  display: flex;
  align-items: center;
  background: linear-gradient(90deg, rgba(220, 38, 38, 0.22), rgba(234, 179, 8, 0.18));
  border: 1px solid rgba(220, 38, 38, 0.4);
  border-radius: 12px;
  padding: 8px 14px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.15);
}

.ticker-title {
  font-size: 12px;
  font-weight: 800;
  color: #ef4444;
  white-space: nowrap;
  margin-right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.04em;
}

.ticker-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.ticker-track {
  display: inline-flex;
  white-space: nowrap;
  animation: ticker 28s linear infinite;
  gap: 24px;
}

.ticker-track:hover {
  animation-play-state: paused;
}

.ticker-item {
  font-size: 13px;
  font-weight: 700;
  color: var(--tx);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.5);
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.15s;
}

.ticker-item:hover {
  color: var(--ac);
  border-color: var(--ac);
  transform: translateY(-1px);
}

[data-theme="light"] .ticker-wrapper {
  background: #fef2f2;
  border: 1px solid #fecaca;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.08);
}

[data-theme="light"] .ticker-title {
  color: #991b1b;
}

[data-theme="light"] .ticker-item {
  background: #ffffff;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

[data-theme="light"] .ticker-item:hover {
  background: #fee2e2;
  color: #7f1d1d;
  border-color: #f87171;
}

@keyframes ticker {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* Modals */
.custom-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.custom-modal-box {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* WhatsApp-like Chat */
.chat-container {
  display: flex;
  height: calc(100vh - 180px);
  min-height: 520px;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.chat-sidebar {
  width: 320px;
  border-right: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chat-thread-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.chat-thread-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.chat-thread-item.active {
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--bd);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--ac);
  flex-shrink: 0;
}

.chat-thread-info {
  flex: 1;
  min-width: 0;
}

.chat-thread-name {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--tx);
  margin-bottom: 2px;
}

.chat-thread-time {
  font-size: 10px;
  color: var(--mu);
}

.chat-thread-lastmsg {
  font-size: 12px;
  color: var(--mu);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread-badge {
  background: var(--ac);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 99px;
  margin-left: auto;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--card);
}

.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--bd);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
}

.chat-header-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--tx);
}

.chat-header-status {
  font-size: 11.5px;
  color: var(--mu);
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--card);
}

.chat-bubble-row {
  display: flex;
  width: 100%;
}

.chat-bubble-row.in {
  justify-content: flex-start;
}
.chat-bubble-row.out {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 14px;
  position: relative;
  word-break: break-word;
}

.chat-bubble.out {
  background: var(--ac);
  color: #ffffff;
  border-bottom-right-radius: 3px;
  box-shadow: 0 2px 6px rgba(249, 115, 22, 0.25);
}

.chat-bubble.in {
  background: var(--bg);
  border: 1px solid var(--bd);
  border-bottom-left-radius: 3px;
  color: var(--tx);
}

.chat-sender-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--ac);
  margin-bottom: 4px;
}

.chat-msg-text {
  font-size: 13.5px;
  line-height: 1.45;
}

.chat-msg-time {
  font-size: 10.5px;
  color: var(--mu);
  text-align: right;
  margin-top: 4px;
}

.chat-bubble.out .chat-msg-time {
  color: rgba(255, 255, 255, 0.85);
}

.chat-input-area {
  padding: 12px 18px;
  border-top: 1px solid var(--bd);
  background: var(--bg);
}

.chat-input-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input-form textarea {
  flex: 1;
  border-radius: 10px;
  border: 1px solid var(--bd);
  background: var(--card);
  color: var(--tx);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13.5px;
  resize: none;
}

/* Tooltip System */
.has-tooltip {
  position: relative;
}

.has-tooltip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 105%;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--bd);
  z-index: 1000;
  pointer-events: none;
}

/* ==========================================
   DASHBOARD 3'LÜ YATAY DÜZEN (TRI-GRID)
   ========================================== */
.dash-tri-grid {
  display: grid;
  grid-template-columns: 310px 1fr 310px;
  gap: 16px;
  margin-bottom: 20px;
  align-items: stretch;
}

.dash-tri-col {
  display: flex;
  flex-direction: column;
}

.dash-tri-col-main {
  min-width: 0;
}

@media (max-width: 1280px) {
  .dash-tri-grid {
    grid-template-columns: 1fr 1fr;
  }
  .dash-tri-col-main {
    grid-column: span 2;
    order: -1;
  }
}

@media (max-width: 768px) {
  .dash-tri-grid {
    grid-template-columns: 1fr;
  }
  .dash-tri-col-main {
    grid-column: span 1;
    order: 0;
  }
}

/* ==========================================
   PLANLAMA TAKVİMİ STİLLERİ
   ========================================== */
.sidebar-calendar-widget {
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 10px;
}

.sidebar-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cal-nav-btn {
  background: var(--card);
  border: 1px solid var(--bd);
  color: var(--tx);
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.cal-nav-btn:hover {
  background: var(--ac);
  color: #fff;
  border-color: var(--ac);
}

.sidebar-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  text-align: center;
}

.cal-day-hdr {
  font-size: 10px;
  font-weight: 800;
  color: var(--mu);
  padding: 3px 0;
  text-transform: uppercase;
}

.cal-day-cell {
  position: relative;
  font-size: 11px;
  font-weight: 600;
  color: var(--tx);
  padding: 4px 2px;
  border-radius: 6px;
  cursor: pointer;
  background: var(--card);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  transition: all 0.15s ease;
}

.cal-day-cell:hover {
  border-color: var(--ac);
  background: rgba(249, 115, 22, 0.12);
}

.cal-day-cell.other-month {
  color: var(--mu);
  opacity: 0.35;
}

.cal-day-cell.today {
  border-color: var(--ac);
  font-weight: 900;
  background: rgba(249, 115, 22, 0.18);
  color: var(--ac);
}

.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-top: 2px;
}

.cal-dot.urgent {
  background: #ef4444;
  box-shadow: 0 0 4px #ef4444;
}

.cal-dot.due-soon {
  background: #f97316;
}

.cal-dot.normal {
  background: #10b981;
}

.cal-popover {
  position: fixed;
  z-index: 100000;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  padding: 12px;
  width: 270px;
  max-width: 90vw;
  font-size: 12px;
  color: var(--tx);
}

/* ==========================================
   GELİŞMİŞ ÇİZGİ GRAFİK (LINE CHART)
   ========================================== */
.line-chart-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.line-chart-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.line-chart-title-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.line-chart-stats-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  background: var(--bg);
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--bd);
}

.line-stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.line-stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.line-chart-svg-wrap {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 165px;
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 6px 8px 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.line-chart-svg {
  width: 100%;
  height: 100%;
  min-height: 155px;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--bd);
  stroke-width: 1;
  stroke-dasharray: 2 4;
  opacity: 0.6;
}

.chart-target-line {
  stroke: #10b981;
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}

.chart-path-cur {
  fill: none;
  stroke: var(--ac);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-path-prev {
  fill: none;
  stroke: var(--mu);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 3 3;
  opacity: 0.7;
}

.chart-dot {
  cursor: pointer;
  transition: r 0.2s ease, stroke-width 0.2s ease;
}

.chart-dot:hover {
  r: 7;
  stroke-width: 3;
}

.chart-dot-cur {
  fill: var(--card);
  stroke: var(--ac);
  stroke-width: 2.5;
}

.chart-dot-prev {
  fill: var(--card);
  stroke: var(--mu);
  stroke-width: 1.5;
}

.chart-axis-text {
  font-size: 10.5px;
  fill: var(--mu);
  text-anchor: middle;
  font-weight: 600;
}

.chart-val-label {
  font-size: 9.5px;
  font-weight: 800;
  text-anchor: middle;
}

/* Tooltip floating card */
.chart-custom-tooltip {
  position: absolute;
  background: var(--card);
  color: var(--tx);
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  transform: translate(-50%, -120%);
  display: none;
  transition: opacity 0.15s ease;
}

.perf-bar-fill {
  width: 80%;
  max-width: 44px;
  border-radius: 6px 6px 0 0;
  transition: height 0.3s ease;
  position: relative;
  display: flex;
  justify-content: center;
}

.perf-bar-val {
  position: absolute;
  top: -20px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.perf-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: center;
}

.perf-data-table th,
.perf-data-table td {
  border: 1px solid var(--bd);
  padding: 6px 4px;
}

/* ==========================================
   MOBİL OPTİMİZASYON (CARD VIEW RESPONSIVE)
   ========================================== */
/* ==========================================
   MOBİL VE TABLET RESPONSIVE TASARIM SİSTEMİ
   ========================================== */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 19, 41, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-in-out;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 992px) {
  #erpSidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45);
  }

  #erpSidebar.open {
    transform: translateX(0);
  }

  #erpMainContainer {
    margin-left: 0 !important;
  }

  .mob-menu-btn {
    display: inline-flex !important;
  }

  .perf-grid-layout {
    grid-template-columns: 1fr;
  }

  .perf-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--bd);
    flex-direction: row;
    flex-wrap: wrap;
  }

  .chat-container {
    flex-direction: column;
    height: auto;
  }

  .chat-sidebar {
    width: 100%;
    height: 240px;
  }
}

@media (max-width: 768px) {
  /* 5. DOKUNMATİK HEDEF VE PADDING AYARLARI */
  .erp-content {
    padding: 12px 10px !important;
  }

  /* 4. MOBİL MENÜ VE ÜST BAR (NAVBAR & SIDEBAR) */
  #erpHeader {
    padding: 6px 10px !important;
    height: 54px !important;
    gap: 8px !important;
  }

  #erpHeader .collapse-btn[title*="Daralt"],
  #erpHeader .collapse-btn[title*="Genişlet"] {
    display: none !important;
  }

  .mob-menu-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 22px !important;
    border-radius: 8px !important;
    background: var(--card) !important;
    border: 1px solid var(--bd) !important;
    color: var(--tx) !important;
    cursor: pointer !important;
  }

  #erpHeader .header-left {
    gap: 6px !important;
  }

  #erpHeader .header-right {
    gap: 4px !important;
  }

  .header-action-btn {
    min-height: 44px !important;
    padding: 6px 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 13px !important;
    border-radius: 8px !important;
  }

  .header-action-btn .btn-text {
    display: none !important;
  }

  .header-action-btn .btn-icon {
    font-size: 16px !important;
    margin: 0 !important;
  }

  /* 1. MOBİL GRID VE KART YERLEŞİMİ (BREAKPOINTS) */
  .stats {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 14px !important;
  }

  .stats > div:nth-child(5) {
    grid-column: span 2 !important;
  }

  .st {
    padding: 10px 12px !important;
    min-height: auto !important;
    border-radius: 10px !important;
    gap: 2px !important;
  }

  .st b {
    font-size: 20px !important;
    line-height: 1.2 !important;
  }

  .st span {
    font-size: 11.5px !important;
    font-weight: 700 !important;
  }

  .st small {
    font-size: 10px !important;
    margin-top: 2px !important;
  }

  /* 3'LÜ ORTA BLOK DİKEY DİZİLİMİ (1. Çizgi Grafik, 2. Donut Dağılım, 3. Kritik Stok) */
  .dash-tri-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
  }

  .dash-tri-col-main {
    order: 1 !important; /* 1. Çizgi Grafik (Performans Trendi) */
  }

  .dash-tri-col-donut {
    order: 2 !important; /* 2. İş Emirleri Dağılımı Donut & Takvim */
  }

  .dash-tri-col-stock {
    order: 3 !important; /* 3. Kritik Döküm Stokları */
  }

  /* 2. MOBİL ÇİZGİ GRAFİK VE ZAMAN KONTROLLERİ */
  .line-chart-card {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }

  .line-chart-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .line-chart-header > div:last-child {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 4px !important;
    gap: 4px !important;
    scrollbar-width: none !important;
  }

  .line-chart-header > div:last-child::-webkit-scrollbar {
    display: none !important;
  }

  .line-chart-header .tabs {
    display: flex !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    flex-shrink: 0 !important;
    gap: 3px !important;
  }

  .line-chart-stats-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 6px 12px !important;
    padding: 6px 10px !important;
  }

  .line-stat-pill {
    font-size: 11px !important;
  }

  .line-chart-svg-wrap {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
    min-height: 140px !important;
    padding: 4px 4px !important;
  }

  .line-chart-svg {
    width: 100% !important;
    height: auto !important;
    max-height: 160px !important;
    display: block !important;
  }

  /* 3. TABLOLARIN MOBİLDE KAYDIRILABİLİRLİĞİ (RESPONSIVE TOUCH-SCROLL TABLES) */
  .tw {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-bottom: 6px !important;
    border-radius: 8px !important;
  }

  .tw table {
    min-width: 540px !important;
    width: 100% !important;
    display: table !important;
  }

  .tw thead {
    display: table-header-group !important;
  }

  .tw tbody {
    display: table-row-group !important;
  }

  .tw tr {
    display: table-row !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
  }

  .tw th,
  .tw td {
    display: table-cell !important;
    padding: 8px 10px !important;
    font-size: 12.5px !important;
    text-align: left !important;
    border-bottom: 1px solid var(--bd) !important;
    white-space: nowrap !important;
  }

  .tw td::before {
    display: none !important;
  }

  /* Kart içi filtre çipleri - Mobilde yatay kaydırılabilir */
  .card > div:first-child .tabs {
    display: flex !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 4px !important;
    gap: 4px !important;
    width: 100% !important;
    scrollbar-width: none !important;
  }

  .card > div:first-child .tabs::-webkit-scrollbar {
    display: none !important;
  }

  /* Dokunmatik hedefler (Touch targets >= 44px) */
  .nav-item {
    min-height: 46px !important;
    padding: 11px 14px !important;
    font-size: 14.5px !important;
  }

  .b, .tab, button:not(.cal-day-cell):not(.nav-badge):not(.cal-nav-btn) {
    min-height: 44px !important;
  }

  .cal-day-cell {
    min-height: 28px !important;
  }
}

/* ==========================================
   YAZDIRMA VE DÖKÜM RAPORU (MEDIA PRINT)
   ========================================== */
#pa {
  display: none;
}

@page {
  margin: 8mm;
  size: auto;
}

@media print {
  html,
  body {
    background: #ffffff !important;
    color: #000000 !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #erpApp,
  #erpLoginModal,
  .custom-modal-backdrop,
  aside,
  header,
  nav,
  button,
  .ticker-wrapper {
    display: none !important;
  }

  #pa {
    display: block !important;
    visibility: visible !important;
    width: 100% !important;
    background: #ffffff !important;
    color: #000000 !important;
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #pa * {
    visibility: visible !important;
  }

  #pa img {
    display: inline-block !important;
    max-height: 60px !important;
    object-fit: contain !important;
  }

  #pa .pano-logo-img {
    max-height: 140px !important;
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
  }

  .pano-2x2-container {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: 1fr 1fr !important;
    width: 170mm !important;
    height: 217mm !important;
    margin: 40mm auto !important;
    border: 2px solid #000 !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .pano-sheet {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  #pa h2 {
    font-size: 18px !important;
    font-weight: 800 !important;
    margin: 0 0 6px !important;
    color: #000000 !important;
  }

  #pa p,
  #pa .pd {
    font-size: 12px !important;
    color: #333333 !important;
    margin: 2px 0 10px !important;
  }

  #pa table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 11.5px !important;
    margin-top: 8px !important;
  }

  #pa th,
  #pa td {
    border: 1px solid #444444 !important;
    padding: 5px 8px !important;
    white-space: normal !important;
    color: #000000 !important;
  }

  #pa th {
    background: #f1f5f9 !important;
    font-weight: 700 !important;
  }

  .fm {
    border: 2px solid #000000 !important;
    padding: 12px !important;
    color: #000000 !important;
    background: #ffffff !important;
  }

  .fm h2 {
    text-align: center !important;
    font-size: 18px !important;
    margin: 0 0 8px !important;
    border-bottom: 2px solid #000000 !important;
    padding-bottom: 6px !important;
  }

  .fr {
    display: flex !important;
    border-bottom: 1px solid #888888 !important;
    padding: 4px 0 !important;
    font-size: 13px !important;
  }

  .fr b {
    width: 38% !important;
    padding: 4px !important;
    border-right: 1px solid #888888 !important;
  }

  .fr span {
    flex: 1 !important;
    padding: 4px !important;
  }

  .fr.big {
    font-size: 15px !important;
    font-weight: bold !important;
  }

  .box {
    height: 55mm !important;
    border: 1px solid #888888 !important;
    margin-top: 10px !important;
    padding: 6px !important;
    font-size: 12px !important;
  }

  .sg {
    display: flex !important;
    gap: 12px !important;
    margin-top: 16px !important;
  }

  .sg div {
    flex: 1 !important;
    border-top: 1px solid #000000 !important;
    text-align: center !important;
    font-size: 12px !important;
    padding-top: 4px !important;
    height: 45px !important;
  }
}
