/* ============================================================
   CRM DuongEdu — giao diện web app hiện đại
   Nhận diện: xanh ngọc #2DBDB6, cam nhấn #F5A623, tối giản nhiều khoảng trắng
   ============================================================ */
:root {
  --brand: #2DBDB6;
  --brand-dark: #1FA39C;
  --brand-darker: #157F79;
  --brand-050: #EAF9F8;
  --brand-100: #D3F1EF;
  --brand-200: #B7E7E4;
  --accent: #F5A623;
  --accent-soft: #FEF4E2;
  --accent-ink: #B45309;

  --chart: #0A9B92;
  --chart-accent: #C2410C;

  --canvas: #F3F6F7;
  --surface: #FFFFFF;
  --surface-2: #F8FAFB;

  --ink: #131B24;
  --ink-2: #56636F;
  --ink-3: #93A0AC;
  --line: #E7ECEE;
  --line-soft: #F0F4F5;
  --danger: #DC2626;
  --danger-soft: #FDECEC;
  --success: #16A34A;

  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(19, 27, 36, .06);
  --shadow: 0 2px 10px rgba(19, 27, 36, .05), 0 1px 3px rgba(19, 27, 36, .04);
  --shadow-md: 0 8px 24px rgba(19, 27, 36, .09);
  --shadow-lg: 0 18px 48px rgba(19, 27, 36, .16);
  --ring: 0 0 0 3.5px rgba(45, 189, 182, .18);
  --font: 'Montserrat', 'Segoe UI', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--canvas); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }
a { color: var(--brand-darker); text-decoration: none; }
::selection { background: var(--brand-100); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D5DDE0; border-radius: 20px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #BCC6CB; background-clip: content-box; }

/* ---------- login ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 15% -10%, #DFF6F4 0%, transparent 55%), radial-gradient(900px 500px at 100% 110%, #FCEBD2 0%, transparent 50%), var(--canvas); }
.login-card { background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg); padding: 46px 44px; width: 400px; max-width: 92vw; border: 1px solid var(--line); }
.login-logo { font-size: 32px; font-weight: 800; letter-spacing: -.6px; text-align: center; }
.login-logo span, .brand span { color: var(--brand); }
.login-sub { text-align: center; color: var(--ink-2); margin: 8px 0 32px; font-size: 14px; }
.login-card label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 18px; color: var(--ink-2); }
.login-card input { display: block; width: 100%; margin-top: 7px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 11px; background: var(--surface-2); transition: border-color .15s, box-shadow .15s, background .15s; }
.login-card input:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: var(--ring); }

/* ---------- app shell ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { font-size: 22px; font-weight: 800; padding: 24px 22px 20px; letter-spacing: -.5px; display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-darker) 100%); box-shadow: 0 4px 12px rgba(45, 189, 182, .35); color: #fff; font-size: 18px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
#nav { display: flex; flex-direction: column; gap: 3px; padding: 6px 12px; }
#nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px; color: var(--ink-2); font-weight: 600; font-size: 13.5px; position: relative; transition: background .14s, color .14s; }
#nav a:hover { background: var(--surface-2); color: var(--ink); }
#nav a.active { background: var(--brand-050); color: var(--brand-darker); }
#nav a.active::before { content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%); width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--brand); }
.nav-ico { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; border-radius: 8px; background: var(--surface-2); flex-shrink: 0; }
#nav a.active .nav-ico { background: #fff; }
.badge { background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; margin-left: auto; font-weight: 700; box-shadow: 0 2px 6px rgba(245, 166, 35, .4); }
.sidebar-footer { margin-top: auto; padding: 14px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.user-chip { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-chip::before { content: attr(data-initial); width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-darker) 100%); color: #fff; font-size: 15px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-chip small { display: block; color: var(--ink-3); font-weight: 500; font-size: 11.5px; }
.view { flex: 1; padding: 30px 34px; max-width: 1560px; min-width: 0; }

/* ---------- generic ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.page-sub { color: var(--ink-2); margin-top: 4px; font-size: 13.5px; }
.btn { border: none; border-radius: 11px; padding: 10px 17px; font-weight: 700; font-size: 13.5px; display: inline-flex; align-items: center; gap: 7px; transition: transform .06s, box-shadow .15s, background .15s, border-color .15s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(45, 189, 182, .32); }
.btn-primary:hover { background: var(--brand-dark); box-shadow: 0 5px 16px rgba(45, 189, 182, .4); }
.btn-secondary { background: var(--brand-050); color: var(--brand-darker); }
.btn-secondary:hover { background: var(--brand-100); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border: 1.5px solid var(--line); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--brand-200); color: var(--ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #FBDBDB; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; justify-content: center; padding: 13px; font-size: 14.5px; }
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 22px; border: 1px solid var(--line); }
.form-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; background: var(--danger-soft); padding: 9px 12px; border-radius: 9px; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.filters input[type=text], .filters select, .filters input[type=date] {
  padding: 10px 13px; border: 1.5px solid var(--line); border-radius: 11px; background: var(--surface); transition: border-color .15s, box-shadow .15s; box-shadow: var(--shadow-sm); }
.filters input[type=text] { min-width: 260px; }
.filters input[type=text]::placeholder { color: var(--ink-3); }
.filters :focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }

/* ---------- table ---------- */
.table-wrap { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow-x: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3); font-weight: 700; padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--brand-050); cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }
.stage-pill { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 12.5px; white-space: nowrap; background: var(--surface-2); border: 1px solid var(--line); padding: 4px 10px; border-radius: 99px; }
.stage-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tag { display: inline-block; background: var(--brand-050); border: 1px solid var(--brand-100); border-radius: 6px; padding: 1px 8px; font-size: 11px; margin: 2px 3px 0 0; color: var(--brand-darker); font-weight: 600; }
.money { font-variant-numeric: tabular-nums; font-weight: 700; }
.muted { color: var(--ink-3); }
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; padding: 14px 12px; color: var(--ink-2); font-size: 13px; }

/* ---------- bulk action bar ---------- */
.bulk-bar { display: flex; align-items: center; gap: 14px; background: linear-gradient(90deg, var(--brand-050), var(--brand-100)); border: 1px solid var(--brand-200); border-radius: 13px; padding: 12px 18px; margin-bottom: 16px; flex-wrap: wrap; box-shadow: var(--shadow-sm); animation: slideDown .18s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.bulk-bar #bulk-count { font-weight: 800; color: var(--brand-darker); }
.bulk-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.bulk-actions select { padding: 8px 12px; border: 1.5px solid var(--brand-200); border-radius: 9px; background: var(--surface); font-size: 13px; font-weight: 600; }
.check-cell { text-align: center; }
.row-check, #check-all { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }

/* ---------- dashboard ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 18px; margin-bottom: 22px; }
.stat-tile { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px 22px; border: 1px solid var(--line); display: flex; align-items: center; gap: 16px; position: relative; overflow: hidden; }
.stat-tile::after { content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: var(--brand-050); opacity: .6; }
.stat-ico { width: 48px; height: 48px; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; background: var(--brand-050); z-index: 1; }
.stat-tile.t-accent .stat-ico { background: var(--accent-soft); }
.stat-tile.t-accent::after { background: var(--accent-soft); }
.stat-body { z-index: 1; min-width: 0; }
.stat-label { font-size: 11.5px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .4px; }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 3px; letter-spacing: -.6px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-value.accent { color: var(--accent-ink); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }
.chart-card h3 { font-size: 14.5px; font-weight: 800; margin-bottom: 18px; letter-spacing: -.2px; }
.hbar-row { display: grid; grid-template-columns: minmax(120px, 175px) 1fr 92px; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 13px; }
.hbar-label { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 22px; display: flex; align-items: center; background: var(--surface-2); border-radius: 7px; overflow: hidden; }
.hbar-fill { height: 22px; background: linear-gradient(90deg, var(--brand) 0%, var(--brand-dark) 100%); border-radius: 7px; min-width: 3px; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.hbar-value { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.empty-note { color: var(--ink-3); padding: 22px 0; text-align: center; }

/* ---------- pipeline (kanban) ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); min-width: 252px; width: 252px; flex-shrink: 0; padding: 12px; }
.kanban-col.drag-over { outline: 2px dashed var(--brand); outline-offset: -3px; background: var(--brand-050); }
.kanban-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 12px; font-weight: 800; font-size: 13px; }
.kanban-count { margin-left: auto; color: var(--ink-3); font-weight: 700; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 0 9px; font-size: 12px; }
.kanban-cards { display: flex; flex-direction: column; gap: 9px; min-height: 30px; max-height: calc(100vh - 250px); overflow-y: auto; padding: 2px; }
.kcard { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-sm); padding: 12px 13px; cursor: grab; border: 1px solid var(--line); transition: box-shadow .14s, border-color .14s, transform .06s; }
.kcard:hover { border-color: var(--brand-200); box-shadow: var(--shadow-md); }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .5; transform: rotate(1.5deg); }
.kcard-name { font-weight: 700; font-size: 13px; }
.kcard-meta { color: var(--ink-3); font-size: 11.5px; margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; }
.kcard-rev { color: var(--brand-darker); font-weight: 700; }

/* ---------- drawer ---------- */
.drawer-backdrop, .modal-backdrop { position: fixed; inset: 0; background: rgba(19, 27, 36, .42); z-index: 40; backdrop-filter: blur(2px); animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 580px; max-width: 96vw; background: var(--surface); z-index: 50; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slideIn .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes slideIn { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 22px 26px 0; border-bottom: 1px solid var(--line); }
.drawer-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.drawer-name { font-size: 21px; font-weight: 800; letter-spacing: -.4px; }
.drawer-sub { color: var(--ink-2); font-size: 13px; margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.drawer-close { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; width: 32px; height: 32px; font-size: 17px; color: var(--ink-2); line-height: 1; transition: background .14s; }
.drawer-close:hover { background: var(--danger-soft); color: var(--danger); }
.tabs { display: flex; gap: 4px; margin-top: 18px; }
.tabs button { background: none; border: none; padding: 11px 14px; font-weight: 700; font-size: 13px; color: var(--ink-2); border-bottom: 2.5px solid transparent; transition: color .14s, border-color .14s; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--brand-darker); border-bottom-color: var(--brand); }
.drawer-body { padding: 22px 26px; overflow-y: auto; flex: 1; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 13px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface-2); transition: border-color .15s, box-shadow .15s, background .15s; }
.field :focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: var(--ring); }
.field textarea { resize: vertical; min-height: 74px; }
.drawer-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 18px; margin-top: 4px; border-top: 1px solid var(--line-soft); }

/* timeline */
.timeline-item { display: flex; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.timeline-item:last-child { border-bottom: none; }
.timeline-ico { width: 36px; height: 36px; border-radius: 11px; background: var(--brand-050); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 15px; }
.timeline-content { flex: 1; font-size: 13.5px; }
.timeline-meta { color: var(--ink-3); font-size: 11.5px; margin-top: 3px; }
.quick-add { display: flex; gap: 8px; margin-bottom: 16px; }
.quick-add select, .quick-add input { padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface-2); transition: border-color .15s, box-shadow .15s; }
.quick-add input { flex: 1; }
.quick-add :focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: var(--ring); }

/* purchases */
.purchase-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; gap: 8px; }

/* reminders */
.reminder-item { display: flex; align-items: center; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.reminder-item:last-child { border-bottom: none; }
.reminder-item input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); flex-shrink: 0; }
.reminder-late { color: var(--danger); font-weight: 700; }

/* ---------- modal ---------- */
.modal-backdrop { display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); width: 540px; max-width: 94vw; max-height: 90vh; overflow-y: auto; padding: 28px 30px; z-index: 60; animation: pop .2s cubic-bezier(.2, .8, .2, 1); border: 1px solid var(--line); }
@keyframes pop { from { transform: scale(.96); opacity: .5; } to { transform: none; opacity: 1; } }
.modal h2 { font-size: 18px; font-weight: 800; margin-bottom: 20px; letter-spacing: -.3px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 13px 22px; border-radius: 12px; font-weight: 600; font-size: 13.5px; z-index: 100; box-shadow: var(--shadow-lg); animation: toastUp .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes toastUp { from { transform: translate(-50%, 12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.toast.error { background: var(--danger); }

/* ---------- settings ---------- */
.settings-section { margin-bottom: 30px; }
.settings-section h3 { font-size: 16px; font-weight: 800; margin-bottom: 14px; letter-spacing: -.2px; }
.role-pill { display: inline-block; border-radius: 7px; padding: 3px 10px; font-size: 11.5px; font-weight: 700; }
.role-admin { background: var(--accent-soft); color: var(--accent-ink); }
.role-manager { background: #EAF2FD; color: #1D4ED8; }
.role-sale { background: var(--brand-050); color: var(--brand-darker); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: sticky; top: 0; z-index: 30; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 0 8px; }
  .brand { padding: 14px 12px; font-size: 19px; }
  .brand::after { top: 17px; left: 34px; }
  #nav { flex-direction: row; flex-wrap: wrap; padding: 8px; gap: 4px; }
  #nav a { padding: 8px 10px; font-size: 12.5px; }
  #nav a.active::before { display: none; }
  .sidebar-footer { margin: 0 0 0 auto; border: none; padding: 8px 12px; }
  .user-chip small { display: none; }
  .view { padding: 18px 16px; }
  .field-grid { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
}
