/* ===================== Design tokens ===================== */
:root {
  --bg: #f6f8f6;
  --surface: #ffffff;
  --surface-soft: #f0f4f3;
  --border: #e3eae7;

  --blue: #7fa8c9;
  --blue-deep: #5d8bb0;
  --green: #8fc0a9;
  --green-deep: #6aa589;

  --text: #3c4a4f;
  --text-soft: #7b8a90;
  --text-faint: #a7b3b7;

  --danger: #d99a9a;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(93, 139, 176, 0.08);
  --shadow-soft: 0 2px 10px rgba(93, 139, 176, 0.06);

  --font: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ===================== Buttons ===================== */
.btn-primary {
  background: var(--green-deep);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 700;
  transition: background 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}
.btn-primary:hover { background: #5d937a; }
.btn-primary:active { transform: scale(0.98); }

/* ===================== Login ===================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #eef4f1 0%, #e8f0f4 100%);
}

.login-card {
  background: var(--surface);
  width: 100%;
  max-width: 380px;
  padding: 40px 36px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-mark {
  font-size: 34px;
  color: var(--green-deep);
  margin-bottom: 8px;
}

.login-card h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
}

.login-sub {
  margin: 6px 0 28px;
  color: var(--text-soft);
  font-size: 15px;
}

.field {
  display: block;
  text-align: left;
  margin-bottom: 18px;
}
.field span {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--surface-soft);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.field input:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
}

.login-btn { width: 100%; margin-top: 4px; padding: 13px; }

.login-error {
  color: var(--blue-deep);
  font-size: 14px;
  font-weight: 600;
  min-height: 20px;
  margin: 16px 0 0;
}

/* ===================== App layout ===================== */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 28px;
}
.brand-mark { font-size: 24px; color: var(--green-deep); }
.brand-name { font-size: 19px; font-weight: 800; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

/* Group header within the side navigation (e.g. "Emet Digital") */
.nav-section {
  padding: 20px 14px 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-soft);
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: var(--surface-soft); color: var(--text); }
.nav-item.active {
  background: var(--surface-soft);
  color: var(--green-deep);
}
.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  font-size: 15px;
}

/* Subtle item-count badge on the Tasks / Projects tabs */
.nav-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 11px;
  background: rgba(143, 192, 169, 0.22);
  color: var(--green-deep);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.logout-btn {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  padding: 11px;
  font-size: 14px;
  font-weight: 700;
  transition: border-color 0.15s, color 0.15s;
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

.content {
  flex: 1;
  padding: 48px 56px;
  max-width: 920px;
}

/* ===================== Sections ===================== */
.section { display: none; animation: fade 0.25s ease; }
.section.active { display: block; }

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.section-head h2 {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
}
.section-sub {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 15px;
}

/* Quiet secondary button (e.g. Import notes) */
.btn-ghost {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--green-deep);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.btn-ghost:hover { border-color: var(--green); background: var(--surface-soft); }
.btn-ghost:disabled { opacity: 0.55; cursor: default; }

/* Import progress / result message */
.import-status {
  margin: -14px 0 22px;
  min-height: 18px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}
.import-status.error { color: var(--blue-deep); }
.import-status.done { color: var(--green-deep); }

/* ===================== Add row ===================== */
.add-row {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.add-row input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease;
}
.add-row input[type="text"]:focus { outline: none; border-color: var(--blue); }

.date-input {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-soft);
  background: var(--surface);
}
.date-input:focus { outline: none; border-color: var(--blue); }

/* ===================== Task list ===================== */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-soft);
}

.checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: 2px solid var(--blue);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.checkbox:checked { background: var(--green-deep); border-color: var(--green-deep); }
.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

.item-body { flex: 1; min-width: 0; }
.item-title {
  font-size: 15px;
  font-weight: 600;
  word-break: break-word;
}
.item-desc {
  font-size: 14px;
  color: var(--text-soft);
  margin-top: 3px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}
.item-meta {
  font-size: 13px;
  color: var(--text-faint);
  margin-top: 4px;
}
.list-item.done .item-title { text-decoration: line-through; color: var(--text-faint); }
.list-item.done .item-desc { color: var(--text-faint); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 18px;
  padding: 6px;
  border-radius: 8px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--danger); background: var(--surface-soft); }

/* ===================== Cards (projects, processes, notes) ===================== */
.cards { display: flex; flex-direction: column; gap: 18px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-soft);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title {
  flex: 1;
  font-size: 19px;
  font-weight: 800;
  word-break: break-word;
}
.card-count {
  font-size: 13px;
  color: var(--text-faint);
  font-weight: 700;
  background: var(--surface-soft);
  padding: 3px 10px;
  border-radius: 20px;
}

.checklist { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 2px;
}
.check-row .check-label { flex: 1; font-size: 15px; word-break: break-word; }
.check-row.done .check-label { text-decoration: line-through; color: var(--text-faint); }

.sub-add {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.sub-add input {
  flex: 1;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface-soft);
  color: var(--text);
}
.sub-add input:focus { outline: none; border-color: var(--blue); }
.btn-soft {
  background: var(--surface-soft);
  color: var(--green-deep);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 700;
  transition: background 0.15s;
}
.btn-soft:hover { background: #e3ece8; }

/* ===================== Notes ===================== */
.note-title {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  padding: 0;
}
.note-title:focus { outline: none; }
.note-body {
  width: 100%;
  border: none;
  background: transparent;
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
  padding: 0;
  margin-top: 10px;
}
.note-body:focus { outline: none; }
.note-saved {
  font-size: 12px;
  color: var(--green-deep);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s;
}
.note-saved.show { opacity: 1; }

/* ===================== Empty state ===================== */
.empty-state {
  text-align: center;
  color: var(--text-faint);
  font-size: 15px;
  padding: 40px 20px;
  display: none;
}
.empty-state.show { display: block; }

/* ===================== Sync banner ===================== */
.sync-banner {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: #fbeaea;
  color: #b56b6b;
  border: 1px solid #f0d3d3;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}
.sync-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===================== Responsive ===================== */

/* --- Tablets / small laptops: tighten spacing, keep the side rail --- */
@media (max-width: 980px) {
  .sidebar { width: 200px; padding: 24px 14px; }
  .content { padding: 40px 36px; }
  .section-head h2 { font-size: 27px; }
}

/* --- Phones & narrow tablets: top bar + fixed bottom nav --- */
@media (max-width: 720px) {
  .app { flex-direction: column; }

  /* Sidebar becomes a slim sticky top bar holding the brand + sign out.
     The nav is pulled out of it into a fixed bottom tab bar (below). */
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 50;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0; }

  .logout-btn {
    padding: 9px 16px;
    font-size: 14px;
    min-height: 40px;
  }

  /* The group header makes no sense in a horizontal bar — hide it; the
     Clients tab simply joins the row as another tab. */
  .nav-section { display: none; }

  /* Fixed bottom tab bar */
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    flex-direction: row;
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(93, 139, 176, 0.06);
  }
  .nav-item {
    position: relative;
    flex: 1;
    flex-direction: column;
    gap: 3px;
    padding: 8px 4px;
    min-height: 56px;
    justify-content: center;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    border-radius: 12px;
  }
  .nav-item.active { background: var(--surface-soft); }
  .nav-icon { width: auto; font-size: 19px; }

  /* Badge becomes a small bubble at the top-right of the tab's icon */
  .nav-badge {
    position: absolute;
    top: 4px;
    left: calc(50% + 7px);
    margin-left: 0;
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 10px;
  }

  /* Leave room so content never hides behind the bottom bar */
  .content {
    padding: 28px 18px;
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
    max-width: 100%;
  }
  .section-head { margin-bottom: 22px; }
  .section-head h2 { font-size: 25px; }

  /* Stack the add row so inputs are full width and buttons easy to tap */
  .add-row { flex-direction: column; gap: 10px; }
  .add-row input[type="text"],
  .date-input { width: 100%; min-width: 0; }
  .add-row .btn-primary { width: 100%; }

  /* Comfortable tap sizes everywhere */
  .btn-primary { padding: 13px 20px; min-height: 48px; font-size: 16px; }
  .btn-soft { padding: 11px 16px; min-height: 44px; }
  .btn-ghost { padding: 12px 18px; min-height: 46px; font-size: 15px; }
  .add-row input[type="text"],
  .date-input,
  .field input,
  .sub-add input,
  .note-title,
  .note-body { font-size: 16px; } /* 16px stops iOS from zooming on focus */

  .icon-btn { padding: 10px; font-size: 20px; min-width: 44px; min-height: 44px; }
  .checkbox { width: 24px; height: 24px; }
  .checkbox:checked::after { left: 7px; top: 3px; }

  /* Cards a touch more compact */
  .card { padding: 18px 18px; }
  .list-item { padding: 14px 14px; }

  /* Login fills the screen nicely */
  .login-card { padding: 34px 24px; }
}

/* --- Very small phones --- */
@media (max-width: 380px) {
  .nav-item { font-size: 11px; }
  .brand-name { font-size: 17px; }
  .section-head h2 { font-size: 23px; }
}

/* Keep the sync banner inside the viewport on small screens */
@media (max-width: 480px) {
  .sync-banner {
    max-width: calc(100% - 24px);
    text-align: center;
    font-size: 13px;
    padding: 10px 16px;
  }
}
