
:root {
  --bg:           #f5f5f7;
  --surface:      #ffffff;
  --surface-2:    #fbfbfd;
  --surface-3:    #f0f0f3;
  --border:       rgba(0,0,0,.08);
  --border-strong:rgba(0,0,0,.14);
  --text-1:       #1d1d1f;
  --text-2:       #515154;
  --text-3:       #86868b;
  --text-4:       #aeaeb2;
  --blue:         #0071e3;
  --blue-light:   #e8f0fe;
  --blue-hover:   #0077ed;
  --green:        #28cd41;
  --green-light:  #e6f9ea;
  --orange:       #ff9500;
  --orange-light: #fff4e0;
  --red:          #ff3b30;
  --red-light:    #ffe8e6;
  --purple:       #bf5af2;
  --purple-light: #f5e8fe;
  --teal:         #32ade6;
  --teal-light:   #e5f5fd;
  --radius-s:     8px;
  --radius-m:     12px;
  --radius-l:     18px;
  --radius-xl:    24px;
  --shadow-s:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-m:     0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-l:     0 8px 32px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.05);
  --sidebar-w:    240px;
  --topbar-h:     52px;
  --font:         -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  --transition:   .18s cubic-bezier(.4,0,.2,1);
  --primary:      #0071e3;
  --primary-dark: #004ab3;
  --primary-light:#e8f0fe;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { font-family: var(--font); background: var(--bg); color: var(--text-1); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; height: 100%; overflow: hidden; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* LOGIN */
#login-screen { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; align-items: center; justify-content: center; transition: opacity .4s ease; }
#login-screen.hidden { opacity: 0; pointer-events: none; }
.login-wrap { display: flex; flex-direction: column; align-items: center; gap: 40px; width: 100%; max-width: 400px; padding: 0 24px; animation: loginFadeIn .6s cubic-bezier(.4,0,.2,1) both; }
@keyframes loginFadeIn { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: translateY(0); } }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.login-logo-mark { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(145deg, #0071e3, #004ab3); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 20px rgba(0,113,227,.3); }
.login-logo-mark svg { width: 28px; height: 28px; }
.login-logo-name { font-size: 20px; font-weight: 600; letter-spacing: -.4px; color: var(--text-1); }
.login-logo-sub { font-size: 13px; color: var(--text-3); margin-top: -8px; }
.login-card { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 32px; box-shadow: var(--shadow-l); display: flex; flex-direction: column; gap: 20px; }
.login-card h2 { font-size: 22px; font-weight: 600; letter-spacing: -.4px; text-align: center; }
.login-card p { font-size: 13px; color: var(--text-3); text-align: center; margin-top: -12px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 12px; font-weight: 500; color: var(--text-2); letter-spacing: .2px; text-transform: uppercase; }
.form-field input { padding: 11px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-s); font-size: 15px; font-family: var(--font); color: var(--text-1); background: var(--surface-2); outline: none; transition: border-color var(--transition), box-shadow var(--transition); }
.form-field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,113,227,.12); background: var(--surface); }
.login-btn { width: 100%; padding: 13px; background: var(--blue); color: #fff; border: none; border-radius: var(--radius-s); font-size: 15px; font-weight: 500; font-family: var(--font); cursor: pointer; transition: background var(--transition), transform var(--transition); }
.login-btn:hover { background: var(--blue-hover); }
.login-btn:active { transform: scale(.99); }
#login-error { font-size: 13px; color: var(--red); text-align: center; min-height: 16px; }

/* APP SHELL */
#app { display: flex; height: 100vh; overflow: hidden; }
#sidebar { width: var(--sidebar-w); background: rgba(255,255,255,.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; padding: 16px 0 24px; }
.sidebar-header { padding: 0 16px 16px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; }
.sidebar-brand-icon { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(145deg,#0071e3,#004ab3); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-brand-icon svg { width: 16px; height: 16px; }
.sidebar-brand-name { font-size: 14px; font-weight: 600; color: var(--text-1); line-height: 1.2; }
.sidebar-brand-sub { font-size: 11px; color: var(--text-3); }
.sidebar-section { padding: 4px 8px; margin-top: 4px; }
.sidebar-section-label { font-size: 10px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: .6px; padding: 4px 8px 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: var(--radius-s); cursor: pointer; transition: background var(--transition); color: var(--text-2); font-size: 13px; font-weight: 500; margin: 1px 0; text-decoration: none; }
.nav-item:hover { background: var(--surface-3); color: var(--text-1); }
.nav-item.active { background: var(--blue-light); color: var(--blue); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 600; border-radius: 10px; padding: 1px 6px; min-width: 18px; text-align: center; }
.nav-badge.blue { background: var(--blue); }
.sidebar-user { padding: 12px 16px 0; border-top: 1px solid var(--border); margin-top: auto; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg,#0071e3,#32ade6); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--text-1); }
.user-role { font-size: 11px; color: var(--text-3); }
.user-logout { display:flex; align-items:center; gap:5px; margin-left:auto; font-size:11px; color:var(--text-3); cursor:pointer; padding:4px 8px; border-radius:6px; border:1px solid transparent; transition:all .15s; white-space:nowrap; }
.user-logout:hover { color:var(--red,#dc2626); background:rgba(220,38,38,.08); border-color:rgba(220,38,38,.2); }
.sidebar-logout-btn { width:100%; display:flex; align-items:center; justify-content:center; gap:6px; margin-top:8px; padding:7px 0; border-radius:8px; border:1px solid var(--border); background:transparent; color:var(--text-3); font-size:12px; cursor:pointer; transition:all .15s; }
.sidebar-logout-btn:hover { color:var(--red,#dc2626); background:rgba(220,38,38,.07); border-color:rgba(220,38,38,.25); }

/* MAIN */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#topbar { height: var(--topbar-h); background: rgba(255,255,255,.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-shrink: 0; }
#topbar-title { font-size: 17px; font-weight: 600; color: var(--text-1); letter-spacing: -.3px; }
.topbar-search { flex: 1; max-width: 360px; margin-left: auto; position: relative; }
.topbar-search input { width: 100%; padding: 7px 12px 7px 32px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 20px; font-size: 13px; font-family: var(--font); color: var(--text-1); outline: none; transition: all var(--transition); }
.topbar-search input:focus { background: var(--surface); border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,113,227,.1); }
.topbar-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); }
#topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--transition); position: relative; }
.topbar-btn:hover { background: var(--surface); }
.topbar-btn svg { width: 16px; height: 16px; color: var(--text-2); }
.notif-dot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; background: var(--red); border-radius: 50%; border: 1.5px solid var(--surface); }

/* CONTENT */
#content { flex: 1; overflow-y: auto; padding: 24px; }
.page { display: none; animation: pageFade .2s ease; }
.page.active { display: block; }
@keyframes pageFade { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 24px; font-weight: 700; letter-spacing: -.5px; color: var(--text-1); }
.page-header p { font-size: 14px; color: var(--text-3); margin-top: 4px; }

/* CARDS */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: 20px; box-shadow: var(--shadow-s); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; color: var(--text-1); }
.card-subtitle { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.card-link { font-size: 13px; color: var(--blue); cursor: pointer; font-weight: 500; }

/* GRID */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }

/* KPI */
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 16px; box-shadow: var(--shadow-s); }
.kpi-label { font-size: 12px; color: var(--text-3); font-weight: 500; margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.5px; color: var(--text-1); }
.kpi-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.kpi-value.blue { color: var(--blue); }
.kpi-value.green { color: var(--green); }
.kpi-value.orange { color: var(--orange); }
.kpi-value.red { color: var(--red); }

/* BADGE */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-gray { background: var(--surface-3); color: var(--text-3); }
.badge-teal { background: var(--teal-light); color: var(--teal); }

/* TICKET LIST */
.ticket-list { display: flex; flex-direction: column; gap: 8px; }
.ticket-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-m); cursor: pointer; transition: all var(--transition); }
.ticket-item:hover { background: var(--surface); border-color: var(--blue); box-shadow: var(--shadow-s); }
.ticket-key { font-size: 11px; font-weight: 600; color: var(--blue); font-family: monospace; white-space: nowrap; }
.ticket-summary { flex: 1; font-size: 13px; color: var(--text-1); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ticket-date { font-size: 11px; color: var(--text-3); }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.priority-Critical { background: var(--red); }
.priority-High { background: var(--orange); }
.priority-Medium { background: var(--blue); }
.priority-Low { background: var(--text-4); }

/* SERVICE CATALOG */
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.catalog-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 16px; cursor: pointer; transition: all var(--transition); display: flex; flex-direction: column; gap: 8px; }
.catalog-item:hover { border-color: var(--blue); box-shadow: var(--shadow-m); transform: translateY(-1px); }
.catalog-icon { width: 40px; height: 40px; border-radius: var(--radius-s); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.catalog-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.catalog-desc { font-size: 12px; color: var(--text-3); line-height: 1.4; }
.catalog-sla { font-size: 11px; color: var(--blue); font-weight: 500; }

/* FORM */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: .2px; text-transform: uppercase; }
.form-input { padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-s); font-size: 14px; font-family: var(--font); color: var(--text-1); background: var(--surface-2); outline: none; transition: all var(--transition); width: 100%; }
.form-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,113,227,.1); background: var(--surface); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-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='%2386868b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.btn { padding: 10px 20px; border-radius: var(--radius-s); font-size: 14px; font-weight: 500; font-family: var(--font); cursor: pointer; transition: all var(--transition); border: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-secondary { background: var(--surface-3); color: var(--text-1); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--surface); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* CHAT AI */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 48px - 120px); }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; gap: 10px; align-items: flex-start; max-width: 80%; }
.chat-msg.user { flex-direction: row-reverse; align-self: flex-end; }
.chat-bubble { padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; }
.chat-msg.bot .chat-bubble { background: var(--surface); border: 1px solid var(--border); color: var(--text-1); border-radius: 4px 14px 14px 14px; }
.chat-msg.user .chat-bubble { background: var(--blue); color: #fff; border-radius: 14px 4px 14px 14px; }
.chat-avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.chat-avatar.bot { background: var(--blue-light); color: var(--blue); font-weight: 700; }
.chat-avatar.user { background: var(--surface-3); color: var(--text-2); }
.chat-input-row { display: flex; gap: 8px; padding: 12px 0; }
.chat-input-row input { flex: 1; padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: 20px; font-size: 14px; font-family: var(--font); background: var(--surface); outline: none; }
.chat-input-row input:focus { border-color: var(--blue); }
.chat-send { width: 40px; height: 40px; border-radius: 50%; background: var(--blue); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-send svg { width: 16px; height: 16px; color: #fff; }

/* KB */
.kb-result { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-m); margin-bottom: 8px; cursor: pointer; transition: all var(--transition); }
.kb-result:hover { border-color: var(--blue); background: var(--blue-light); }
.kb-result-title { font-size: 14px; font-weight: 600; color: var(--text-1); margin-bottom: 4px; }
.kb-result-meta { font-size: 12px; color: var(--text-3); }
.kb-result-excerpt { font-size: 13px; color: var(--text-2); margin-top: 6px; }

/* STATUS PAGE */
.status-service { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-dot.ok { background: var(--green); }
.status-dot.warn { background: var(--orange); }
.status-dot.down { background: var(--red); }
.status-name { font-size: 14px; font-weight: 500; color: var(--text-1); flex: 1; }
.status-label { font-size: 12px; color: var(--text-3); }

/* ASSET */
.asset-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-m); cursor: pointer; transition: all var(--transition); }
.asset-card:hover { background: var(--surface); border-color: var(--blue); }
.asset-icon { width: 40px; height: 40px; border-radius: var(--radius-s); background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.asset-info { flex: 1; }
.asset-name { font-size: 14px; font-weight: 600; color: var(--text-1); }
.asset-meta { font-size: 12px; color: var(--text-3); }

/* EMPTY STATE */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; text-align: center; }
.empty-icon { font-size: 40px; margin-bottom: 16px; opacity: .5; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--text-3); }

/* SPINNER */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* TOAST */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--text-1); color: #fff; padding: 12px 18px; border-radius: var(--radius-m); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-l); animation: toastIn .3s ease; pointer-events: auto; max-width: 320px; }
.toast.success { background: #1a7f37; }
.toast.warning { background: #b45309; }
.toast.error { background: #b91c1c; }
@keyframes toastIn { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 24px; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border-radius: var(--radius-xl); padding: 28px; width: 100%; max-width: 560px; max-height: 80vh; overflow-y: auto; transform: scale(.95); transition: transform .2s ease; box-shadow: var(--shadow-l); }
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 18px; font-weight: 600; }
.modal-close { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.modal-close svg { width: 14px; height: 14px; }

/* TABS */
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: var(--radius-m); margin-bottom: 20px; }
.tab-btn { flex: 1; padding: 7px 12px; border-radius: var(--radius-s); border: none; background: transparent; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; transition: all var(--transition); }
.tab-btn.active { background: var(--surface); color: var(--text-1); box-shadow: var(--shadow-s); }

/* AI SUGGESTIONS */
.ai-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; background: linear-gradient(135deg, var(--purple-light), var(--blue-light)); border: 1px solid rgba(191,90,242,.2); border-radius: 20px; font-size: 12px; font-weight: 500; color: var(--purple); cursor: pointer; transition: all var(--transition); }
.ai-chip:hover { box-shadow: 0 2px 8px rgba(191,90,242,.2); }
.ai-chip svg { width: 12px; height: 12px; }
.ai-suggestion-box { background: linear-gradient(135deg, rgba(191,90,242,.05), rgba(0,113,227,.05)); border: 1px solid rgba(191,90,242,.2); border-radius: var(--radius-m); padding: 12px 14px; margin-top: 12px; font-size: 13px; color: var(--text-2); line-height: 1.6; }
