/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #5000F9;
  --primary-dark: #3D00C1;
  --primary-light: #7B3FFF;
  --primary-subtle: rgba(80, 0, 249, 0.06);
  --primary-glow: rgba(80, 0, 249, 0.12);
  --navy: #11175D;
  --navy-light: #1A2070;
  --navy-dark: #0C1045;
  --bg: #F7F8FC;
  --bg-white: #FFFFFF;
  --text: #11175D;
  --text-secondary: #5A5F8C;
  --text-muted: #8E92B5;
  --border: #E8EAF2;
  --border-light: #F0F1F7;
  --danger: #E5384F;
  --danger-bg: #FFF0F2;
  --success: #00B67A;
  --success-bg: #EDFCF6;
  --warning: #F5A623;
  --warning-bg: #FFF8EC;
  --info: #3B82F6;
  --info-bg: #EFF6FF;
  --shadow-sm: 0 1px 3px rgba(17, 23, 93, 0.04);
  --shadow: 0 2px 12px rgba(17, 23, 93, 0.06);
  --shadow-md: 0 4px 24px rgba(17, 23, 93, 0.08);
  --shadow-lg: 0 12px 48px rgba(17, 23, 93, 0.12);
  --radius: 10px;
  --radius-lg: 16px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --nav-height: 56px;
  --sidebar-width: 0px;
  --bottom-nav-height: 68px;
}

@media (min-width: 640px) {
  :root { --nav-height: 60px; }
}
@media (min-width: 1024px) {
  :root {
    --nav-height: 64px;
    --sidebar-width: 220px;
    --bottom-nav-height: 0px;
  }
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-weight: 400;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Login ===== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--navy-dark);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(80, 0, 249, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(80, 0, 249, 0.08) 0%, transparent 50%);
  padding: 16px;
}

.login-container {
  width: 100%;
  max-width: 440px;
}

.login-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 36px 24px 28px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.24), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

@media (min-width: 640px) {
  .login-card { padding: 56px 48px 40px; }
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

@media (min-width: 640px) {
  .login-logo { margin-bottom: 40px; }
}

.login-logo-img {
  height: 48px;
  width: auto;
  object-fit: contain;
  margin-bottom: 12px;
}

@media (min-width: 640px) {
  .login-logo-img { height: 56px; }
}

.login-logo p {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.login-footer {
  text-align: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

.login-footer span {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: var(--bg-white);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238E92B5' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
  font-weight: 300;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0;
}

@media (min-width: 640px) {
  .form-row {
    flex-direction: row;
    gap: 16px;
  }
}

.form-row .form-group { flex: 1; }

@media (min-width: 640px) {
  .form-row .form-group-sm { flex: 0 0 180px; }
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--danger-bg);
  border-radius: var(--radius);
  border: 1px solid rgba(229, 56, 79, 0.12);
  font-weight: 500;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.01em;
  min-height: 48px;
  touch-action: manipulation;
  user-select: none;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(80, 0, 249, 0.24);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 16px rgba(80, 0, 249, 0.32);
}

@media (hover: hover) {
  .btn-primary:hover { transform: translateY(-1px); }
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(80, 0, 249, 0.2);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(229, 56, 79, 0.2);
}

.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 8px 16px; font-size: 0.8rem; min-height: 40px; }
.btn-full { width: 100%; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-muted);
  padding: 8px 10px;
  border-radius: 8px;
  line-height: 1;
  transition: all var(--transition);
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.btn-icon:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ===== Top Nav ===== */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 640px) {
  .top-nav { padding: 0 24px; }
}

@media (min-width: 1024px) {
  .top-nav { padding: 0 28px; }
}

.nav-left {
  display: flex;
  align-items: center;
}

.nav-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
}

@media (min-width: 640px) {
  .nav-logo { height: 32px; }
}

@media (min-width: 1024px) {
  .nav-logo { height: 36px; }
}

.nav-brand {
  font-size: 1.15rem;
  color: var(--navy);
  letter-spacing: 0.12em;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-center {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: center;
  padding: 0 12px;
  min-width: 0;
}

.tenant-select {
  padding: 10px 40px 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238E92B5' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  width: 100%;
  max-width: 280px;
  min-height: 44px;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.tenant-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: none;
}

@media (min-width: 640px) {
  .user-name { display: inline; }
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  bottom: 0;
  width: 260px;
  background: var(--navy);
  padding: 20px 0;
  z-index: 110;
  box-shadow: 2px 0 12px rgba(17, 23, 93, 0.08);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
}

@media (min-width: 1024px) {
  .sidebar {
    display: block;
    width: var(--sidebar-width);
    transform: translateX(0);
  }
}

.sidebar.open {
  display: block;
  transform: translateX(0);
}

/* Sidebar overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(17, 23, 93, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 105;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  margin: 2px 0;
  min-height: 48px;
  touch-action: manipulation;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.85);
}

.nav-link.active {
  color: #FFFFFF;
  background: rgba(80, 0, 249, 0.25);
  border-left-color: var(--primary-light);
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-label { white-space: nowrap; }

/* ===== Mobile Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 12px rgba(17, 23, 93, 0.06);
}

@media (min-width: 1024px) {
  .bottom-nav { display: none; }
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--text-muted);
  padding: 8px 16px;
  min-width: 64px;
  min-height: 48px;
  border-radius: 12px;
  transition: all var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item.active .bottom-nav-icon {
  background: var(--primary-subtle);
  border-radius: 16px;
  padding: 2px 12px;
}

.bottom-nav-icon {
  width: 24px;
  height: 24px;
  transition: all var(--transition);
}

.bottom-nav-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--nav-height);
  padding: 16px;
  padding-bottom: calc(16px + var(--bottom-nav-height));
  min-height: calc(100vh - var(--nav-height));
  min-height: calc(100dvh - var(--nav-height));
}

@media (min-width: 640px) {
  .main-content {
    padding: 24px;
    padding-bottom: calc(24px + var(--bottom-nav-height));
  }
}

@media (min-width: 1024px) {
  .main-content {
    padding: 32px;
    padding-bottom: 32px;
  }
}

/* ===== Create Task Panel ===== */
.create-task-panel {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

@media (min-width: 640px) {
  .create-task-panel {
    padding: 28px;
    margin-bottom: 28px;
  }
}

.create-task-panel h2 {
  font-size: 0.9rem;
  margin-bottom: 16px;
  color: var(--navy);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

@media (min-width: 640px) {
  .create-task-panel h2 {
    font-size: 1rem;
    margin-bottom: 20px;
  }
}

.task-form { display: flex; flex-direction: column; gap: 8px; }
.task-form .btn { align-self: stretch; }

@media (min-width: 640px) {
  .task-form .btn { align-self: flex-start; }
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-low { background: var(--success-bg); color: var(--success); }
.badge-medium { background: var(--warning-bg); color: #D4891A; }
.badge-high { background: #FFF0F2; color: var(--danger); }
.badge-critical { background: var(--danger); color: #FFFFFF; box-shadow: 0 2px 6px rgba(229, 56, 79, 0.25); }

.badge-status-nueva { background: var(--info-bg); color: var(--info); }
.badge-status-en_curso { background: var(--warning-bg); color: #D4891A; }
.badge-status-completada { background: var(--success-bg); color: var(--success); }
.badge-status-cancelada { background: var(--danger-bg); color: var(--danger); }
.badge-status-stand_by { background: var(--primary-subtle); color: var(--primary); }

.badge-internal {
  background: var(--navy);
  color: #FFFFFF;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
}

.badge-visible {
  background: var(--success-bg);
  color: var(--success);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
}

/* ===== Custom Checkbox ===== */
.form-check {
  margin-bottom: 20px;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  min-height: 44px;
  user-select: none;
  touch-action: manipulation;
}

.check-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.check-mark {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.check-label input[type="checkbox"]:checked + .check-mark {
  background: var(--primary);
  border-color: var(--primary);
}

.check-label input[type="checkbox"]:checked + .check-mark::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid #FFFFFF;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}

.check-label input[type="checkbox"]:focus-visible + .check-mark {
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.task-visibility-toggle {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

/* ===== Internal task indicator on kanban card ===== */
.card-internal-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--navy);
  background: rgba(17, 23, 93, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ===== Section headers ===== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
}

@media (min-width: 640px) {
  .section-header { margin-bottom: 24px; }
}

.section-header h2 {
  font-size: 1rem;
  color: var(--navy);
  font-weight: 700;
  letter-spacing: 0.02em;
}

@media (min-width: 640px) {
  .section-header h2 { font-size: 1.1rem; }
}

/* ===== Data List (admin panels) ===== */
.data-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg-white);
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all var(--transition);
}

@media (min-width: 640px) {
  .data-card {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    gap: 16px;
  }
}

.data-card-info { min-width: 0; }

.data-card-info strong {
  display: block;
  margin-bottom: 4px;
  color: var(--navy);
  font-weight: 600;
  word-break: break-word;
}

.data-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-word;
}

.data-card-actions {
  display: flex;
  gap: 8px;
}

.data-card-actions .btn {
  flex: 1;
}

@media (min-width: 640px) {
  .data-card-actions .btn { flex: none; }
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 0.95rem;
  font-weight: 400;
}

@media (min-width: 640px) {
  .empty-state { padding: 48px; }
}

/* ===== Modals ===== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(17, 23, 93, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}

@media (min-width: 640px) {
  .modal { align-items: center; }
}

.modal-content {
  background: var(--bg-white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px;
  width: 100%;
  max-width: 100%;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}

@media (min-width: 640px) {
  .modal-content {
    border-radius: var(--radius-lg);
    max-width: 500px;
    padding: 36px;
    max-height: 90vh;
  }
}

.modal-large { max-width: 100%; }

@media (min-width: 640px) {
  .modal-large { max-width: 680px; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

@media (min-width: 640px) {
  .modal-header { margin-bottom: 24px; }
}

.modal-header h3 {
  font-size: 1rem;
  color: var(--navy);
  font-weight: 700;
  min-width: 0;
  word-break: break-word;
}

@media (min-width: 640px) {
  .modal-header h3 { font-size: 1.1rem; }
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all var(--transition);
  flex-shrink: 0;
  touch-action: manipulation;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

/* ===== Task Detail ===== */
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

@media (min-width: 640px) {
  .task-meta { gap: 10px; margin-bottom: 20px; }
}

.task-meta-info {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.task-description {
  color: var(--text);
  margin-bottom: 24px;
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius);
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.7;
  border: 1px solid var(--border-light);
  word-break: break-word;
}

@media (min-width: 640px) {
  .task-description {
    padding: 16px;
    margin-bottom: 28px;
    font-size: 0.925rem;
  }
}

/* ===== Notes / Threads ===== */
.notes-section h4 {
  font-size: 0.85rem;
  color: var(--navy);
  margin-bottom: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

@media (min-width: 640px) {
  .notes-section h4 {
    font-size: 0.95rem;
    margin-bottom: 16px;
  }
}

.new-note-form {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

@media (min-width: 640px) {
  .new-note-form {
    margin-bottom: 24px;
    padding: 20px;
  }
}

.new-note-form .form-group { margin-bottom: 12px; }

.new-note-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  min-height: 48px;
}

.new-note-form input:focus,
.new-note-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.note-form-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 640px) {
  .note-form-row {
    flex-direction: row;
    align-items: flex-end;
  }
}

.note-form-row textarea {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  resize: vertical;
  color: var(--text);
  min-height: 48px;
}

.note-form-row .btn {
  width: 100%;
}

@media (min-width: 640px) {
  .note-form-row .btn { width: auto; }
}

.notes-list { display: flex; flex-direction: column; gap: 10px; }

.notes-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  font-size: 0.85rem;
}

/* Thread card */
.note-thread {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
}

.note-thread.thread-open {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.note-thread-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  transition: background var(--transition);
  min-height: 56px;
  touch-action: manipulation;
  gap: 8px;
}

.note-thread-header:hover {
  background: var(--bg);
}

.note-thread-info {
  flex: 1;
  min-width: 0;
}

.note-thread-title {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 3px;
  word-break: break-word;
}

.note-thread-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

@media (min-width: 640px) {
  .note-thread-meta { font-size: 0.75rem; }
}

.note-thread-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.thread-toggle {
  font-size: 1rem;
  color: var(--text-muted);
  user-select: none;
  transition: color var(--transition);
  padding: 4px;
}

/* Thread body (expanded) */
.note-thread-body {
  border-top: 1px solid var(--border-light);
  padding: 14px;
  background: var(--bg);
}

@media (min-width: 640px) {
  .note-thread-body { padding: 18px; }
}

.thread-message {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  border-left: 3px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.thread-message-original {
  border-left-color: var(--primary);
}

.message-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.message-author {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.author-admin { color: var(--primary); }

.message-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.message-content {
  font-size: 0.88rem;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.6;
  word-break: break-word;
}

.thread-replies { margin-bottom: 8px; }

.loading-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
}

/* Reply form */
.reply-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

@media (min-width: 640px) {
  .reply-form {
    flex-direction: row;
    align-items: flex-end;
  }
}

.reply-input {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  resize: vertical;
  color: var(--text);
  min-height: 48px;
}

.reply-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.reply-form .btn {
  width: 100%;
}

@media (min-width: 640px) {
  .reply-form .btn { width: auto; }
}

.btn-delete-note,
.btn-delete-reply {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  transition: all var(--transition);
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.btn-delete-note:hover,
.btn-delete-reply:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

/* ===== Utility: safe area padding ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .main-content {
    padding-bottom: calc(16px + var(--bottom-nav-height) + env(safe-area-inset-bottom));
  }
  @media (min-width: 640px) {
    .main-content {
      padding-bottom: calc(24px + var(--bottom-nav-height) + env(safe-area-inset-bottom));
    }
  }
  @media (min-width: 1024px) {
    .main-content { padding-bottom: 32px; }
  }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
