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

:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --border: #e2e2e0;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --david: #2563eb;
  --michael: #7c3aed;
  --high: #dc2626;
  --medium: #d97706;
  --low: #16a34a;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.shell { max-width: 960px; margin: 0 auto; padding: 0 16px 64px; }

/* TOP BAR */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.top-bar h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.date-label { font-size: 13px; color: var(--muted); }

/* NAV */
.section-nav {
  display: flex;
  gap: 4px;
  padding: 8px 0 20px;
  flex-wrap: wrap;
}
.section-nav a {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: background 0.1s;
}
.section-nav a:hover { background: var(--bg); color: var(--text); }

/* CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h2 { font-size: 15px; font-weight: 700; }
.target-label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* BUTTONS */
.btn-add {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  border: none;
  background: var(--text);
  color: #fff;
  cursor: pointer;
}
.btn-add:hover { opacity: 0.85; }

.btn-save {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  background: var(--text);
  color: #fff;
  cursor: pointer;
}
.btn-save:hover { opacity: 0.85; }

.btn-ghost {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* PRIORITIES */
.priority-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 600px) { .priority-grid { grid-template-columns: 1fr; } }

.client-label {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.client-label.david { color: var(--david); }
.client-label.michael { color: var(--michael); }

.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge-primary { background: #dbeafe; color: var(--david); }
.badge-secondary { background: #ede9fe; color: var(--michael); }

/* TASK LIST */
.task-list { list-style: none; display: flex; flex-direction: column; gap: 6px; min-height: 40px; }

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.task-item input[type="checkbox"] { margin-top: 2px; cursor: pointer; flex-shrink: 0; }
.task-item-text { flex: 1; font-size: 13px; }
.task-item-text.done { text-decoration: line-through; color: var(--muted); }
.task-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.task-item-actions button {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--muted);
}
.task-item-actions button:hover { color: var(--text); }
.task-item-actions .del-btn:hover { color: var(--high); }

.empty-msg { font-size: 12px; color: var(--muted); padding: 8px 0; font-style: italic; }

/* MICHAEL TASKS TABLE */
.task-group { margin-bottom: 20px; }
.group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.task-table th {
  text-align: left;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.task-table td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.task-table tr:last-child td { border-bottom: none; }
.task-table tr:hover td { background: var(--bg); }
.task-table td:nth-child(4) { color: var(--muted); font-size: 12px; max-width: 200px; }

.priority-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
}
.priority-pill.High { background: #fee2e2; color: var(--high); }
.priority-pill.Medium { background: #fef3c7; color: var(--medium); }
.priority-pill.Low { background: #dcfce7; color: var(--low); }

.status-select {
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
}

.td-day { white-space: nowrap; font-size: 12px; }
.td-hrs { white-space: nowrap; }
.td-notes { color: var(--muted); font-size: 12px; max-width: 180px; }
.hrs-badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 3px; background: #e0e7ff; color: #3730a3; }
.no-val { color: var(--border); }

.table-actions button {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--muted);
  margin-right: 2px;
  font-family: inherit;
}
.table-actions button:hover { color: var(--text); }
.table-actions .del-btn:hover { color: var(--high); }

.empty-row td { color: var(--muted); font-style: italic; padding: 12px 8px; }

/* TIME TRACKING */
.time-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.time-chip { display: flex; flex-direction: column; align-items: center; white-space: nowrap; flex-shrink: 0; }
.time-chip-val { font-size: 18px; font-weight: 700; line-height: 1.1; }
.time-chip-val.over { color: var(--high); }
.time-chip-val.good { color: var(--low); }
.time-chip-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.time-bar-bg { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.time-bar-fill { height: 100%; background: var(--text); border-radius: 4px; transition: width 0.3s; width: 0%; }
.time-bar-fill.over { background: var(--high); }
.time-bar-pct { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; flex-shrink: 0; }

#hours-left { font-size: 18px; font-weight: 700; line-height: 1.1; }
#hours-left.over { color: var(--high); }
#hours-left.good { color: var(--low); }

.time-log-form {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.time-log-form input[type="text"] { flex: 1; min-width: 160px; }
.time-log-form input[type="number"] { width: 72px; }
.time-log-form input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  font-family: inherit;
}
.time-log-form input:focus { outline: 2px solid var(--text); outline-offset: 1px; }

.log-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  font-size: 13px;
}
.log-item-left { display: flex; align-items: center; gap: 8px; flex: 1; }
.log-item-hrs { font-weight: 700; color: var(--text); white-space: nowrap; background: var(--border); padding: 1px 6px; border-radius: 3px; font-size: 12px; }
.log-item-del { font-size: 12px; color: var(--muted); background: none; border: none; cursor: pointer; padding: 0 4px; flex-shrink: 0; }
.log-item-del:hover { color: var(--high); }

/* QUESTIONS */
.q-client-tag { font-size: 11px; font-weight: 600; color: var(--muted); padding: 1px 5px; border-radius: 3px; border: 1px solid var(--border); }
.q-client-tag.david { color: var(--david); border-color: #bfdbfe; background: #eff6ff; }
.q-client-tag.michael { color: var(--michael); border-color: #ddd6fe; background: #f5f3ff; }

/* DONE */
.done-list .task-item { opacity: 0.55; }
.done-list .task-item-text { text-decoration: line-through; color: var(--muted); }

/* MODAL */
.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  padding: 24px;
  min-width: 320px;
  max-width: 460px;
  width: 90vw;
}
.modal::backdrop { background: rgba(0,0,0,0.3); }
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  margin-bottom: 12px;
}
.modal label input,
.modal label select,
.modal label textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
.modal label input:focus,
.modal label select:focus,
.modal label textarea:focus { outline: 2px solid var(--text); outline-offset: 1px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
/* ════════════════════════════════════════
   RESPONSIVE DESIGN - Mobile / Tablet / Desktop
   ════════════════════════════════════════ */

/* MOBILE (< 600px) */
@media (max-width: 599px) {
  .shell { padding: 0 12px 40px; }
  
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 14px 0 10px;
  }
  .top-bar h1 { font-size: 16px; }
  
  .section-nav {
    gap: 4px;
    padding: 6px 0 14px;
  }
  .section-nav a {
    font-size: 12px;
    padding: 3px 8px;
  }
  
  .card {
    padding: 14px;
    margin-bottom: 12px;
    border-radius: 6px;
  }
  
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .card-header h2 { font-size: 14px; }
  
  .btn-add,
  .btn-ghost {
    font-size: 11px;
    padding: 5px 10px;
    width: 100%;
  }
  
  /* Priority Grid */
  .priority-grid { grid-template-columns: 1fr; gap: 12px; }
  
  /* Task List */
  .task-item {
    padding: 6px 8px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .task-item input[type="checkbox"] { margin-top: 0; }
  .task-item-text { font-size: 12px; }
  .task-item-actions button { font-size: 10px; padding: 2px 5px; }
  
  /* Tables - Horizontal Scroll */
  .task-group { margin-bottom: 14px; }
  .task-table {
    font-size: 12px;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: 6px;
  }
  .task-table th,
  .task-table td {
    padding: 5px 6px;
    font-size: 11px;
  }
  .task-table th { font-size: 10px; }
  .status-select { font-size: 11px; padding: 4px 6px; }
  
  /* Time Tracking */
  .time-summary {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }
  .time-chip { gap: 2px; }
  .time-chip-val { font-size: 16px; }
  
  .time-log-form {
    flex-direction: column;
    gap: 6px;
  }
  .time-log-form input[type="text"] { min-width: auto; }
  .time-log-form input[type="number"] { width: 100%; }
  
  #log-hrs { width: 100%; }
  #log-time-btn { width: 100%; }
  
  /* Modal */
  .modal {
    width: 95vw;
    max-width: 100%;
    min-width: 280px;
    padding: 16px;
    border-radius: 10px;
  }
  .modal h3 { font-size: 14px; margin-bottom: 12px; }
  .modal label {
    margin-bottom: 10px;
    font-size: 11px;
  }
  .modal label input,
  .modal label select,
  .modal label textarea {
    padding: 8px 8px;
    font-size: 13px;
  }
  
  .modal-actions {
    flex-direction: column-reverse;
    gap: 6px;
  }
  .modal-actions button { width: 100%; }
  
  /* Clear Done Button */
  #clear-done-btn { width: 100%; }
  
  /* Badges */
  .badge { font-size: 9px; padding: 1px 4px; }
}

/* TABLET (600px - 899px) */
@media (min-width: 600px) and (max-width: 899px) {
  .shell { padding: 0 16px 50px; max-width: 100%; }
  
  .top-bar {
    padding: 16px 0 10px;
  }
  .top-bar h1 { font-size: 17px; }
  
  .section-nav {
    padding: 6px 0 16px;
    gap: 6px;
  }
  .section-nav a { font-size: 12px; }
  
  .card {
    padding: 16px;
    margin-bottom: 14px;
  }
  
  .card-header h2 { font-size: 14px; }
  
  .btn-add {
    font-size: 11px;
    padding: 5px 10px;
  }
  
  /* Priority Grid - Still 2 cols */
  .priority-grid { gap: 16px; }
  
  /* Task List */
  .task-item { padding: 7px 9px; }
  .task-item-text { font-size: 12px; }
  
  /* Tables - Better spacing */
  .task-table {
    font-size: 12px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
  }
  .task-table th,
  .task-table td {
    padding: 5px 7px;
    font-size: 12px;
  }
  .table-actions button { font-size: 10px; }
  
  /* Time Tracking */
  .time-summary { gap: 10px; padding: 12px 12px; }
  .time-chip-val { font-size: 16px; }
  
  .time-log-form {
    gap: 8px;
  }
  .time-log-form input[type="text"] { min-width: 200px; }
  
  /* Modal */
  .modal {
    max-width: 440px;
    min-width: 300px;
    padding: 20px;
  }
  
  .modal-actions { gap: 8px; }
}

/* DESKTOP (900px+) */
@media (min-width: 900px) {
  /* Default styles already optimized for desktop */
  .shell { max-width: 960px; }
  
  .priority-grid { grid-template-columns: 1fr 1fr; }
  
  .task-table {
    font-size: 13px;
  }
  .task-table th,
  .task-table td {
    padding: 8px;
  }
  
  .modal {
    max-width: 460px;
  }
}

/* LARGE DESKTOP (1200px+) */
@media (min-width: 1200px) {
  .shell { max-width: 1100px; }
  
  .card { padding: 24px; }
  .card-header { margin-bottom: 20px; }
  
  .priority-grid { gap: 24px; }
  
  /* Better spacing for time summary */
  .time-summary { gap: 16px; padding: 14px 16px; }
}

/* VERY SMALL DEVICES (< 360px) */
@media (max-width: 359px) {
  body { font-size: 13px; }
  
  .shell { padding: 0 8px 30px; }
  .top-bar h1 { font-size: 14px; }
  
  .card { padding: 10px; }
  
  .task-item { padding: 4px 6px; gap: 4px; }
  .task-item-text { font-size: 11px; }
  
  .time-chip-val { font-size: 14px; }
  
  .task-table { font-size: 11px; }
  .task-table th,
  .task-table td { padding: 4px 5px; font-size: 10px; }
}

/* LANDSCAPE MODE (width > height on small devices) */
@media (max-height: 500px) {
  .shell { padding: 0 16px 30px; }
  
  .top-bar { padding: 10px 0 8px; }
  .top-bar h1 { font-size: 16px; }
  
  .section-nav { padding: 4px 0 10px; gap: 2px; }
  .section-nav a { font-size: 11px; padding: 3px 7px; }
  
  .card { padding: 12px; margin-bottom: 10px; }
  
  .card-header h2 { font-size: 13px; }
}

/* OPTIMIZE FOR TOUCH DEVICES */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .btn-add,
  .btn-ghost,
  .task-item-actions button {
    min-height: 44px;
  }
  
  button { min-width: 44px; }
  
  input[type="checkbox"] {
    min-width: 24px;
    min-height: 24px;
    cursor: pointer;
  }
  
  select, input, textarea {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* PRINT STYLE */
@media print {
  .section-nav,
  .btn-add,
  .card-header button,
  #priority-modal,
  #michael-modal,
  #question-modal {
    display: none;
  }
  
  .card { page-break-inside: avoid; }
}