
:root {
  --primary: #E60012;
  --primary-dark: #B5000E;
  --primary-soft: #FFF2F3;
  --text: #333333;
  --text-secondary: #666666;
  --text-muted: #8C8C8C;
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #FAFAFA;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --success: #16A34A;
  --warning: #D97706;
  --danger: #DC2626;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.10);
  --radius: 18px;
  --radius-sm: 12px;
  --header-height: 82px;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{font-family:'Inter',-apple-system,BlinkMacSystemFont,sans-serif;background:linear-gradient(180deg,#f8f8f8 0%,#f4f5f7 100%);color:var(--text);overflow:hidden}
button,input,select,textarea{font:inherit}
img{display:block;max-width:100%}
.app{display:flex;flex-direction:column;height:100dvh}
.mobile-only{display:none}
.desktop-only{display:flex}

.header{height:var(--header-height);display:flex;align-items:center;justify-content:space-between;padding:14px 24px;background:rgba(255,255,255,.95);backdrop-filter:blur(10px);border-bottom:1px solid rgba(229,231,235,.9);position:relative;z-index:20}
.header::before{content:'';position:absolute;left:0;top:0;width:100%;height:4px;background:linear-gradient(90deg,var(--primary) 0%, #ff3b47 35%, var(--primary) 100%)}
.header-left{display:flex;align-items:center;gap:14px;min-width:0}
.header-brand{display:flex;align-items:center;gap:16px;min-width:0}
.brand-logo-image{width:168px;height:auto;object-fit:contain}
.brand-text{min-width:0}
.brand-overline{font-size:12px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--primary);margin-bottom:2px}
.brand-text h1{font-size:28px;line-height:1.05;font-weight:800;color:var(--text)}
.brand-text span{display:block;font-size:13px;color:var(--text-secondary);margin-top:4px}
.header-actions{display:flex;align-items:center;gap:12px;margin-left:20px}
.header-status{align-items:center;gap:6px;padding:8px 12px;border-radius:999px;background:var(--surface-2);border:1px solid var(--border)}
.status-dot{width:8px;height:8px;border-radius:50%;background:var(--success);box-shadow:0 0 0 6px rgba(22,163,74,.12);animation:pulse 2s infinite}
.status-text{font-size:13px;color:var(--text-secondary);font-weight:600}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.5}}
.customer-access{display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}
.customer-label{font-size:12px;color:var(--text-secondary);font-weight:600}
.customer-profile-btn,.secondary-action{display:inline-flex;align-items:center;justify-content:center;padding:10px 14px;border-radius:12px;border:1px solid var(--border);background:var(--surface);color:var(--text);cursor:pointer;font-weight:700;transition:.2s ease}
.customer-profile-btn:hover,.secondary-action:hover{border-color:var(--border-strong);background:#fff;box-shadow:var(--shadow)}
.google-signin-button{min-height:34px;display:flex;align-items:center}.google-linked{font-size:12px;padding:8px 10px;border-radius:999px;background:#eef8f0;color:#166534;border:1px solid #bbdfc4;font-weight:700}

.main{display:flex;flex:1;min-height:0;position:relative}
.sidebar-overlay{display:none}
.sidebar{width:300px;background:var(--surface);border-right:1px solid var(--border);padding:18px;display:flex;flex-direction:column;gap:18px;overflow-y:auto}
.sidebar-top{display:none}
.sidebar-card{padding:16px;border-radius:16px;background:linear-gradient(180deg,#fff7f7 0%,#fff 100%);border:1px solid #f5d6d9}
.sidebar-card h3{font-size:15px;font-weight:800;color:var(--text);margin-bottom:8px}
.sidebar-card p{font-size:13px;line-height:1.55;color:var(--text-secondary)}
.sidebar-section h3{font-size:12px;font-weight:800;text-transform:uppercase;letter-spacing:.08em;color:var(--text-muted);margin-bottom:12px}
.tag-list{display:flex;flex-wrap:wrap;gap:8px}
.tag{padding:8px 12px;background:var(--surface-2);color:var(--text);border:1px solid var(--border);border-radius:999px;font-size:12px;font-weight:700;cursor:pointer;transition:.2s ease;font-family:inherit}
.tag:hover{background:var(--primary-soft);border-color:#f5a3aa;color:var(--primary)}
.tag-skeleton{width:86px;height:34px;border-radius:999px;background:linear-gradient(90deg,#f2f3f5,#fafafa,#f2f3f5);background-size:200% 100%;animation:shimmer 1.4s infinite}
@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
.sidebar-stats{margin-top:auto;padding-top:18px;border-top:1px solid var(--border)}
.stat-item{display:flex;flex-direction:column;gap:6px;align-items:flex-start}
.stat-number{font-size:32px;font-weight:800;color:var(--primary);line-height:1}
.stat-label{font-size:12px;color:var(--text-secondary);font-weight:700;letter-spacing:.04em;text-transform:uppercase}

.chat-container{flex:1;display:flex;flex-direction:column;min-width:0;background:linear-gradient(180deg,#f7f8fa 0%,#f2f4f7 100%)}
.chat-messages{flex:1;overflow-y:auto;padding:26px;display:flex;flex-direction:column;gap:16px}
.chat-messages::-webkit-scrollbar{width:6px}.chat-messages::-webkit-scrollbar-thumb{background:#d6d9df;border-radius:999px}
.message{display:flex;gap:12px;max-width:min(86%,860px);animation:fadeInUp .25s ease}.message-user{align-self:flex-end;flex-direction:row-reverse}.message-bot{align-self:flex-start}
@keyframes fadeInUp{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
.message-avatar{width:40px;height:40px;min-width:40px;border-radius:50%;background:#fff;border:1px solid #f1b5bb;display:flex;align-items:center;justify-content:center;box-shadow:var(--shadow);padding:6px}
.message-avatar img{width:100%;height:100%;object-fit:contain}
.message-content{background:var(--surface);padding:16px 18px;border-radius:14px 18px 18px 18px;box-shadow:var(--shadow);line-height:1.6;border:1px solid rgba(255,255,255,.75)}
.message-user .message-content{background:linear-gradient(135deg,var(--primary) 0%,var(--primary-dark) 100%);color:#fff;border-radius:18px 14px 18px 18px}
.message-header{display:flex;align-items:center;gap:8px;margin-bottom:6px;font-size:13px}.message-header strong{color:var(--primary);font-weight:800}.message-user .message-header strong{color:#fff}.message-time{color:var(--text-muted);font-size:11px}.message-user .message-time{color:rgba(255,255,255,.74)}
.message-text p{margin-bottom:8px}.message-text p:last-child{margin-bottom:0}.message-text ul{margin:8px 0;padding-left:18px}.message-text li{margin-bottom:4px}.message-text em{font-style:italic;color:var(--text-secondary)}
.message-error{background:#fef2f2!important;border:1px solid #fecaca;color:#991b1b}

.product-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;margin-top:14px}
.product-card{background:var(--surface);border:1px solid var(--border);border-radius:16px;padding:14px;transition:.2s ease;display:flex;flex-direction:column;gap:6px}
.product-card:hover{transform:translateY(-1px);border-color:#f2a1a8;box-shadow:var(--shadow)}
.product-card-name{font-weight:700;font-size:13px;color:var(--text)}
.product-card-code{font-size:11px;color:var(--text-muted)}
.product-card-price{font-size:18px;font-weight:800;color:var(--text)}
.product-card-stock{font-size:12px;display:flex;align-items:center;gap:6px;color:var(--success);font-weight:700}
.stock-dot{width:7px;height:7px;border-radius:50%}.stock-high{background:var(--success)}.stock-low{background:var(--warning)}.stock-none{background:var(--danger)}

.typing-indicator{display:flex;align-items:center;gap:12px;padding:0 26px 10px}.typing-dots{display:flex;gap:4px;padding:14px 18px;background:var(--surface);border-radius:14px 18px 18px 18px;box-shadow:var(--shadow)}.typing-dots span{width:8px;height:8px;background:var(--text-muted);border-radius:50%;animation:bounce 1.4s infinite ease-in-out}.typing-dots span:nth-child(2){animation-delay:.2s}.typing-dots span:nth-child(3){animation-delay:.4s}@keyframes bounce{0%,80%,100%{transform:scale(.6);opacity:.5}40%{transform:scale(1);opacity:1}}

.chat-input-area{padding:16px 24px 24px;background:rgba(255,255,255,.96);backdrop-filter:blur(12px);border-top:1px solid var(--border)}
.quick-suggestions{display:flex;gap:8px;flex-wrap:wrap;overflow-x:auto;padding-bottom:4px;margin-bottom:12px;scrollbar-width:none}.quick-suggestions::-webkit-scrollbar{display:none}
.suggestion-chip{padding:9px 14px;background:#fff;border:1px solid var(--border);border-radius:999px;font-size:12px;font-weight:700;color:var(--text-secondary);cursor:pointer;white-space:nowrap;transition:.2s ease}.suggestion-chip:hover{background:var(--primary-soft);border-color:#f2a1a8;color:var(--primary)}
.chat-form{display:flex;gap:10px;align-items:center}.chat-form input{flex:1;padding:15px 18px;border:1px solid var(--border);border-radius:18px;font-size:15px;background:var(--surface-2);color:var(--text);outline:none;transition:.2s ease}.chat-form input:focus{border-color:#f08b95;background:#fff;box-shadow:0 0 0 4px rgba(230,0,18,.08)}.chat-form input::placeholder{color:#9ca3af}
.send-btn{width:52px;height:52px;min-width:52px;border:none;border-radius:16px;background:linear-gradient(135deg,var(--primary) 0%,var(--primary-dark) 100%);color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:.2s ease;box-shadow:0 8px 18px rgba(230,0,18,.2)}.send-btn:hover{transform:translateY(-1px)}.send-btn:disabled{opacity:.5;cursor:not-allowed;transform:none}.send-btn svg{width:20px;height:20px}

.lead-form{display:grid;gap:8px;margin-top:10px}.lead-form input,.customer-profile-form input,.admin input,.admin select{padding:12px;border:1px solid var(--border);border-radius:12px;background:#fff;outline:none}.lead-form input:focus,.customer-profile-form input:focus,.admin input:focus,.admin select:focus{border-color:#f08b95;box-shadow:0 0 0 4px rgba(230,0,18,.08)}
.add-order-btn,.confirm-order-btn,.form-submit,.admin button{border:0;border-radius:12px;padding:11px 14px;background:linear-gradient(135deg,var(--primary) 0%,var(--primary-dark) 100%);color:white;font-weight:800;cursor:pointer;transition:.2s ease}.add-order-btn:hover,.confirm-order-btn:hover,.form-submit:hover,.admin button:hover{transform:translateY(-1px)}
.add-order-btn{width:100%;margin-top:auto}.add-order-btn.added{background:linear-gradient(135deg,#15803d 0%,#166534 100%)}.add-order-btn:disabled{cursor:default;opacity:.92}
.stock-available{color:#15803d;font-weight:700;margin:8px 0}
.order-summary{border:1px solid #f5d6d9;background:#fff;border-radius:18px;padding:14px 16px;margin-bottom:12px;box-shadow:var(--shadow)}.order-title{font-weight:800;margin-bottom:8px;color:var(--text)}.order-item{display:flex;justify-content:space-between;gap:12px;font-size:13px;padding:6px 0;align-items:flex-start}.order-item>span:last-child{display:flex;align-items:center;gap:8px;white-space:nowrap}.order-total{font-weight:800;text-align:right;margin:8px 0;color:var(--text)}.remove-order-btn{border:0;background:transparent;color:#b91c1c;font-size:20px;line-height:1;cursor:pointer;padding:0 4px}
.muted{color:var(--text-muted);font-size:12px}
.saved-contact-card{display:grid;gap:3px;border:1px solid var(--border);border-radius:14px;padding:12px;background:#fafafa;margin:10px 0}.saved-contact-card span{font-size:13px;color:var(--text-secondary)}.saved-contact-actions{display:flex;gap:8px;flex-wrap:wrap}.saved-contact-actions .form-submit,.saved-contact-actions .secondary-action{margin:0}

.customer-modal[hidden]{display:none}.customer-modal{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;padding:20px}.customer-modal-backdrop{position:absolute;inset:0;background:rgba(17,24,39,.45)}.customer-modal-card{position:relative;z-index:1;background:#fff;width:min(760px,100%);max-height:88vh;overflow:auto;border-radius:22px;padding:24px;box-shadow:0 24px 70px rgba(0,0,0,.22)}.customer-modal-close{position:absolute;right:14px;top:10px;border:0;background:transparent;font-size:28px;cursor:pointer;color:#666}.customer-modal-card h2{margin:0 0 18px;font-size:24px}.customer-profile-form{display:grid;gap:12px}.customer-profile-form label{display:grid;gap:6px;font-size:13px;font-weight:700}.customer-section{margin-top:22px;padding-top:16px;border-top:1px solid var(--border)}.customer-section h3{margin:0 0 10px;font-size:16px}.customer-row{padding:8px 0;border-bottom:1px solid #eee}.customer-order{display:grid;grid-template-columns:110px 1fr auto;gap:10px;padding:10px 0;border-bottom:1px solid #eee;align-items:start;font-size:13px}.customer-order span{color:var(--text-secondary)}

.admin{max-width:1200px;margin:30px auto;padding:20px}.admin h1{font-size:34px;margin-bottom:18px}.panel{background:white;padding:22px;border-radius:18px;margin-bottom:20px;box-shadow:var(--shadow);border:1px solid var(--border)}.admin input,.admin button,.admin select{margin:5px}.admin button:disabled{opacity:.6;cursor:default}.table-wrap{overflow:auto}table{width:100%;border-collapse:collapse;font-size:13px}th,td{padding:10px;border-bottom:1px solid #eee;text-align:left;vertical-align:top}th{font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--text-muted)}.status-ok{color:#15803d}.status-error{color:#b91c1c}.search-results{display:grid;gap:8px;margin-top:12px}.search-result{border:1px solid var(--border);border-radius:12px;padding:12px;background:#fff}.muted-admin{color:var(--text-secondary);font-size:12px}

.sidebar-toggle{display:none;width:42px;height:42px;border-radius:12px;border:1px solid var(--border);background:#fff;box-shadow:var(--shadow);align-items:center;justify-content:center;gap:4px;padding:10px;cursor:pointer}.sidebar-toggle span{display:block;width:16px;height:2px;background:var(--text);border-radius:99px}.sidebar-close{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid var(--border);background:#fff;border-radius:10px;font-size:22px;line-height:1;cursor:pointer;color:var(--text)}

@media (max-width: 1100px){
  .brand-logo-image{width:136px}
  .brand-text h1{font-size:24px}
  .sidebar{width:270px}
}
@media (max-width: 900px){
  .mobile-only{display:flex}
  .desktop-only{display:none}
  .sidebar-toggle{display:inline-flex}
  .header{height:auto;min-height:var(--header-height);padding:16px}
  .header-left{min-width:0;flex:1}
  .brand-logo-image{width:118px}
  .brand-overline{font-size:11px}
  .brand-text h1{font-size:22px}
  .brand-text span{font-size:12px}
  .header-actions{margin-left:0;gap:8px;align-items:flex-end;max-width:52%}
  .customer-access{justify-content:flex-end}
  .customer-label{display:none}
  .google-signin-button{max-width:150px;overflow:hidden}
  .sidebar{position:fixed;left:0;top:0;bottom:0;width:min(86vw,340px);z-index:40;transform:translateX(-104%);transition:transform .25s ease;box-shadow:var(--shadow-lg)}
  .sidebar-top{display:flex;align-items:center;justify-content:space-between}
  .sidebar-overlay{display:block;position:fixed;inset:0;background:rgba(17,24,39,.45);z-index:35;opacity:0;pointer-events:none;transition:opacity .2s ease}
  .sidebar-open .sidebar{transform:translateX(0)}
  .sidebar-open .sidebar-overlay{opacity:1;pointer-events:auto}
  .chat-messages{padding:18px}
  .chat-input-area{padding:14px 16px 18px}
  .message{max-width:95%}
}
@media (max-width: 640px){
  body{overflow:hidden}
  .header{padding:12px 14px;align-items:flex-start;gap:10px;flex-direction:column}
  .header-left,.header-actions{width:100%}
  .header-actions{justify-content:space-between;max-width:none}
  .brand-logo-image{width:106px}
  .brand-text h1{font-size:20px}
  .customer-profile-btn{padding:9px 12px;font-size:13px}
  .chat-messages{padding:14px;gap:12px}
  .message{gap:8px;max-width:100%}
  .message-avatar{width:34px;height:34px;min-width:34px;padding:5px}
  .message-content{padding:14px}
  .product-cards{grid-template-columns:1fr}
  .typing-indicator{padding:0 14px 8px}
  .chat-input-area{padding:12px 12px calc(12px + env(safe-area-inset-bottom))}
  .quick-suggestions{flex-wrap:nowrap;overflow-x:auto}
  .suggestion-chip{padding:8px 12px}
  .chat-form{gap:8px}
  .chat-form input{padding:14px 16px;font-size:14px}
  .send-btn{width:48px;height:48px;min-width:48px;border-radius:14px}
  .order-item{flex-direction:column;gap:6px}.order-item>span:last-child{justify-content:space-between;width:100%}
  .saved-contact-actions{flex-direction:column}.saved-contact-actions .form-submit,.saved-contact-actions .secondary-action{width:100%}
  .customer-modal{padding:10px}.customer-modal-card{padding:20px 16px;border-radius:18px;max-height:92vh}.customer-order{grid-template-columns:1fr}
  .admin{padding:14px}.panel{padding:16px}.admin h1{font-size:28px}
}
