:root {
  --pine: #2F4538;
  --pine-dark: #1E2E25;
  --sand: #EDE6D6;
  --sand-light: #F6F2E9;
  --ink: #23261F;
  --ink-soft: #5B5D52;
  --brass: #B98B3E;
  --brass-light: #E7C889;
  --rust: #A6512F;
  --line: #DCD3BE;
  --white: #FFFFFF;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(30, 46, 37, 0.08);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Work Sans', -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--sand-light);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Icons ---------- */
.icon { width: 20px; height: 20px; flex-shrink: 0; display: block; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }
.brand-mark .icon { width: 26px; height: 26px; }

/* ---------- Auth screen ---------- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--pine) 0%, var(--pine-dark) 100%);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: 16px;
  padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  text-align: center;
}
.auth-mark { display: flex; justify-content: center; color: var(--pine); margin-bottom: 8px; }
.auth-mark .icon { width: 34px; height: 34px; }
.auth-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--pine-dark);
}
.auth-sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 28px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; text-align: left; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  font-family: var(--font-body);
  font-size: 15px;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--sand-light);
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--pine); background: var(--white); }

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform .1s, background .15s, opacity .15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--pine); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--pine-dark); }
.btn-secondary { background: var(--sand); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { background: var(--line); }
.btn-danger { background: var(--rust); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #8A3F23; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.inline-error {
  background: #F8E4DB;
  color: var(--rust);
  border: 1px solid #EBC1AC;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
}
.inline-ok {
  background: #E4EBDF;
  color: var(--pine-dark);
  border: 1px solid #C7D6BE;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
}

/* ---------- Portal shell ---------- */
.portal { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--pine-dark);
  color: var(--sand-light);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.sidebar-brand { font-family: var(--font-display); font-size: 20px; font-weight: 600; padding: 0 10px 22px; display: flex; align-items: center; gap: 10px; }
.sidebar-brand.brand-mark .icon { color: var(--brass); }
.sidebar-brand small { display: block; font-family: var(--font-body); font-size: 11px; font-weight: 500; color: #A9B7A3; text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #D9E0D2;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active { background: var(--brass); color: var(--pine-dark); font-weight: 700; }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-user { font-size: 13px; color: #C8D2C1; margin-bottom: 10px; }
.sidebar-user b { display: block; color: var(--white); font-size: 14px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  padding: 18px 28px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-family: var(--font-display); font-size: 22px; margin: 0; color: var(--pine-dark); }
.topbar .sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.content { padding: 24px 28px; flex: 1; overflow-y: auto; }

/* ---------- Kanban ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.column {
  min-width: 250px;
  max-width: 250px;
  background: var(--sand);
  border-radius: var(--radius);
  padding: 12px;
  flex-shrink: 0;
}
.column-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; padding: 0 4px; }
.column-title { font-size: 13px; font-weight: 700; color: var(--pine-dark); text-transform: uppercase; letter-spacing: .03em; }
.column-count { font-size: 12px; background: var(--white); color: var(--ink-soft); padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.lead-card {
  background: var(--white);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .1s, border-color .15s;
}
.lead-card:hover { border-color: var(--brass); }
.lead-card:active { transform: scale(0.98); }
.lead-card .name { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.lead-card .meta { font-size: 12px; color: var(--ink-soft); }
.lead-card .tag { display: inline-block; margin-top: 6px; font-size: 11px; background: var(--sand); padding: 2px 8px; border-radius: 20px; color: var(--pine-dark); font-weight: 600; }
.column-empty { font-size: 12px; color: var(--ink-soft); text-align: center; padding: 16px 4px; }

/* ---------- Drawer ---------- */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(30,46,37,0.35);
  display: flex; justify-content: flex-end; z-index: 50;
}
.drawer {
  width: 420px; max-width: 100%; height: 100%;
  background: var(--white); box-shadow: -8px 0 30px rgba(0,0,0,0.15);
  overflow-y: auto; padding: 24px;
}
.drawer-close { float: right; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-soft); }
.drawer h2 { font-family: var(--font-display); font-size: 21px; margin: 0 0 2px; color: var(--pine-dark); }
.drawer .drawer-meta { font-size: 13px; color: var(--ink-soft); margin-bottom: 18px; }
.drawer-section { margin-bottom: 22px; }
.drawer-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--brass); margin: 0 0 10px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.activity-item { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.activity-item .a-type { font-weight: 700; color: var(--pine-dark); text-transform: capitalize; }
.activity-item .a-when { color: var(--ink-soft); font-size: 11px; }

/* ---------- Table (Teachers view) ---------- */
table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 12px 14px; font-size: 13px; border-bottom: 1px solid var(--line); }
th { background: var(--sand); color: var(--pine-dark); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
.lead-row:hover td { background: var(--sand-light); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.pill-on { background: #E4EBDF; color: var(--pine-dark); }
.pill-off { background: #F8E4DB; color: var(--rust); }

.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="text"] { padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 13px; min-width: 220px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(30,46,37,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
  overflow-y: auto;
}
.modal { background: var(--white); border-radius: 14px; padding: 26px; max-width: 440px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,0.3); max-height: 88vh; overflow-y: auto; margin: auto; }
.modal-wide { max-width: 600px; }
.modal h3 { font-family: var(--font-display); margin: 0 0 8px; color: var(--pine-dark); }
.modal p { font-size: 14px; color: var(--ink-soft); margin: 0 0 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.whatsapp-box {
  background: var(--sand-light); border: 1px dashed var(--line); border-radius: 8px;
  padding: 12px; font-size: 13px; white-space: pre-wrap; margin-bottom: 10px;
}

@media (max-width: 720px) {
  .sidebar { position: fixed; bottom: 0; left: 0; right: 0; width: 100%; flex-direction: row; justify-content: space-around; padding: 6px; z-index: 40; }
  .sidebar-brand, .sidebar-footer { display: none; }
  .nav-item {
    flex-direction: column; font-size: 10.5px; padding: 8px 4px; gap: 4px;
    flex: 1; align-items: center; text-align: center; border-radius: 10px;
    -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  }
  .nav-item .icon { margin: 0 auto; }
  .main { padding-bottom: 76px; }
  .content { padding: 16px; }
  .drawer { width: 100%; }

  /* Client portal specifically: a light, native-feeling tab bar rather than
     the dark ops-tool sidebar — closer to what a consumer app (the kind
     clients are used to) actually looks like on a phone. */
  .client-app .sidebar {
    background: var(--white);
    box-shadow: 0 -2px 12px rgba(30,46,37,0.08);
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
  .client-app .nav-item { color: var(--ink-soft); font-weight: 600; }
  .client-app .nav-item.active { background: transparent; color: var(--pine); }
  .client-app .nav-item.active .icon { color: var(--pine); }
  .client-app .main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .client-app .topbar {
    position: sticky; top: 0; z-index: 30;
    padding-top: max(18px, env(safe-area-inset-top));
  }
}
