/* Shared base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #1a1a2e; min-height: 100vh; }

/* ---- Login ---- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px 16px; background: #1a1a2e; }
.login-box { background: #fff; border-radius: 20px; padding: 36px 28px; width: 100%; max-width: 400px; box-shadow: 0 24px 64px rgba(0,0,0,.35); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .icon { font-size: 52px; display: block; }
.login-logo h1 { font-size: 22px; font-weight: 700; margin-top: 10px; color: #1a1a2e; }
.login-logo p  { color: #888; font-size: 14px; margin-top: 4px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: #666; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .6px; }
.field input { width: 100%; border: 2px solid #e5e7eb; border-radius: 12px; padding: 14px 16px; font-size: 16px; outline: none; transition: border-color .2s; background: #fafafa; }
.field input:focus { border-color: #64235E; background: #fff; }
.error-msg { color: #dc2626; font-size: 14px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; border: 2px solid transparent; transition: all .15s; text-decoration: none; white-space: nowrap; touch-action: manipulation; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary  { background: #64235E; color: #fff; border-color: #64235E; }
.btn-primary:hover:not(:disabled) { background: #7a2c72; }
.btn-success  { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-outline  { background: transparent; color: #374151; border-color: #d1d5db; }
.btn-outline:hover { background: #f9fafb; }
.btn-full { width: 100%; }

/* ---- App shell with sidebar ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #1a1a2e;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .3px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255,255,255,.65);
  cursor: pointer;
  transition: all .15s;
}
.sidebar-item:hover  { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-item.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; }

.sidebar-sep { border: none; border-top: 1px solid rgba(255,255,255,.1); margin: 8px 4px; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-user { font-size: 13px; color: rgba(255,255,255,.65); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-logout { background: transparent; color: rgba(255,255,255,.7); border: 1px solid rgba(255,255,255,.3); padding: 6px 12px; border-radius: 8px; font-size: 13px; cursor: pointer; transition: color .15s, border-color .15s; }
.btn-logout:hover { color: #fff; border-color: rgba(255,255,255,.6); }

/* ---- Main content area ---- */
.app-content {
  flex: 1;
  min-width: 0;
  padding: 20px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Order / ticket cards ---- */
.order-list { display: flex; flex-direction: column; gap: 12px; max-width: 700px; }
.order-card { background: #fff; border-radius: 14px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.06); border: 1px solid #e5e7eb; }
.order-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.order-header strong { font-size: 16px; }
.order-customer { font-size: 15px; font-weight: 600; margin-bottom: 8px; color: #111; }
.order-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; color: #6b7280; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .3px; }

/* ---- SAV detail ---- */
.sav-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.sav-bloc { border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; background: #fff; }
.sav-bloc-title { background: #1a1a2e; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; padding: 6px 12px; }
.sav-dtable { width: 100%; border-collapse: collapse; }
.sav-dtable tr { border-bottom: 1px solid #f3f4f6; }
.sav-dtable tr:last-child { border-bottom: none; }
.sav-dtable td { padding: 7px 12px; font-size: 13px; color: #374151; vertical-align: top; }
.sav-fl { font-weight: 600; color: #9ca3af; white-space: nowrap; width: 70px; font-size: 12px; }

.sav-section { margin-bottom: 14px; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 14px 16px; max-width: 700px; }
.sav-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #9ca3af; margin-bottom: 10px; }
.sav-select { width: 100%; border: 1.5px solid #e5e7eb; border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none; background: #fafafa; font-family: inherit; }
.sav-select:focus { border-color: #64235E; }
.sav-textarea { width: 100%; border: 1.5px solid #e5e7eb; border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none; font-family: inherit; resize: none; }
.sav-textarea:focus { border-color: #64235E; }

/* ---- Chat thread ---- */
.sav-thread { display: flex; flex-direction: column; gap: 10px; max-height: 360px; overflow-y: auto; padding: 12px; margin-bottom: 4px; background: #f9fafb; border-radius: 8px; }
.sav-bubble { max-width: 80%; padding: 10px 14px; border-radius: 14px; }
.sav-bubble-client { align-self: flex-end; background: #64235E; color: #fff; border-bottom-right-radius: 4px; }
.sav-bubble-tech   { align-self: flex-start; background: #f97316; color: #fff; border-bottom-left-radius: 4px; }
.sav-bubble-author  { font-size: 11px; opacity: .8; margin-bottom: 4px; }
.sav-bubble-content { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }

/* System messages (status changes, handover) */
.sav-bubble-system { align-self: center; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; margin: 6px 0; }
.sav-bubble-system > span:first-child {
  background: #fff7ed;
  color: #92400e;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.sav-sys-date { font-size: 11px; color: #c0c0c0; }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #1a1a2e; color: #fff; padding: 12px 24px; border-radius: 999px; font-size: 14px; font-weight: 500; z-index: 9999; box-shadow: 0 4px 20px rgba(0,0,0,.2); pointer-events: none; white-space: nowrap; }
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }

/* ---- States ---- */
.state-msg { text-align: center; padding: 48px 20px; color: #9ca3af; font-size: 15px; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .app-sidebar { width: 60px; }
  .sidebar-brand span:last-child, .sidebar-item { font-size: 0; }
  .sidebar-brand { justify-content: center; padding: 16px 0; }
  .sidebar-brand span:first-child { font-size: 22px; }
  .sidebar-item { text-align: center; padding: 12px 0; }
  .sidebar-footer .sidebar-user { display: none; }
}
