
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1923;
  --bg2:       #1a2535;
  --bg3:       #223044;
  --border:    #2a3a50;
  --primary:   #1a6b3c;
  --primary-light: #22875a;
  --gold:      #c9a84c;
  --gold-dim:  #a08838;
  --text:      #e8edf2;
  --text-dim:  #8899aa;
  --green:     #22c55e;
  --red:       #ef4444;
  --teal:      #14b8a6;
}

body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; margin: 0; }

/* ── LOGIN ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 60% 40%, #1a2535 0%, #0f1923 70%);
}
.login-box {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 16px;
  padding: 48px 40px; width: 380px; box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .brand-name { font-size: 28px; font-weight: 800; color: var(--gold); letter-spacing: 1px; }
.login-logo .brand-sub { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input {
  width: 100%; padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; outline: none; transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--gold); }
.btn-primary {
  width: 100%; padding: 12px; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff; font-weight: 600; font-size: 14px; border: none; border-radius: 8px;
  cursor: pointer; transition: all 0.2s; margin-top: 8px;
  box-shadow: 0 2px 8px rgba(26,107,60,0.3);
}
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(26,107,60,0.4); }
.btn-primary:active { transform: translateY(0); }
.error-msg { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

/* ── TOP NAVBAR ── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: #1a2535;
  border-bottom: 1px solid #1a6b3c;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  display: flex;
  flex-direction: column;
  min-width: 160px;
}
.navbar-brand .brand-name {
  font-size: 18px;
  font-weight: 700;
  color: #c9a84c;
  line-height: 1.2;
}
.navbar-brand .brand-sub {
  font-size: 11px;
  color: #8899aa;
  line-height: 1;
}
.navbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}
.navbar-nav a {
  padding: 6px 14px;
  color: #b0c4d8;
  text-decoration: none;
  font-size: 14px;
  border-radius: 6px;
  transition: all 0.2s;
  white-space: nowrap;
}
.navbar-nav a:hover {
  background: rgba(26,107,60,0.2);
  color: #c9a84c;
}
.navbar-nav a.active {
  background: rgba(26,107,60,0.35);
  color: #c9a84c;
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--gold);
}
.navbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 160px;
  justify-content: flex-end;
}
.navbar-user .username {
  color: #b0c4d8;
  font-size: 14px;
}
.btn-logout {
  padding: 5px 14px;
  background: transparent;
  border: 1px solid #1a6b3c;
  color: #c9a84c;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.btn-logout:hover {
  background: #1a6b3c;
  color: #fff;
}

/* ── MAIN CONTENT ── */
.main-content { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 600; color: var(--text); }
.page-sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

/* ── STATS ROW ── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px;
  transition: all 0.2s ease; position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--gold));
  opacity: 0; transition: opacity 0.2s;
}
.stat-card:hover { border-color: rgba(26,107,60,0.4); box-shadow: 0 4px 16px rgba(0,0,0,0.2); }
.stat-card:hover::after { opacity: 1; }
.stat-num { font-size: 26px; font-weight: 700; color: var(--gold); letter-spacing: -0.5px; }
.stat-label { font-size: 12px; color: var(--text-dim); margin-top: 5px; font-weight: 500; }

/* ── SECTION LABEL ── */
.section-label {
  margin-bottom: 16px; font-size: 13px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* ── CARDS GRID ── */
.cards-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
@media (max-width: 1000px) { .cards-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .cards-grid, .stats-row { grid-template-columns: 1fr; } }

.card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; cursor: pointer; transition: all 0.25s ease; text-decoration: none; display: block;
  position: relative; overflow: hidden;
}
.card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--gold));
  opacity: 0; transition: opacity 0.25s;
}
.card:hover { border-color: rgba(26,107,60,0.5); transform: translateY(-3px); box-shadow: 0 12px 32px rgba(0,0,0,0.35); }
.card:hover::before { opacity: 1; }
.card-icon { font-size: 28px; margin-bottom: 12px; }
.card-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.card-desc { font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.card-badge {
  display: inline-block; margin-top: 12px; padding: 3px 10px;
  background: rgba(26,107,60,0.15); color: var(--green);
  font-size: 11px; font-weight: 500; border-radius: 20px;
}
.card-badge.badge-gold {
  background: rgba(201,168,76,0.12); color: var(--gold);
}
.card-badge.badge-teal {
  background: rgba(20,184,166,0.12); color: var(--teal);
}
.card-badge.badge-admin {
  background: rgba(239,68,68,0.1); color: #f87171;
}

/* ── CHAT ── */
.chat-area {
  max-width: 900px; margin: 0 auto; display: flex; flex-direction: column;
  height: calc(100vh - 130px); padding: 0 32px;
}
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0 16px;
}
.chat-messages { flex: 1; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 12px; max-width: 80%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 14px; flex-shrink: 0;
}
.msg.ai .msg-avatar { background: rgba(26,107,60,0.2); }
.msg.user .msg-avatar { background: var(--gold); color: #0f1923; font-weight: 700; }
.msg-bubble { padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.6; }
.msg.ai .msg-bubble { background: var(--bg2); border: 1px solid var(--border); color: var(--text); }
.msg.user .msg-bubble { background: var(--primary); color: #fff; font-weight: 500; }
.chat-input-row {
  display: flex; gap: 12px; padding: 16px 0; border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1; padding: 12px 16px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 14px; outline: none; resize: none;
  font-family: 'Inter', sans-serif;
}
.chat-input:focus { border-color: var(--gold); }
.btn-send {
  padding: 12px 20px; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff; font-weight: 600; border: none; border-radius: 10px; cursor: pointer; font-size: 14px;
  transition: opacity 0.2s;
}
.btn-send:hover { opacity: 0.9; }
.model-select {
  padding: 8px 12px; background: var(--bg2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; font-size: 13px; outline: none;
}

/* ── TABLE ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px 16px; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: var(--bg3); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.badge-green { background: rgba(34,197,94,0.1); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.1); color: var(--red); }
.badge-gold { background: rgba(201,168,76,0.1); color: var(--gold); }

/* ── FORM ── */
.form-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 24px; max-width: 600px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; outline: none; transition: border-color 0.2s;
  font-family: 'Inter', sans-serif;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--gold); }
.form-field select option { background: var(--bg3); }
.btn-submit {
  padding: 10px 24px; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff; font-weight: 600; font-size: 14px; border: none; border-radius: 8px; cursor: pointer;
  transition: opacity 0.2s;
}
.btn-submit:hover { opacity: 0.9; }

/* ── ALERT ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #4ade80; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }

/* ── SKILL MODAL ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px; width: 560px; max-height: 80vh; overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; font-weight: 600; color: var(--text); }
.modal-close {
  background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer;
  padding: 4px 8px; border-radius: 4px; transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

/* ── SKILL RESULT ── */
.result-box {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; margin-top: 20px; white-space: pre-wrap; font-size: 13px; line-height: 1.7; color: var(--text);
}
.loading { color: var(--text-dim); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── USER AVATAR ── */
.user-avatar {
  width: 32px; height: 32px; background: var(--primary); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff;
}

/* ── HISTORY TABLE ── */
.status-badge { padding: 0.25rem 0.65rem; border-radius: 12px; font-size: 0.8rem; font-weight: 600; }
.status-done { background: rgba(72,187,120,0.2); color: #48bb78; }
.status-running { background: rgba(201,168,76,0.2); color: var(--gold); }
.status-failed { background: rgba(252,129,129,0.2); color: #fc8181; }
.status-pending { background: rgba(160,174,192,0.2); color: #a0aec0; }
.btn-small { padding: 4px 12px; font-size: 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg3); color: var(--text-dim); cursor: pointer; }
.btn-small:hover { border-color: var(--gold); color: var(--text); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* MOBILE RESPONSIVE */
.hamburger-btn {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 1001;
  background: var(--bg2, #1e2130);
  border: 1px solid var(--border, #2d3148);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--text, #e2e8f0);
  font-size: 18px;
  line-height: 1;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}
@media (max-width: 768px) {
  .hamburger-btn { display: flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed !important;
    left: -260px !important;
    top: 0; height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
    overflow-y: auto;
  }
  .sidebar.open { left: 0 !important; }
  .sidebar-overlay.open { display: block; }
  .main-content, .content, main {
    margin-left: 0 !important;
    padding-top: 56px !important;
    width: 100% !important;
  }
  .modal-box, .modal-content {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    margin: 5vh auto !important;
  }
  .form-row { grid-template-columns: 1fr !important; }
  .cards-grid { grid-template-columns: 1fr !important; }
  .btn, button[type="submit"] {
    width: 100% !important;
    padding: 14px !important;
    font-size: 16px !important;
  }
  input, select, textarea { font-size: 16px !important; }
  .data-table { display: block; overflow-x: auto; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ── TOAST NOTIFICATION ── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  padding: 12px 20px; border-radius: 10px; font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); pointer-events: auto;
  animation: toast-in 0.3s ease; max-width: 320px;
}
.toast-success { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.4); color: #4ade80; }
.toast-error   { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.4); color: #f87171; }
.toast-info    { background: rgba(201,168,76,0.15); border: 1px solid rgba(201,168,76,0.4); color: var(--gold); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
/* ── MOBILE NAVBAR FIX ── */
@media (max-width: 768px) {
  .navbar { padding: 0 16px 0 52px; height: 52px; }
  .navbar-nav { display: none; }
  .navbar-user { gap: 8px; }
  .navbar-user .username { display: none; }
  .page-header { flex-direction: column; gap: 8px; }
  .page-header .page-title { font-size: 18px; }
  .chat-area { padding: 0 12px; height: calc(100vh - 110px); }
  .modal-box { width: 95vw; max-width: 95vw; padding: 20px 16px; margin: 2vh auto; }
}
/* ── UPLOAD ZONE IMPROVEMENT ── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 10px; padding: 20px;
  text-align: center; cursor: pointer; transition: all 0.2s; background: var(--bg);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--gold); background: rgba(201,168,76,0.05);
}
.upload-icon { font-size: 24px; margin-bottom: 8px; }
.upload-hint { font-size: 12px; color: var(--text-dim); }
.upload-status { font-size: 12px; margin-top: 8px; padding: 6px 10px; border-radius: 6px; }
.upload-status.uploading { color: var(--gold); background: rgba(201,168,76,0.08); }
.upload-status.success { color: var(--green); background: rgba(34,197,94,0.08); }
.upload-status.error { color: var(--red); background: rgba(239,68,68,0.08); }
/* ── RESULT BTN PRIMARY ── */
.result-btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; border-color: transparent;
}
.result-btn.primary:hover { opacity: 0.9; color: #fff; }
/* ── PAGE HEADER ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-sub { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
/* ── MAIN CONTENT ── */
.main-content { padding: 24px 32px; max-width: 1200px; margin: 0 auto; }
@media (max-width: 768px) { .main-content { padding: 16px; } }
/* ── WELCOME BANNER ── */
.welcome-banner {
  background: linear-gradient(135deg, rgba(26,107,60,0.15) 0%, rgba(201,168,76,0.08) 100%);
  border: 1px solid rgba(26,107,60,0.25); border-radius: 14px;
  padding: 20px 24px; margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
}
.welcome-text { font-size: 18px; font-weight: 600; color: var(--text); }
.welcome-sub { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.welcome-role {
  padding: 6px 16px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: rgba(201,168,76,0.15); color: var(--gold); border: 1px solid rgba(201,168,76,0.3);
}
/* ── SECTION HEADER ── */
.section-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.section-title { font-size: 14px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
/* ── STATS ROW ── */
.stats-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px;
}
@media (max-width: 640px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }

/* ── MESSAGE TIME ── */
.msg-time { font-size: 10px; color: var(--text-dim); margin-top: 4px; opacity: 0.7; }
.msg.user .msg-time { text-align: right; }
/* ── LOADING OVERLAY ── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(15,25,35,0.85); z-index: 500;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px;
}
.loading-overlay .spinner-lg {
  width: 48px; height: 48px; border: 3px solid var(--border);
  border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite;
}
.loading-overlay .loading-text { color: var(--text-dim); font-size: 14px; }
/* ── FORM FIELD IMPROVEMENT ── */
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-dim); margin-bottom: 6px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; outline: none; transition: border-color 0.2s;
  font-family: inherit;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201,168,76,0.1);
}
/* ── REGION TABS ── */
.region-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.region-tab {
  padding: 8px 18px; border-radius: 20px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border); color: var(--text-dim);
  transition: all 0.2s; background: var(--bg2);
}
.region-tab:hover { border-color: var(--gold); color: var(--text); }
.region-tab.active { background: rgba(201,168,76,0.15); border-color: var(--gold); color: var(--gold); font-weight: 600; }
.tab-count { font-size: 11px; opacity: 0.7; margin-left: 4px; }
/* ── NAVBAR USER ── */
.navbar-user { display: flex; align-items: center; gap: 12px; }
.navbar-user .username { font-size: 13px; color: var(--text-dim); font-weight: 500; }
.btn-logout {
  padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); color: var(--text-dim); text-decoration: none;
  transition: all 0.2s; background: transparent;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }
/* ── NAVBAR NAV ACTIVE ── */
.navbar-nav a { padding: 6px 12px; border-radius: 6px; font-size: 13px; color: var(--text-dim); text-decoration: none; transition: all 0.15s; }
.navbar-nav a:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.navbar-nav a.active { color: var(--gold); font-weight: 600; }
/* ── CB GROUP (checkbox) ── */
.cb-group { display: flex; flex-wrap: wrap; gap: 8px; }
.cb-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); cursor: pointer; padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; transition: all 0.15s; }
.cb-item:hover { border-color: var(--gold); color: var(--text); }
.cb-item input[type="checkbox"] { accent-color: var(--gold); }
