/* =============================================================================
   IstiqlolTV — Main Stylesheet
   Design System: Monochrome (Black & White)
============================================================================= */

/* ─── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --bg:            #F4F4F5;
  --surface:       #FFFFFF;
  --surface-2:     #FAFAFA;
  --border:        #E4E4E7;
  --border-2:      #A1A1AA;
  --text:          #09090B;
  --text-2:        #52525B;
  --text-3:        #A1A1AA;

  --sb-bg:         #09090B;
  --sb-border:     rgba(255,255,255,0.08);
  --sb-text:       rgba(255,255,255,0.6);
  --sb-text-on:    #FFFFFF;
  --sb-hover:      rgba(255,255,255,0.06);
  --sb-active:     rgba(255,255,255,0.10);
  --sb-width:      240px;

  --topbar-h:      60px;
  --r:             6px;
  --r-sm:          4px;
  --r-lg:          10px;

  --font:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'Courier New', monospace;

  --sh-xs: 0 1px 2px rgba(0,0,0,0.05);
  --sh-sm: 0 1px 3px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.06);
  --sh-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);

  --t: 120ms ease;
  --t-md: 220ms ease;
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { font-size:16px; scroll-behavior:smooth; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color:inherit; text-decoration:none; }
button { font-family:inherit; cursor:pointer; border:none; background:none; }
input,textarea,select { font-family:inherit; font-size:inherit; color:inherit; }
img { max-width:100%; display:block; }
table { border-collapse:collapse; width:100%; }
ul,ol { list-style:none; }
svg { flex-shrink:0; }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}
.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sb-width);
  display: flex;
  flex-direction: column;
  transition: margin-left var(--t-md);
}
.content {
  flex: 1;
  padding: var(--space-6, 24px);
  padding-top: calc(var(--topbar-h) + 24px);
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sb-width);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
  transition: transform var(--t-md);
}
.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sidebar__logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #fff;
}
.sidebar__close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  color: var(--sb-text);
  transition: background var(--t), color var(--t);
}
.sidebar__close:hover { background: var(--sb-hover); color: #fff; }

.sidebar__nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar__nav::-webkit-scrollbar { width: 4px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius:4px; }

.sidebar__section {
  padding: 16px 20px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sb-text);
  font-size: 13.5px;
  font-weight: 450;
  transition: background var(--t), color var(--t);
  position: relative;
  white-space: nowrap;
}
.sidebar__link i {
  width: 16px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}
.sidebar__link:hover {
  background: var(--sb-hover);
  color: var(--sb-text-on);
}
.sidebar__link.active {
  background: var(--sb-active);
  color: var(--sb-text-on);
}
.sidebar__link.active::after {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2.5px;
  background: #fff;
  border-radius: 0 2px 2px 0;
}
.sidebar__link--logout {
  color: rgba(255,255,255,0.4);
  margin-top: 4px;
}
.sidebar__link--logout:hover {
  color: #ff6b6b;
  background: rgba(255,100,100,0.08);
}

.sidebar__footer {
  border-top: 1px solid var(--sb-border);
  padding: 8px 0;
  flex-shrink: 0;
}

.sidebar__badge {
  margin-left: auto;
  background: #fff;
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 100px;
  min-width: 18px;
  text-align: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
}
.sidebar-overlay.open { display: block; }

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sb-width);
  right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  z-index: 100;
  transition: left var(--t-md);
}
.topbar__hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  transition: background var(--t);
}
.topbar__hamburger:hover { background: var(--bg); }

.topbar__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.topbar__user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.topbar__avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}
.topbar__username {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}
.topbar__logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  text-decoration: none;
  transition: background var(--t), color var(--t);
  font-size: 14px;
  margin-left: 2px;
}
.topbar__logout:hover {
  background: #FEE2E2;
  color: #DC2626;
}

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--topbar-h) + 16px);
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  width: calc(100vw - 48px);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--text);
  color: #fff;
  border-radius: var(--r-lg);
  font-size: 13.5px;
  line-height: 1.4;
  box-shadow: var(--sh-md);
  animation: toastIn 0.2s ease;
}
.toast__text { flex:1; }
.toast__close {
  color: rgba(255,255,255,0.5);
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
  padding: 0 2px;
  border-radius: 2px;
}
.toast__close:hover { color:#fff; }
@keyframes toastIn {
  from { opacity:0; transform:translateY(-6px) scale(0.97); }
  to   { opacity:1; transform:translateY(0)    scale(1); }
}

/* ─── Typography helpers ─────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header__left { display:flex; flex-direction:column; gap:2px; }
.page-header__title { font-size:20px; font-weight:700; letter-spacing:-0.3px; }
.page-header__sub { font-size:13px; color:var(--text-3); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--r);
  border: 1.5px solid transparent;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--t);
  outline: none;
}
.btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.btn-primary {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.btn-primary:hover { background: #27272A; border-color: #27272A; }
.btn-primary:active { background: #3F3F46; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-2);
}
.btn-secondary:hover { background: var(--bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--border); color: var(--text); }

.btn-danger {
  background: var(--surface);
  color: #DC2626;
  border-color: #DC2626;
}
.btn-danger:hover { background: #DC2626; color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 15px; }
.btn-full { width:100%; justify-content:center; }
.btn[disabled] { opacity:0.45; pointer-events:none; }

/* ─── Form ───────────────────────────────────────────────────────────────── */
.form-stack { display:flex; flex-direction:column; gap:18px; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.form-group { display:flex; flex-direction:column; gap:6px; }
.form-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}
.form-label sup { color:#CC0000; margin-left:2px; }

/* All inputs inside form-group */
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(9,9,11,0.08);
}
.form-group input::placeholder { color: var(--text-3); }
.form-group textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}
.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 34px;
  cursor: pointer;
}
.form-error {
  font-size: 12px;
  color: #DC2626;
  margin-top: 2px;
}
.form-hint { font-size: 12px; color: var(--text-3); }

.form-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.form-section + .form-section { margin-top: 8px; }
.form-section__heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ─── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size:14px; font-weight:600; }
.card-body { padding:20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ─── Table ──────────────────────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}
.table-wrap table { font-size: 13.5px; }
.table-wrap thead { background: var(--surface-2); }
.table-wrap th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-wrap td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.table-wrap tbody tr:last-child td { border-bottom: none; }
.table-wrap tbody tr { transition: background var(--t); }
.table-wrap tbody tr:hover { background: var(--surface-2); }

.table-link {
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-2);
}
.table-link:hover { text-decoration-color: var(--text); }

/* ─── Badge ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.5;
}
/* Status — semantic colors */
.badge-pending   { background:#FEF9C3; color:#854D0E; border:1px solid #FDE047; }          /* yellow  — kutilmoqda  */
.badge-approved  { background:#DCFCE7; color:#166534; border:1px solid #86EFAC; }          /* green   — tasdiqlandi */
.badge-rejected  { background:#FEE2E2; color:#991B1B; border:1px solid #FCA5A5; }          /* red     — rad etildi  */
.badge-paid      { background:#DCFCE7; color:#166534; border:1px solid #86EFAC; }          /* green   — to'langan  */
.badge-unpaid    { background:#FEF3C7; color:#92400E; border:1px solid #FCD34D; }          /* amber   — to'lanmagan */
.badge-done      { background:#DBEAFE; color:#1E40AF; border:1px solid #93C5FD; }          /* blue    — daftarga yozilgan */
.badge-nodone    { background:#F4F4F5; color:#71717A; border:1px dashed #D4D4D8; }

/* ─── Pagination ─────────────────────────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.pager a, .pager span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all var(--t);
  white-space: nowrap;
}
.pager a:hover { background: var(--bg); color: var(--text); }
.pager .current {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.pager .disabled { opacity:0.4; pointer-events:none; }

/* ─── Stat cards ─────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
}
.stat-card__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-bottom: 6px;
}
.stat-card__value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

/* ─── Detail page ────────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.detail-field {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.detail-field:last-child { border-bottom: none; }
.detail-field__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
}
.detail-field__value { font-size: 14px; color: var(--text); }
.detail-field__value strong { font-weight:600; }

/* ─── Profile ────────────────────────────────────────────────────────────── */
.profile-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  align-items: start;
}
.profile-avatar {
  width: 100px; height: 140px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 32px;
  font-weight: 800;
}
.profile-avatar img { width:100%; height:100%; object-fit:cover; }
.profile-name { font-size:22px; font-weight:700; margin-bottom:4px; }
.profile-tel { font-size:14px; color:var(--text-2); font-family:var(--font-mono); }

.info-list { display:flex; flex-direction:column; gap:0; }
.info-item {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
  font-size: 14px;
}
.info-item:last-child { border-bottom: none; }
.info-item__key {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-3);
}

/* ─── Image gallery ──────────────────────────────────────────────────────── */
.img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.img-grid__item {
  aspect-ratio: 1;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.img-grid__item img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.img-grid__item:hover img { transform: scale(1.06); }

/* ─── Upload grid ────────────────────────────────────────────────────────── */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.upload-box {
  border: 1.5px dashed var(--border-2);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface-2);
  transition: border-color var(--t), background var(--t);
}
.upload-box:hover { border-color: var(--text); background: var(--surface); }
.upload-box__label {
  display: block;
  padding: 5px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
/* hide native file button, show styled area */
.upload-box input[type=file] {
  width: 100%;
  padding: 0;
  font-size: 12px;
  cursor: pointer;
  color: transparent;  /* hide "no file chosen" text */
  display: block;
}
.upload-box input[type=file]::file-selector-button {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface-2);
  border: none;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t), color var(--t);
  text-align: left;
}
.upload-box input[type=file]::file-selector-button:hover {
  background: var(--bg);
  color: var(--text);
}
/* show filename after selection */
.upload-box input[type=file].has-file {
  color: var(--text-2);
  padding: 6px 10px;
}

/* ─── Chat layout ────────────────────────────────────────────────────────── */
.chat-wrap {
  display: grid;
  grid-template-columns: 270px 1fr;
  height: calc(100vh - var(--topbar-h) - 48px);
  min-height: 500px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}

.chat-contacts {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
}
.chat-contacts__head {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.chat-contacts__title { font-size:14px; font-weight:700; color: var(--text); }
.chat-contacts__scroll {
  flex: 1;
  overflow-y: auto;
}
.chat-contacts__scroll::-webkit-scrollbar { width:3px; }
.chat-contacts__scroll::-webkit-scrollbar-thumb { background:var(--border); border-radius:3px; }

.chat-contacts__section {
  padding: 10px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--t);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.contact-item:hover { background: var(--surface-2); }
.contact-item.active {
  background: var(--bg);
  border-left: 3px solid var(--text);
  padding-left: 13px;
}
.contact-item__av {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
  text-transform: uppercase;
}
.contact-item__av--unread {
  background: var(--text);
  color: #fff;
}
.contact-item__info { flex:1; min-width:0; }
.contact-item__name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-item__name--unread { font-weight:700; }
.contact-item__tel {
  font-size: 11.5px;
  color: var(--text-3);
  font-family: var(--font-mono);
}
.contact-item__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text);
  flex-shrink: 0;
}

/* Chat main area */
.chat-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-main__head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
}
.chat-main__name { font-size:15px; font-weight:700; color: var(--text); }
.chat-main__tel  { font-size:12px; color:var(--text-3); font-family:var(--font-mono); margin-top:1px; }

/* Messages area — subtle gray wallpaper so white bubbles pop */
.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #F0F0F2;
}
.chat-msgs::-webkit-scrollbar { width:4px; }
.chat-msgs::-webkit-scrollbar-thumb { background: #C4C4C8; border-radius:4px; }
.chat-msgs--empty {
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 14px;
}

/* Day separator */
.msg-day {
  text-align: center;
  margin: 10px 0 6px;
}
.msg-day span {
  display: inline-block;
  background: rgba(0,0,0,0.12);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

/* Single message row */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 62%;
  gap: 2px;
}
.msg--in  { align-self: flex-start; }
.msg--out { align-self: flex-end; }

/* Bubble */
.msg__bubble {
  padding: 9px 13px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
}

/* INCOMING — white bubble, left-tail */
.msg--in .msg__bubble {
  background: #FFFFFF;
  color: #09090B;
  border-radius: 0 14px 14px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.10);
}

/* OUTGOING — dark bubble, right-tail */
.msg--out .msg__bubble {
  background: #09090B;
  color: #FFFFFF;
  border-radius: 14px 14px 0 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}

/* Timestamp */
.msg__time {
  font-size: 10.5px;
  color: #8E8E96;
  padding: 0 2px;
  letter-spacing: 0.2px;
}
.msg--out .msg__time {
  text-align: right;
  color: #8E8E96;
}

/* Media (photo/video) */
.msg__media {
  max-width: 240px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.14);
}
.msg--in  .msg__media { border-bottom-left-radius: 3px; }
.msg--out .msg__media { border-bottom-right-radius: 3px; }
.msg__media img,
.msg__media video { width:100%; display:block; }
.msg__media audio  { width:100%; padding:6px; background:#fff; }

/* File attachment */
.msg--in  .msg__bubble .msg__file a {
  font-size: 12.5px;
  font-weight: 500;
  color: #09090B;
  text-decoration: underline;
}
.msg--out .msg__bubble .msg__file a {
  font-size: 12.5px;
  font-weight: 500;
  color: #fff;
  text-decoration: underline;
}

/* Location link */
.msg--in  .msg__bubble .msg__loc a { font-size:12.5px; color:#09090B; text-decoration:underline; }
.msg--out .msg__bubble .msg__loc a { font-size:12.5px; color:#fff;    text-decoration:underline; }

/* Order link */
.msg__order-link {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  display: inline-block;
}
.msg--in  .msg__bubble .msg__order-link {
  border: 1.5px solid rgba(0,0,0,0.15);
  color: var(--text-2);
  background: rgba(0,0,0,0.03);
}
.msg--out .msg__bubble .msg__order-link {
  border: 1.5px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.1);
}

/* Chat input area */
.chat-input {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--surface);
}
.chat-input__row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input textarea {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: var(--font);
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 38px;
  line-height: 1.4;
  overflow-y: auto;
  background: var(--surface-2);
  transition: border-color var(--t), background var(--t);
}
.chat-input textarea:focus {
  border-color: var(--text);
  background: var(--surface);
}
.chat-input__file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 2px;
}
.chat-input__file i {
  font-size: 13px;
  color: var(--text-3);
  flex-shrink: 0;
}
.chat-input__file input[type=file] {
  flex: 1;
  font-size: 12px;
  font-family: var(--font);
  color: transparent;
  cursor: pointer;
}
.chat-input__file input[type=file]::file-selector-button {
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 11.5px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t), border-color var(--t), color var(--t);
  margin-right: 8px;
}
.chat-input__file input[type=file]::file-selector-button:hover {
  background: var(--bg);
  border-color: var(--text);
  color: var(--text);
}
.chat-input__file input[type=file].has-file {
  color: var(--text-2);
}

/* Empty — no active chat */
.chat-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--text-3);
  padding: 40px;
  background: #F0F0F2;
  flex: 1;
}
.chat-empty__icon { font-size:40px; opacity:0.25; }
.chat-empty__text { font-size:14px; font-weight:500; }

/* ─── Login page ─────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-md);
}
.login-card__head {
  padding: 32px 28px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.login-card__logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.login-card__tagline { font-size:13px; color:var(--text-3); }
.login-card__body { padding: 24px 28px 28px; }
.login-card__body .form-stack { gap: 16px; }

/* ─── Filter bar ─────────────────────────────────────────────────────────── */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.filter-bar__row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.filter-bar__group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
.filter-bar__group--wide { min-width: 220px; flex: 1; }
.filter-bar__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
}
.filter-bar__input,
.filter-bar__select {
  height: 34px;
  padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t), background var(--t), box-shadow var(--t);
  font-family: var(--font);
  width: 100%;
}
.filter-bar__input:hover,
.filter-bar__select:hover {
  border-color: var(--border-2);
}
.filter-bar__input:focus,
.filter-bar__select:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(9,9,11,0.08);
}
.filter-bar__input::placeholder { color: var(--text-3); }

/* ── Select — custom arrow + active state ─────────────────────────── */
.filter-bar__select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A1A1AA' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
  font-weight: 450;
}
.filter-bar__select:hover {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2352525B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* Active filter — tinted border + faint bg */
.filter-bar__select.is-active {
  border-color: #09090B;
  background-color: #09090B;
  color: #fff;
  font-weight: 600;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
.filter-bar__select.is-active option {
  background: #fff;
  color: #09090B;
  font-weight: 400;
}

/* Status-specific active tints */
.filter-bar__select[name="status"].is-active[data-val="pending"]  { background-color:#854D0E; border-color:#854D0E; }
.filter-bar__select[name="status"].is-active[data-val="approved"] { background-color:#166534; border-color:#166534; }
.filter-bar__select[name="status"].is-active[data-val="rejected"] { background-color:#991B1B; border-color:#991B1B; }
.filter-bar__select[name="tulov"].is-active[data-val="yes"]       { background-color:#166534; border-color:#166534; }
.filter-bar__select[name="tulov"].is-active[data-val="no"]        { background-color:#92400E; border-color:#92400E; }
.filter-bar__select[name="daftar"].is-active[data-val="yes"]      { background-color:#1E40AF; border-color:#1E40AF; }
.filter-bar__select[name="daftar"].is-active[data-val="no"]       { background-color:#71717A; border-color:#71717A; }
.filter-bar__search-icon {
  position: relative;
}
.filter-bar__search-icon input {
  padding-left: 34px;
}
.filter-bar__search-icon svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}
.filter-bar__actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-left: auto;
  flex-shrink: 0;
}
.filter-result {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 10px;
}
.filter-result strong { color: var(--text); }

/* chat filter panel */
.chat-filter {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

/* chat search */
.chat-search {
  padding: 8px 12px;
  position: relative;
}
.chat-search input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 30px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 13px;
  outline: none;
  background: var(--surface-2);
  transition: border-color var(--t);
  font-family: var(--font);
}
.chat-search input:focus { border-color: var(--text); background: var(--surface); }
.chat-search svg {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

/* period shortcut buttons */
.chat-period-btns {
  display: flex;
  gap: 4px;
  padding: 0 10px 8px;
}
.chat-period-btn {
  flex: 1;
  height: 26px;
  font-size: 11.5px;
  font-weight: 500;
  font-family: var(--font);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
  padding: 0 6px;
}
.chat-period-btn:hover {
  background: var(--bg);
  border-color: var(--border-2);
  color: var(--text);
}
.chat-period-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

/* custom date range */
.chat-date-range {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.chat-date-range__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 6px;
}
.chat-date-range__group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-date-range__group label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
}
.chat-date-range__group input[type=date] {
  height: 28px;
  padding: 0 7px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 12px;
  font-family: var(--font);
  background: var(--surface);
  outline: none;
  transition: border-color var(--t);
  width: 100%;
}
.chat-date-range__group input[type=date]:focus { border-color: var(--text); }
.chat-date-range__apply {
  width: 100%;
  height: 28px;
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t);
}
.chat-date-range__apply:hover { background: #333; }

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty-state__icon { font-size:38px; margin-bottom:12px; opacity:0.3; }
.empty-state__text { font-size:15px; font-weight:500; }
.empty-state__sub { font-size:13px; margin-top:4px; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .chat-wrap { grid-template-columns: 230px 1fr; }
}

@media (max-width: 768px) {
  :root { --sb-width: 0px; }

  .sidebar {
    width: 240px;
    transform: translateX(-240px);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar__close { display: flex; }

  .main { margin-left: 0; }
  .topbar { left: 0; }
  .topbar__hamburger { display: flex; }

  .content {
    padding: 16px;
    padding-top: calc(var(--topbar-h) + 16px);
  }

  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .profile-layout { grid-template-columns: 1fr; }

  .chat-wrap {
    grid-template-columns: 1fr;
    height: auto;
    min-height: unset;
  }
  .chat-contacts {
    height: 280px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .chat-main { height: 60vh; }
  .chat-msgs { height: auto; }

  .page-header { flex-direction:column; align-items:flex-start; }
  .toast-container { right:16px; left:16px; width:auto; }
}

@media (max-width: 480px) {
  .table-wrap th,
  .table-wrap td { padding: 8px 10px; font-size:12.5px; }
  .upload-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .info-item { grid-template-columns: 1fr; gap:2px; }
}
