:root {
  --bg: #eef3f9;
  --surface: #ffffff;
  --surface2: #f6f9fd;
  --border: #dce7f5;
  --border-strong: #c3d6ef;
  --text: #17263d;
  --muted: #5d7290;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eef4ff;
  --primary-grad: linear-gradient(135deg, #3b82f6 0%, #2563eb 55%, #1d4ed8 100%);
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 38, 61, .04), 0 6px 24px -6px rgba(37, 99, 235, .12);
  --shadow-lg: 0 4px 12px rgba(23, 38, 61, .06), 0 24px 48px -12px rgba(37, 99, 235, .22);
  --header-bg: linear-gradient(120deg, #1e3a8a 0%, #1d4ed8 55%, #2563eb 100%);
  --ring: 0 0 0 3px rgba(37, 99, 235, .18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: Vazirmatn, Tahoma, "Segoe UI", sans-serif;
  background:
    radial-gradient(1000px 480px at 85% -10%, rgba(59, 130, 246, .10), transparent 60%),
    radial-gradient(800px 420px at 0% 100%, rgba(37, 99, 235, .07), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

::selection { background: rgba(37, 99, 235, .18); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #b9cbe6 transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #b9cbe6; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #93aed3; background-clip: content-box; border: 2px solid transparent; }
*::-webkit-scrollbar-track { background: transparent; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}

.auth-card {
  max-width: 420px;
  margin: 60px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.logo { text-align: center; margin-bottom: 24px; }

.logo h1 {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -.5px;
  background: var(--primary-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.logo p { color: var(--muted); font-size: .9rem; margin-top: 4px; }

.form-group { margin-bottom: 16px; }

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: .875rem;
  color: var(--muted);
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}

input::placeholder, textarea::placeholder { color: #9db1cc; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) {
  border-color: #a8c0e2;
}

textarea { min-height: 90px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .1s, border-color .15s, color .15s;
}

.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--primary-grad);
  color: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, .35);
}
.btn-primary:hover { background: linear-gradient(135deg, #2f74f0 0%, #1d4ed8 55%, #1a44c2 100%); box-shadow: 0 4px 12px rgba(37, 99, 235, .4); }
.btn-primary.full { width: 100%; }
.btn-secondary { background: #fff; color: var(--primary); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--primary-light); border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: .9rem;
  border: 1px solid transparent;
}

.alert-error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alert-info { background: var(--primary-light); border-color: var(--border); color: #1d4ed8; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #b45309; }

.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-3 { margin-bottom: 16px; }
.text-muted { color: var(--muted); font-size: .875rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.app-header {
  background: var(--header-bg);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: 0 4px 20px rgba(30, 58, 138, .35);
  position: sticky;
  top: 0;
  z-index: 60;
}

.app-header .brand { font-weight: 800; font-size: 1.3rem; letter-spacing: -.3px; text-shadow: 0 1px 3px rgba(0,0,0,.15); }
.app-header .user-info { font-size: .875rem; opacity: .92; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.app-header .btn-secondary { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.35); backdrop-filter: blur(4px); }
.app-header .btn-secondary:hover { background: rgba(255,255,255,.25); border-color: rgba(255,255,255,.6); }
.header-locale-select {
  background: rgba(255,255,255,.14);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: .8rem;
  cursor: pointer;
}
.header-locale-select option { color: #222; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.reports-subtabs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.nav-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 24px;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  position: sticky;
  top: 62px;
  z-index: 50;
}

.nav-tab {
  padding: 8px 18px;
  border-radius: 99px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: .92rem;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}

.nav-tab.active {
  background: var(--primary-grad);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .35);
}

.nav-tab:hover:not(.active) { background: var(--primary-light); color: var(--primary); }

.nav-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-inline-start: 6px;
  border-radius: 99px;
  background: var(--danger, #dc2626);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  animation: navBadgePulse 1.6s ease-in-out infinite;
}

@keyframes navBadgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .45); }
  50% { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0); }
}

.panel { display: none; }
.panel.active { display: block; animation: panelIn .22s ease; }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.05rem;
  margin-bottom: 16px;
  color: #1e40af;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 4px;
  background: var(--primary-grad);
  flex: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

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

table { width: 100%; border-collapse: collapse; font-size: .9rem; }

th, td {
  padding: 11px 12px;
  text-align: right;
  border-bottom: 1px solid #e8eef7;
}

th {
  color: var(--muted);
  font-weight: 700;
  font-size: .82rem;
  background: var(--surface2);
  white-space: nowrap;
}

thead th:first-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
thead th:last-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }

tr:hover td { background: var(--primary-light); }
tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
}

.badge-open { background: #dcfce7; color: #15803d; }
.badge-closed { background: #eef2f7; color: var(--muted); }
.badge-priority { background: #fef3c7; color: #b45309; }
.badge-source-api { background: #dbeafe; color: #1d4ed8; }
.badge-source-web { background: #f3e8ff; color: #7e22ce; }

.api-assign-row {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.ticket-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  min-height: 520px;
  align-items: start;
}

@media (max-width: 900px) { .ticket-layout { grid-template-columns: 1fr; } }

.ticket-list { overflow-y: auto; max-height: 620px; padding-left: 4px; }

.ticket-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #e4ebf5;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .1s;
  background: #fff;
}

.ticket-item-body {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.ticket-item-close {
  flex-shrink: 0;
  white-space: nowrap;
}

.ticket-item-actions {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  white-space: nowrap;
}

.ticket-item:hover {
  border-color: var(--primary);
  box-shadow: 0 3px 10px rgba(37, 99, 235, .12);
  transform: translateY(-1px);
}

.ticket-item.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: inset 3px 0 0 var(--primary);
}

.ticket-item h4 { font-size: .95rem; font-weight: 700; margin-bottom: 3px; line-height: 1.35; }
.ticket-item-subtitle { font-size: .8rem; color: var(--muted); margin-bottom: 4px; line-height: 1.35; }
.ticket-item small { color: var(--muted); font-size: .75rem; }

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.message {
  position: relative;
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 85%;
  box-shadow: 0 1px 2px rgba(23, 38, 61, .06);
}

.message.in {
  background: #fff;
  align-self: flex-start;
  border: 1px solid #e4ebf5;
  border-radius: 14px 14px 14px 4px;
}

.message.out {
  background: linear-gradient(135deg, #eef4ff 0%, #e3edff 100%);
  align-self: flex-end;
  border: 1px solid #d3e2fa;
  border-radius: 14px 14px 4px 14px;
}

.message .meta { font-size: .75rem; color: var(--muted); margin-bottom: 4px; }

/* Web chat panel */
.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  min-height: 560px;
  align-items: start;
}

@media (max-width: 900px) { .chat-layout { grid-template-columns: 1fr; } }

.chat-conv-col, .chat-thread-col {
  display: flex;
  flex-direction: column;
  min-height: 560px;
}

.chat-conv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 620px;
  padding-left: 4px;
}

.chat-conv-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid #e4ebf5;
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.chat-conv-item:hover { border-color: var(--primary); box-shadow: 0 3px 10px rgba(37, 99, 235, .12); }

.chat-conv-item.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: inset 3px 0 0 var(--primary);
}

.chat-conv-item-title { font-weight: 700; font-size: .92rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chat-conv-item-preview { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-conv-item-time { color: var(--muted); font-size: .72rem; flex-shrink: 0; }

.chat-thread-col { flex: 1; }
.chat-thread-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
.chat-thread-content { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-thread-header h3 { margin: 0; font-size: 1.05rem; }

.chat-thread-content .chat-messages { flex: 1; max-height: none; min-height: 0; }

.chat-send-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-send-form textarea { resize: none; flex: 1; max-height: 120px; min-height: 44px; }

.chat-contact-scroll { max-height: 360px; }

.chat-contact-list { display: flex; flex-direction: column; gap: 6px; }

.chat-contact-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
  transition: border-color .12s, background .12s;
}

.chat-contact-item:hover { background: var(--primary-light); border-color: var(--border-strong); }
.chat-contact-item.selected { border-color: var(--primary); background: var(--primary-light); }
.chat-contact-item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chat-contact-item-name { font-weight: 600; font-size: .9rem; }
.chat-contact-item-sub { color: var(--muted); font-size: .78rem; }
.chat-contact-item input[type="checkbox"] { width: auto; flex-shrink: 0; accent-color: var(--primary); }

/* Chat — emoji / attachments */
.chat-send-form-wrap { position: relative; }

.chat-send-tools { display: flex; gap: 4px; align-self: flex-end; }

.chat-tool-btn {
  padding: 8px 10px;
  font-size: 1.05rem;
  line-height: 1;
  min-height: 44px;
}

.chat-emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  width: 280px;
  max-height: 220px;
  overflow-y: auto;
}

.chat-emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.chat-emoji-grid button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 5px;
  border-radius: 6px;
  line-height: 1;
}

.chat-emoji-grid button:hover { background: var(--primary-light); }

.chat-attachment-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
}

.chat-attachment-preview img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.chat-attachment-preview-info { flex: 1; min-width: 0; font-size: .82rem; color: var(--muted); }
.chat-attachment-preview-name { display: block; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attachment-preview-remove { background: none; border: none; color: var(--danger, #dc2626); cursor: pointer; font-size: 1.1rem; padding: 0 4px; }

.message-attachment-image {
  display: block;
  max-width: 220px;
  max-height: 220px;
  border-radius: 10px;
  cursor: pointer;
  object-fit: cover;
}

.message-attachment-image-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 120px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .05);
  color: var(--muted);
  font-size: .78rem;
}

.message-attachment-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .6);
  border: 1px solid #e4ebf5;
  cursor: pointer;
  min-width: 180px;
}

.message.out .message-attachment-file { background: rgba(255, 255, 255, .5); }
.message-attachment-file-icon { font-size: 1.4rem; }
.message-attachment-file-info { display: flex; flex-direction: column; min-width: 0; }
.message-attachment-file-name { font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.message-attachment-file-size { font-size: .72rem; color: var(--muted); }
.message-caption { margin-top: 6px; }

.message-attachment-voice,
.message-attachment-voice-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .6);
  border: 1px solid #e4ebf5;
  min-width: 200px;
  font-size: .82rem;
  color: var(--muted);
}

.message.out .message-attachment-voice,
.message.out .message-attachment-voice-loading { background: rgba(255, 255, 255, .5); }
.message-attachment-audio { max-width: 220px; height: 34px; }
.message-attachment-voice-duration { font-size: .72rem; color: var(--muted); flex-shrink: 0; }

.message-attachment-location {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .6);
  border: 1px solid #e4ebf5;
  min-width: 180px;
  text-decoration: none;
  color: inherit;
}

.message.out .message-attachment-location { background: rgba(255, 255, 255, .5); }
.message-attachment-location-icon { font-size: 1.4rem; }
.message-attachment-location-info { display: flex; flex-direction: column; min-width: 0; }
.message-attachment-location-title { font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.message-attachment-location-coords { font-size: .72rem; color: var(--muted); }

/* Chat — reply / forward */
.message-actions {
  position: absolute;
  top: -14px;
  left: 6px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .12s;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(23,38,61,.12));
  padding: 2px;
}

.message.out .message-actions { left: auto; right: 6px; }
.message:hover .message-actions,
.message:focus-within .message-actions { opacity: 1; }

.message-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .95rem;
  padding: 3px 6px;
  border-radius: 6px;
  line-height: 1;
  color: var(--muted);
}

.message-action-btn:hover { background: var(--primary-light); color: var(--primary); }

.message-reply-quote {
  display: block;
  margin-bottom: 6px;
  padding: 6px 10px;
  border-right: 3px solid var(--primary);
  border-radius: 6px;
  background: rgba(37, 99, 235, .06);
  cursor: pointer;
  font-size: .82rem;
}

.message.out .message-reply-quote { border-right: none; border-left: 3px solid var(--primary); }

.message-reply-quote-sender { display: block; font-weight: 700; color: var(--primary); margin-bottom: 2px; }
.message-reply-quote-snippet { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.message-forwarded-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .74rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 4px;
}

.message.highlight { animation: messageHighlight 1.6s ease; }
@keyframes messageHighlight {
  0%, 100% { box-shadow: 0 1px 2px rgba(23, 38, 61, .06); }
  20% { box-shadow: 0 0 0 3px rgba(37, 99, 235, .45); }
}

.chat-reply-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-right: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface2);
}

.chat-reply-preview-info { flex: 1; min-width: 0; font-size: .82rem; }
.chat-reply-preview-sender { display: block; font-weight: 700; color: var(--primary); }
.chat-reply-preview-snippet { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-reply-preview-remove { background: none; border: none; color: var(--danger, #dc2626); cursor: pointer; font-size: 1.1rem; padding: 0 4px; }

/* Chat — conversation list unread badge */
.chat-conv-item-unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.chat-conv-item.has-unread .chat-conv-item-preview { font-weight: 700; color: var(--text); }

/* Chat — image lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 14, 28, .92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: overlayIn .18s ease;
}

.lightbox-toolbar {
  position: absolute;
  top: 16px;
  inset-inline: 16px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  z-index: 1;
}

.lightbox-body {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chatLightboxImage {
  max-width: min(90vw, 1000px);
  max-height: 82vh;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  object-fit: contain;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.permission-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-weight: normal;
  transition: border-color .15s, background .15s;
}

.permission-grid label:hover { border-color: var(--border-strong); background: var(--primary-light); }

.permission-grid input { width: auto; accent-color: var(--primary); }

input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }

.secret-box {
  background: #0f1c33;
  color: #8fc0ff;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-family: Consolas, monospace;
  font-size: .85rem;
  word-break: break-all;
  margin: 12px 0;
  border: 1px solid #24365a;
  direction: ltr;
  text-align: left;
}

.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-bar select { max-width: 220px; }

.customer-search-wrap { min-width: 260px; max-width: 360px; flex: 1; }

.customer-search { position: relative; }

.customer-search-input { width: 100%; }

.customer-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 260px;
  overflow-y: auto;
}

.customer-search-item {
  display: block;
  width: 100%;
  text-align: right;
  padding: 10px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  border-bottom: 1px solid #f1f5fb;
  transition: background .12s;
}

.customer-search-item:hover { background: var(--primary-light); }

.customer-search-item small {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  margin-top: 2px;
}

.customer-search-empty {
  padding: 12px;
  color: var(--muted);
  text-align: center;
  font-size: .9rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 44, 0.5);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  animation: overlayIn .18s ease;
}

@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  padding: 22px;
  animation: modalIn .22s cubic-bezier(.16, 1, .3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.modal-wide { max-width: 820px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.profile-field {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: border-color .15s;
}

.profile-field:hover { border-color: var(--border-strong); }

.profile-field .lbl {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.profile-field .val { font-weight: 600; word-break: break-word; }

.profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.profile-section { margin-top: 16px; }

.profile-section h3 {
  font-size: .95rem;
  margin-bottom: 8px;
  color: var(--primary);
  font-weight: 700;
}

.profile-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.profile-table th, .profile-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: right;
}

.profile-table th { background: var(--primary-light); border-radius: 0; }

.badge-garanti-ok { background: #dcfce7; color: #166534; }
.badge-garanti-no { background: #fee2e2; color: #991b1b; }
.badge-garanti-none { background: #eef2f7; color: #64748b; }
.badge-garanti-warn { background: #fef3c7; color: #92400e; }
.badge-daemi { background: #dcfce7; color: #166534; }
.badge-movaghat { background: #ffedd5; color: #9a3412; }

.ticket-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.ticket-actions-edit { margin-bottom: 0; }

.ticket-search-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ticket-search-bar input[type="text"] {
  flex: 1 1 240px;
  min-width: 0;
}

.ticket-group-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.ticket-group-bar select {
  min-width: 200px;
  max-width: 320px;
}

.ticket-bar-label {
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.ticket-list-count {
  margin-right: auto;
  font-size: .85rem;
}

.ticket-actions select { max-width: 160px; }
.ticket-transfer-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ticket-detail-edit select { max-width: 180px; }
.outbound-toggle label { display: block; margin-bottom: 6px; font-weight: 600; }
.form-group-highlight {
  padding: 14px 16px;
  border: 1px solid var(--border, #ddd);
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.06);
  margin-bottom: 16px;
}
.required-mark { color: #dc2626; font-weight: 700; }

.share-menu { position: relative; display: inline-block; }
.share-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 20;
  overflow: hidden;
}
.share-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: right;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}
.share-menu-dropdown button:hover { background: #f3f4f6; }

.ticket-list-toolbar { margin-bottom: 16px; }

.ticket-toolbar-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .9rem;
  white-space: nowrap;
}

.company-options .company-option-btn {
  text-align: right;
  padding: 12px 14px;
}

.channel-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.channel-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
}

.channel-option:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

.channel-option input {
  margin: 0;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px 14px;
  text-align: center;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--primary-grad);
}

.stat-card .num { font-size: 1.7rem; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat-card .lbl { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.stat-card .stat-sub { font-size: .72rem; color: var(--muted); margin-top: 4px; opacity: .85; }

.stat-card-clickable {
  cursor: pointer;
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.stat-card-clickable:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.stat-card-warn .num { color: #b45309; }
.stat-card-warn::before { background: linear-gradient(135deg, #fbbf24, #d97706); }
.stat-card-warn { background: #fffdf5; border-color: #fde68a; }

.stat-card-success .num { color: #15803d; }
.stat-card-success::before { background: linear-gradient(135deg, #4ade80, #16a34a); }
.stat-card-success { background: #f0fdf4; border-color: #bbf7d0; }
.stat-card-success.stat-card-clickable:hover { border-color: #86efac; }

.overview-company-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.company-public-id {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  font-family: monospace;
  letter-spacing: .5px;
  color: var(--primary);
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  padding: 2px 8px;
  vertical-align: middle;
  margin-inline-end: 6px;
}

.staff-presence-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -6px 0 18px;
}

.staff-presence-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px 4px 8px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.staff-presence-item:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Compact activity heatmap — 30 days in 2×15 grid */
.activity-heatmap-wrap {
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.activity-heatmap-wrap.is-centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-bottom: none;
  margin: .75rem 0 1.25rem;
  padding-bottom: 0;
}
/* Overview "my activity" sits on page bg (#eef3f9); give it a white panel so empty cells stay visible */
.overview-my-heatmap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: .75rem auto 1.25rem;
  padding: .85rem 1.1rem .9rem;
  max-width: max-content;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.overview-my-heatmap .activity-heatmap-wrap {
  margin: 0;
  padding: 0;
  border: none;
}
.activity-heatmap-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: .35rem .75rem;
  margin-bottom: .45rem;
}
.activity-heatmap-title {
  font-size: .9rem;
  font-weight: 600;
}
.activity-heatmap-meta {
  font-size: .75rem;
}
.activity-heatmap {
  display: grid;
  grid-template-columns: repeat(15, 11px);
  gap: 3px;
  width: max-content;
  max-width: 100%;
}
.activity-heat-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: #ebf0f7;
  border: 1px solid rgba(23, 38, 61, .08);
  display: block;
  box-sizing: border-box;
}
.activity-heat-cell.level-0 { background: #ebf0f7; border-color: rgba(23, 38, 61, .1); }
.activity-heat-cell.level-1 { background: #bfdbfe; border-color: transparent; }
.activity-heat-cell.level-2 { background: #60a5fa; border-color: transparent; }
.activity-heat-cell.level-3 { background: #2563eb; border-color: transparent; }
.activity-heat-cell.level-4 { background: #1e3a8a; border-color: transparent; }
.activity-heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-top: .4rem;
  font-size: .7rem;
}
.activity-heatmap-legend .activity-heat-cell {
  width: 9px;
  height: 9px;
}

.presence-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Green = online on web */
.presence-online { background: #16a34a; box-shadow: 0 0 0 2px rgba(22,163,74,.2); }
/* Blue = online on mobile app */
.presence-online-mobile { background: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.2); }
.presence-offline { background: #cbd5e1; }

.header-link { color: #fff; text-decoration: none; border-bottom: 1px dashed rgba(255,255,255,.5); padding-bottom: 1px; }
.header-link:hover { text-decoration: none; border-bottom-style: solid; }

.customer-view-page { max-width: 1100px; }

.customer-search-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.customer-search-bar input { max-width: 220px; }

.tab-panel { margin-top: 0; }
.tab-panel.hidden { display: none !important; }

.table-scroll { overflow-x: auto; border-radius: var(--radius-sm); }

.mb-3 { margin-bottom: 16px; }
.mb-2 { margin-bottom: 8px; }
.mt-3 { margin-top: 16px; }
.gap-2 { gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.profile-table td.btn-group,
table td.btn-group { white-space: nowrap; }

.readonly-summary {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: .88rem;
  color: var(--muted);
}

.align-center { align-items: center; }

.hidden { display: none !important; }
.no-access { text-align: center; padding: 48px; color: var(--muted); }

/* Auth pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 24px;
  width: 100%;
  max-width: 960px;
  align-items: start;
}

#registerAside { display: none; }
#registerAside.auth-aside-visible { display: block; }

.auth-layout-wide {
  grid-template-columns: minmax(0, 420px);
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
  justify-items: stretch;
}

.auth-layout-wide .auth-card-form {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.auth-aside {
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-aside h2 {
  color: var(--primary);
  margin-bottom: 12px;
  font-size: 1.25rem;
  font-weight: 800;
}

.auth-aside-list {
  margin: 16px 0 24px;
  padding-right: 20px;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.9;
}

.auth-aside-list li::marker { color: var(--primary); }

.auth-aside-action {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.auth-card-wide {
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.auth-card-form {
  margin: 0;
}

.info-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.info-box h3 {
  font-size: .95rem;
  margin-bottom: 10px;
  color: var(--text);
}

.info-steps {
  padding-right: 20px;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.9;
}

.info-steps li::marker { color: var(--primary); font-weight: 700; }

.plan-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.plan-fieldset legend {
  padding: 0 8px;
  font-size: .875rem;
  color: var(--muted);
  font-weight: 600;
}

.plan-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.plan-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .1s;
  background: #fff;
}

.plan-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.plan-card input { display: none; }

.plan-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 3px 10px rgba(37, 99, 235, .15);
}

.plan-name { font-weight: 800; font-size: .95rem; }
.plan-desc { font-size: .78rem; color: var(--muted); line-height: 1.5; }
.plan-note { font-size: .82rem; margin-top: 10px; }

.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #991b1b; }

.plan-select { min-width: 110px; padding: 6px 8px; font-size: .85rem; }

@media (max-width: 768px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-card { margin: 24px auto; padding: 24px 20px; }
  .plan-cards { grid-template-columns: 1fr; }

  .container { padding: 16px 12px; }

  .app-header {
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 60;
  }

  .app-header .user-info {
    width: 100%;
    flex-basis: 100%;
  }

  .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 8px 12px;
    gap: 8px;
    scroll-snap-type: x proximity;
  }

  .nav-tab {
    flex-shrink: 0;
    min-height: 44px;
    padding: 10px 16px;
    scroll-snap-align: start;
    touch-action: manipulation;
  }

  .stat-cards,
  .accounting-stat-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
    width: 100%;
  }

  .stat-card {
    padding: 14px 10px;
    min-width: 0;
    overflow: visible;
  }

  .stat-card .num { font-size: 1.4rem; }

  .grid-2 { grid-template-columns: 1fr; }

  .ticket-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .ticket-list { max-height: none; }

  .ticket-item {
    min-height: 44px;
    touch-action: manipulation;
  }

  .filter-bar select,
  .filter-bar input:not(.accounting-invoice-search) {
    max-width: 100%;
    flex: 1 1 100%;
  }

  .accounting-invoice-filter {
    flex-wrap: nowrap;
  }

  .accounting-invoice-filter .accounting-invoice-search {
    width: min(180px, 55vw);
    max-width: 180px;
    flex: 0 1 auto;
  }

  .customer-search-wrap {
    min-width: 0;
    max-width: 100%;
    flex: 1 1 100%;
  }

  .ticket-search-bar input[type="text"] {
    flex: 1 1 100%;
    min-width: 0;
  }

  .ticket-group-bar select {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .ticket-actions select { max-width: 100%; }

  .accounting-layout { min-height: 0; }

  .accounting-sticky-header {
    position: static;
    box-shadow: none;
    padding-bottom: 0;
  }

  .accounting-stat-cards {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    grid-template-columns: unset;
    gap: 8px;
    margin-bottom: 12px;
    scroll-snap-type: x proximity;
  }

  .accounting-stat-cards .stat-card {
    flex: 0 0 min(148px, 42vw);
    scroll-snap-align: start;
    padding: 12px 10px;
  }

  .accounting-stat-cards .stat-card .num { font-size: 1.25rem; }

  .accounting-list-scroll {
    min-height: 240px;
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    margin-bottom: 12px;
  }

  .accounting-invoices-table {
    min-width: 640px;
  }

  .invoice-actions-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .invoice-actions-buttons {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    gap: 8px;
  }

  .invoice-actions-buttons .btn {
    flex-shrink: 0;
  }

  .invoice-selection-hint {
    font-size: .85rem;
  }

  .accounting-subtabs,
  .master-data-subtabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .accounting-subtabs .btn,
  .master-data-subtabs .btn {
    flex-shrink: 0;
    min-height: 44px;
    touch-action: manipulation;
  }

  .modal-overlay {
    padding: 12px;
    align-items: flex-start;
  }

  .modal-card {
    max-width: 100%;
    width: 100%;
    padding: 16px;
    margin: auto 0;
  }

  .modal-wide { max-width: 100%; }

  .profile-table th,
  .profile-table td {
    padding: 8px 10px;
    font-size: .85rem;
  }

  .invoice-totals-summary { max-width: 100%; }

  .btn,
  .company-option-btn {
    min-height: 44px;
    touch-action: manipulation;
  }
}

@media (max-width: 400px) {
  .stat-cards {
    grid-template-columns: 1fr;
  }
}

.btn-phone-code {
  background: linear-gradient(135deg, #e879d9 0%, #c55ec1 100%);
  border-color: #c55ec1;
  color: #fff;
  box-shadow: 0 2px 6px rgba(197, 94, 193, .35);
}
.btn-phone-code:hover { background: linear-gradient(135deg, #d968ca 0%, #b350af 100%); color: #fff; }

.phone-code-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--surface2);
}
.phone-code-section h3 { font-size: .95rem; margin-bottom: 6px; }
.section-hint { font-size: .82rem; margin-bottom: 10px; }

.phone-code-results label {
  display: block;
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.phone-code-result-box {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--primary-light);
  direction: ltr;
  user-select: all;
  transition: border-color .15s, box-shadow .15s;
}
.phone-code-result-box:hover { border-color: var(--primary); box-shadow: var(--ring); }
.phone-code-pink { background: #ffd3da; }
.phone-code-gray { background: #d9dee5; }
.phone-code-scale-row { display: flex; gap: 12px; flex-wrap: wrap; }
.phone-code-scale-row .phone-code-result-box { flex: 1; min-width: 120px; }

.badge-code-permanent { background: #dcfce7; color: #166534; padding: 4px 10px; border-radius: 6px; font-size: .85rem; }
.badge-code-temp { background: #ffedd5; color: #9a3412; padding: 4px 10px; border-radius: 6px; font-size: .85rem; }

.upgrade-plan-cards { grid-template-columns: 1fr; }
.upgrade-plan-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.upgrade-plan-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.upgrade-plan-card h4 { margin-bottom: 6px; color: var(--primary); }
.upgrade-plan-price { font-size: 1.15rem; font-weight: 800; margin: 8px 0; }
.subscription-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.plan-features { font-size: .85rem; color: var(--muted); line-height: 1.8; margin: 8px 0; }

.accounting-stat-cards {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.accounting-subtabs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inv-line-price.readonly-field,
.inv-line-discount.readonly-field,
#productPrice0.readonly-field {
  background: var(--surface-muted, #f3f4f6);
  cursor: not-allowed;
}
.btn-success { background: #059669; color: #fff; border-color: #059669; }
.btn-warning { background: #d97706; color: #fff; border-color: #d97706; }
.accounting-subtabs .btn-add { margin-right: auto; }
.accounting-subtab.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.accounting-invoice-filter {
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  margin-bottom: 8px;
}

.accounting-invoice-filter .accounting-invoice-search {
  width: 220px;
  max-width: 220px;
  flex: 0 0 auto;
  min-width: 0;
  padding: 7px 10px;
  font-size: .9rem;
}

.accounting-invoice-archive-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  color: var(--muted);
  white-space: nowrap;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}

.accounting-invoice-archive-check input {
  margin: 0;
  flex-shrink: 0;
}

.accounting-layout {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 180px);
}
.accounting-sticky-header {
  flex-shrink: 0;
  position: sticky;
  top: 108px;
  z-index: 30;
  background: var(--bg, #f8fafc);
  padding-bottom: 8px;
  box-shadow: 0 6px 16px -10px rgba(15, 23, 42, .18);
}
.accounting-list-scroll {
  flex: 1 1 auto;
  min-height: 280px;
  overflow-x: auto;
  overflow-y: visible;
  margin-bottom: 16px;
}
.invoice-actions-toolbar { padding: 10px 12px; background: var(--surface-2, #f8fafc); border: 1px solid var(--border, #e2e8f0); border-radius: 8px; }
.invoice-actions-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.invoice-selection-hint { font-size: .85rem; white-space: nowrap; }
.invoice-row { cursor: pointer; }
.invoice-row.selected { background: var(--primary-light, #eff6ff); }
.invoice-row:hover { background: #f1f5f9; }

.master-data-subtabs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.master-data-subtabs .btn-add { margin-right: auto; }
.master-data-subtab.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.settings-section-title {
  margin: 1.25rem 0 .75rem;
  font-size: 1rem;
  color: var(--text, #334155);
  border-top: 1px solid var(--border, #e2e8f0);
  padding-top: 1rem;
}
.company-logo-preview {
  display: block;
  max-height: 96px;
  max-width: 200px;
  object-fit: contain;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 6px;
  background: #fff;
}

.invoice-lines-table input[type="number"] { width: 88px; min-width: 72px; }
.invoice-lines-table .inv-line-tax-cell { white-space: nowrap; font-size: .85rem; }
.inv-tax-label { display: inline-flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; }
.invoice-totals-summary {
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 12px 16px;
  display: grid;
  gap: 6px;
  max-width: 320px;
  margin-right: auto;
}
.invoice-totals-summary .invoice-grand-total {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border, #e2e8f0);
  font-size: 1.05rem;
  color: var(--primary, #2563eb);
}

.alan-password-input {
  font-family: Consolas, monospace;
  font-size: 1.25rem;
  letter-spacing: 3px;
  text-align: center;
  flex: 1;
}

.search-dropdown {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 4px;
}
.search-dropdown .search-item {
  display: block;
  width: 100%;
  text-align: right;
  padding: 8px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}
.search-dropdown .search-item:hover { background: var(--primary-light); }

.panel-toolbar h2 { margin: 0; font-size: 1.15rem; }

.btn-add {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  font-weight: 400;
  flex-shrink: 0;
}

.line-product-search {
  position: relative;
  min-width: 200px;
}

.line-product-search .search-dropdown {
  position: fixed;
  z-index: 2000;
  min-width: 280px;
  max-width: min(420px, calc(100vw - 24px));
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.line-product-search .search-dropdown .search-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
}

.line-product-search .search-item-code {
  font-size: .78rem;
  color: var(--muted, #64748b);
}

.line-product-search .search-item-title {
  font-size: .92rem;
  color: var(--text, #1e293b);
}

.invoice-lines-scroll {
  overflow: visible;
}

.invoice-lines-table {
  overflow: visible;
}

.invoice-lines-table td {
  overflow: visible;
  vertical-align: top;
}

.modal-card .invoice-lines-scroll {
  overflow: visible;
}

.inv-line-title-readonly {
  font-size: .85rem;
  color: var(--muted);
  margin-top: 4px;
}

.ticket-list-full { max-height: none; }
.ticket-list-full .ticket-item { cursor: pointer; }
