/* ------------------------------ Reset / Base --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:Inter,sans-serif;background:#f0f2f5;color:#222;min-height:100vh;display:flex;flex-direction:column}
a{color:inherit;text-decoration:none}
button{cursor:pointer;font-family:inherit}

/* ------------------------------ Layout --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
.a-wrap{display:flex;min-height:100vh}
.a-sidebar{width:230px;background:#1a1a2e;color:#ccc;flex-shrink:0;display:flex;flex-direction:column}
.a-main{flex:1;display:flex;flex-direction:column;min-width:0}

/* ------------------------------ Topbar --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
.a-topbar{background:#fff;border-bottom:1px solid #e8e8e8;padding:0 24px;height:54px;display:flex;align-items:center;gap:12px;box-shadow:0 1px 4px rgba(0,0,0,.06)}
.a-topbar h1{font-size:1rem;font-weight:600;color:#1a1a2e}
.a-topbar .spacer{flex:1}
.a-topbar .who{font-size:.85rem;color:#888}
.btn-logout{background:none;border:1px solid #e74c3c;color:#e74c3c;border-radius:6px;padding:4px 12px;font-size:.8rem}
.btn-logout:hover{background:#fdecea}

/* ------------------------------ Sidebar ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ */
.a-logo{padding:18px 20px;font-size:1rem;font-weight:700;color:#fff;border-bottom:1px solid rgba(255,255,255,.1)}
.a-logo span{opacity:.5;font-size:.75rem;font-weight:400;display:block}
.a-nav{flex:1;padding:8px 0}
.a-nav a{display:flex;align-items:center;gap:10px;padding:10px 20px;font-size:.88rem;color:#bbb;transition:.15s;border-left:3px solid transparent}
.a-nav a:hover{color:#fff;background:rgba(255,255,255,.07)}
.a-nav a.active{color:#fff;border-left-color:#4c9be8;background:rgba(76,155,232,.12)}
.a-nav .nav-icon{font-size:1rem;width:20px;text-align:center}
.a-nav .badge-count{margin-left:auto;background:#e74c3c;color:#fff;font-size:.7rem;padding:1px 6px;border-radius:10px}

/* ------------------------------ Content ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ */
.a-content{flex:1;padding:24px;overflow-y:auto}
.view{display:none}
.view.active{display:block}
.page-title{font-size:1.2rem;font-weight:700;margin-bottom:20px;color:#1a1a2e}

/* ------------------------------ Cards --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
.card{background:#fff;border-radius:10px;box-shadow:0 1px 6px rgba(0,0,0,.06);padding:20px;margin-bottom:20px}
.card h3{font-size:.95rem;font-weight:600;margin-bottom:14px;color:#333}

/* ------------------------------ Dashboard metrics ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ */
.metrics{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:14px;margin-bottom:20px}
.metric{background:#fff;border-radius:10px;padding:18px 20px;box-shadow:0 1px 6px rgba(0,0,0,.06);border-left:4px solid #4c9be8}
.metric.red{border-left-color:#e74c3c}.metric.green{border-left-color:#27ae60}.metric.orange{border-left-color:#e67e22}
.metric-val{font-size:1.8rem;font-weight:700;line-height:1.1}
.metric-lbl{font-size:.78rem;color:#888;margin-top:4px}

/* ------------------------------ Tables --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
.tbl-wrap{overflow-x:auto}
table{width:100%;border-collapse:collapse;font-size:.875rem}
th,td{text-align:left;padding:10px 12px;border-bottom:1px solid #f0f0f0}
th{font-weight:600;color:#555;background:#fafafa;white-space:nowrap}
tr:hover td{background:#fafbfc}

/* ------------------------------ Filters --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
.filter-bar{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:14px;align-items:center}
.filter-bar input,.filter-bar select{padding:7px 12px;border-radius:7px;border:1px solid #ddd;font-size:.875rem;font-family:inherit}
.filter-bar input{min-width:200px}
.filter-bar .spacer{flex:1}

/* ------------------------------ Badges --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
.badge{display:inline-block;padding:2px 8px;border-radius:20px;font-size:.72rem;font-weight:600}
.badge-green{background:#e8f5e9;color:#27ae60}
.badge-yellow{background:#fff8e1;color:#f39c12}
.badge-red{background:#fdecea;color:#e74c3c}
.badge-blue{background:#e3f2fd;color:#1565c0}
.badge-grey{background:#f5f5f5;color:#888}

/* ------------------------------ Buttons --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
.btn{padding:6px 14px;border-radius:7px;border:none;font-size:.85rem;font-family:inherit;transition:.15s}
.btn-primary{background:#1a5276;color:#fff}.btn-primary:hover{background:#154360}
.btn-success{background:#27ae60;color:#fff}.btn-success:hover{background:#219a52}
.btn-danger{background:#e74c3c;color:#fff}.btn-danger:hover{background:#c0392b}
.btn-outline{background:#fff;border:1px solid #ddd;color:#444}.btn-outline:hover{border-color:#999}
.btn-sm{padding:4px 10px;font-size:.8rem}
.btn:disabled{opacity:.4;cursor:default}

/* ------------------------------ Forms --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:12px}
.form-row.single{grid-template-columns:1fr}
.form-group{display:flex;flex-direction:column;gap:5px}
.form-group label{font-size:.8rem;font-weight:600;color:#555}
.form-group input,.form-group select,.form-group textarea{padding:8px 12px;border-radius:7px;border:1px solid #ddd;font-size:.875rem;font-family:inherit}
.form-group textarea{resize:vertical;min-height:80px}

/* ------------------------------ Chat ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ */
.chat-layout{display:grid;grid-template-columns:320px 1fr;gap:0;height:calc(100vh - 140px);min-height:400px}
.chat-list{border-right:1px solid #eee;overflow-y:auto}
.chat-item{padding:12px 16px;border-bottom:1px solid #f0f0f0;cursor:pointer;transition:.15s}
.chat-item:hover,.chat-item.active{background:#f0f4ff}
.chat-item .ci-name{font-weight:600;font-size:.875rem}
.chat-item .ci-preview{font-size:.78rem;color:#888;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px}
.chat-item .ci-meta{display:flex;justify-content:space-between;align-items:center;margin-top:4px}
.chat-item .ci-time{font-size:.72rem;color:#aaa}
.chat-pane{display:flex;flex-direction:column;overflow:hidden}
.chat-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:8px}
.msg{max-width:72%;padding:9px 14px;border-radius:12px;font-size:.875rem;line-height:1.4}
.msg-user{align-self:flex-start;background:#f0f0f0;border-bottom-left-radius:4px}
.msg-admin{align-self:flex-end;background:#1a5276;color:#fff;border-bottom-right-radius:4px}
.msg-internal{align-self:flex-end;background:#fff8e1;color:#5d4037;border:1px solid #ffe082;border-bottom-right-radius:4px;font-style:italic}
.msg-time{font-size:.7rem;opacity:.6;margin-top:2px}
.chat-input{padding:12px 16px;border-top:1px solid #eee;display:flex;gap:8px;align-items:flex-end}
.chat-input textarea{flex:1;padding:8px 12px;border:1px solid #ddd;border-radius:8px;resize:none;font-family:inherit;font-size:.875rem;max-height:120px}
.chat-toolbar{padding:8px 16px;border-bottom:1px solid #eee;display:flex;gap:8px;align-items:center;background:#fafafa}

/* ------------------------------ Pagination --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
.pagination{display:flex;gap:6px;align-items:center;margin-top:14px}
.pagination button{padding:4px 10px;border-radius:6px;border:1px solid #ddd;background:#fff;font-size:.8rem}
.pagination button.active{background:#1a5276;color:#fff;border-color:#1a5276}
.pagination span{font-size:.8rem;color:#888}

/* ------------------------------ Modal --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
.modal-bg{display:none;position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:1000;align-items:center;justify-content:center}
.modal-bg.open{display:flex}
.modal{background:#fff;border-radius:12px;padding:24px;min-width:340px;max-width:520px;width:100%;max-height:90vh;overflow-y:auto;box-shadow:0 8px 40px rgba(0,0,0,.2)}
.modal h3{font-size:1rem;font-weight:700;margin-bottom:16px}
.modal-footer{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}

/* ------------------------------ Notice ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ */
.notice{padding:10px 16px;border-radius:8px;font-size:.85rem;margin-bottom:14px}
.notice-ok{background:#e8f5e9;color:#2e7d32;border:1px solid #a5d6a7}
.notice-err{background:#fdecea;color:#c0392b;border:1px solid #ef9a9a}
#globalMsg{position:fixed;bottom:20px;right:20px;z-index:2000;display:none;padding:12px 20px;border-radius:8px;font-size:.875rem;box-shadow:0 4px 16px rgba(0,0,0,.15);max-width:360px}

/* -- Breadcrumb --------------------------------------- */
.a-breadcrumb{background:#fff;border-bottom:1px solid #eee;padding:6px 24px;font-size:.8rem;color:#888;display:flex;align-items:center;gap:6px}
.a-breadcrumb a{color:#1a5276;text-decoration:none}.a-breadcrumb a:hover{text-decoration:underline}
.a-breadcrumb span:last-child{color:#333;font-weight:500}

/* -- Dark theme ---------------------------------------- */
body.dark-theme { background:#111827; color:#e5e7eb; }
body.dark-theme .a-topbar { background:#1f2937; border-color:#374151; }
body.dark-theme .a-topbar h1 { color:#f9fafb; }
body.dark-theme .a-topbar .who { color:#9ca3af; }
body.dark-theme .card { background:#1f2937; box-shadow:0 1px 6px rgba(0,0,0,.3); }
body.dark-theme .card h3 { color:#d1d5db; }
body.dark-theme .metric { background:#1f2937; }
body.dark-theme th { background:#111827; color:#9ca3af; }
body.dark-theme th,body.dark-theme td { border-color:#374151; }
body.dark-theme tr:hover td { background:#283141; }
body.dark-theme .filter-bar input,body.dark-theme .filter-bar select { background:#111827; border-color:#374151; color:#e5e7eb; }
body.dark-theme .form-group input,body.dark-theme .form-group select,body.dark-theme .form-group textarea { background:#111827; border-color:#374151; color:#e5e7eb; }
body.dark-theme .modal { background:#1f2937; color:#e5e7eb; }
body.dark-theme .modal-bg { background:rgba(0,0,0,.65); }
body.dark-theme .btn-outline { background:#1f2937; border-color:#4b5563; color:#d1d5db; }
body.dark-theme .btn-outline:hover { border-color:#9ca3af; }
body.dark-theme .a-breadcrumb { background:#1f2937; border-color:#374151; }
body.dark-theme #globalMsg { border-color:#374151; }
body.dark-theme .chat-item:hover,body.dark-theme .chat-item.active { background:#283141; }
body.dark-theme .chat-item,.dark-theme .chat-messages,.dark-theme .chat-input,.dark-theme .chat-list { background:#1f2937; }
body.dark-theme .chat-input textarea { background:#111827; border-color:#374151; color:#e5e7eb; }
body.dark-theme .msg-user { background:#374151; color:#e5e7eb; }
body.dark-theme .page-title { color:#f9fafb; }

/* -- Image picker grid --------------------------------- */
#imgPickerGrid img { transition: opacity .15s; }
#imgPickerGrid img:hover { opacity:.85; }
.form-section-title { border-bottom:1px solid #e5e7eb; padding-bottom:4px; }
body.dark-theme .form-section-title { border-color:#374151; color:#9ca3af; }
body.dark-theme #ccCatsWrap { border-color:#374151; background:#111827; }
body.dark-theme #ccCatsWrap label { background:#1f2937; color:#d1d5db; }
body.dark-theme #ccPortfolioList > div { border-color:#374151; background:#111827; }
body.dark-theme #ccAvatarPreview { background:#111827; border-color:#374151; }
body.dark-theme #imgPickerGrid > div { background:#1f2937; }
body.dark-theme #imgPickerGrid div > div { color:#9ca3af; }
