:root {
  --bg: #F0F4F8;
  --surface: #FFFFFF;
  --text: #1A237E;
  --muted: #546E7A;
  --accent: #1565C0;
  --accent-light: #1976D2;
  --danger: #D32F2F;
  --success: #2E7D32;
  --border: #CFD8DC;
  --tint: #E8F0FE;
  --tint-border: #C5CAE9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Tajawal', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.error-text {
  color: var(--danger);
  font-weight: 600;
  font-size: 0.85rem;
  margin: -4px 0 0;
}

.success-text {
  color: var(--success);
  font-weight: 600;
  font-size: 0.85rem;
  margin: -4px 0 0;
}

.app-shell {
  padding: 16px;
  max-width: 1320px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.app-header h1 {
  margin: 0;
  font-weight: 800;
  font-size: clamp(1.75rem, 2.5vw, 2.75rem);
}

.app-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions button,
.link-button {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: background 0.2s ease, transform 0.1s ease;
}

.header-actions button:hover {
  background: var(--accent-light);
}

.header-actions button:active {
  transform: scale(0.98);
}

.link-button {
  background: #fff;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.link-button:hover {
  background: var(--tint);
}

.menu-wrapper {
  position: relative;
}

.icon-btn-round {
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.icon-btn-round:hover {
  background: var(--tint);
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(21, 101, 192, 0.2);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 40;
}

.menu-dropdown.hidden {
  display: none;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: start;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--tint);
}

.menu-item.menu-item-static {
  cursor: default;
}

.menu-item.menu-item-static:hover {
  background: transparent;
}

.brand-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.trial-badge {
  color: #D32F2F;
  background: #FDECEA;
  border: 1px solid rgba(211, 47, 47, 0.3);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.app-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.calendar-card,
.notes-card,
.usage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(21, 101, 192, 0.06), 0 16px 32px rgba(21, 101, 192, 0.12);
}

.hijri-month {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 2px 0 0;
}

.hijri-day {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.calendar-header,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.calendar-header h2,
.section-title h2 {
  margin: 0;
  font-weight: 800;
}

.calendar-header button {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  box-shadow: 0 3px 8px rgba(21, 101, 192, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: background 0.2s ease, transform 0.1s ease;
}

.calendar-header button:hover {
  background: var(--accent-light);
}

.calendar-header button:active {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(21, 101, 192, 0.35);
}

#selectedDateLabel {
  color: var(--muted);
  margin-top: 2px;
}

.date-jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.date-jump-frame {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: var(--bg);
}

.date-jump.date-jump-frame {
  margin-top: 0;
  margin-bottom: 18px;
}

.date-jump select {
  width: 72px;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 10px 8px;
  background: #FAFBFC;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#jumpMonth,
#fromMonth,
#toMonth {
  width: 130px;
}

.year-input {
  width: 92px;
}

.date-jump select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
  background: #fff;
}

.date-jump button {
  border: none;
  background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  padding: 10px 18px;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(21, 101, 192, 0.3);
  transition: background 0.2s ease, transform 0.1s ease;
}

.date-jump button:hover {
  background: var(--accent-light);
}

.date-jump button:active {
  transform: scale(0.98);
}

.range-filter {
  align-items: center;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px dashed var(--border);
}

.range-filter .secondary-btn {
  padding: 10px 18px;
}

.range-label {
  font-weight: 700;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
}

.week-days,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-top: 18px;
}

.week-days {
  gap: 8px;
  margin-bottom: 4px;
}

.week-days span {
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  color: #fff;
  padding: 9px 4px;
  border-radius: 8px;
}

.week-days span:nth-child(1) { background: #1E88E5; }
.week-days span:nth-child(2) { background: #00ACC1; }
.week-days span:nth-child(3) { background: #43A047; }
.week-days span:nth-child(4) { background: #7CB342; }
.week-days span:nth-child(5) { background: #F9A825; }
.week-days span:nth-child(6) { background: #EC407A; }
.week-days span:nth-child(7) { background: #AB47BC; }

.calendar-grid {
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(21, 101, 192, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.calendar-day {
  min-height: 84px;
  border-radius: 0;
  border: 1px solid var(--border);
  margin: 0 -1px -1px 0;
  padding: 8px;
  position: relative;
  cursor: pointer;
  background: linear-gradient(180deg, #ffffff 0%, #f4f7fb 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
  z-index: 0;
}

.calendar-day:nth-child(7n+1) { background: linear-gradient(180deg, #E3F2FD 0%, #EDF6FE 100%); }
.calendar-day:nth-child(7n+2) { background: linear-gradient(180deg, #E0F7FA 0%, #EBFAFB 100%); }
.calendar-day:nth-child(7n+3) { background: linear-gradient(180deg, #E8F5E9 0%, #F0F8F0 100%); }
.calendar-day:nth-child(7n+4) { background: linear-gradient(180deg, #F1F8E9 0%, #F6FAEF 100%); }
.calendar-day:nth-child(7n+5) { background: linear-gradient(180deg, #FFF8E1 0%, #FFFBEE 100%); }
.calendar-day:nth-child(7n+6) { background: linear-gradient(180deg, #FCE4EC 0%, #FDEDF1 100%); }
.calendar-day:nth-child(7n+7) { background: linear-gradient(180deg, #F3E5F5 0%, #F8EEF9 100%); }

.calendar-day:hover {
  background: var(--tint);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(21, 101, 192, 0.18);
  z-index: 2;
}

.calendar-day.not-current-month {
  opacity: 0.45;
  background: var(--bg);
}

.calendar-day.selected {
  background: var(--tint);
  box-shadow: inset 0 0 0 2px var(--accent), 0 6px 16px rgba(21, 101, 192, 0.25);
  z-index: 3;
}

.day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.2rem;
}

.note-count-badge {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(21, 101, 192, 0.45);
}

.note-count-badge.has-alert {
  background: linear-gradient(180deg, #EF5350 0%, var(--danger) 100%);
  box-shadow: 0 2px 6px rgba(211, 47, 47, 0.45);
}

.note-form {
  margin-top: 18px;
  display: grid;
  gap: 16px;
}

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

.form-row label {
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
}

.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  background: #FAFBFC;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
  background: #fff;
}

textarea {
  resize: vertical;
}

.split-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.note-form button {
  width: fit-content;
  border: none;
  background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  padding: 12px 24px;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(21, 101, 192, 0.35);
  transition: background 0.2s ease, transform 0.1s ease;
}

.note-form button:hover {
  background: var(--accent-light);
}

.note-form button:active {
  transform: scale(0.98);
}

.notes-list {
  margin-top: 24px;
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(21, 101, 192, 0.16);
}

.notes-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.notes-table thead th {
  background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
  color: #fff;
  padding: 12px;
  text-align: start;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 2px 6px rgba(21, 101, 192, 0.25);
}

.notes-table tbody td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  vertical-align: middle;
  color: var(--text);
}

.notes-table tbody tr:nth-child(even) {
  background: var(--bg);
}

.notes-table tbody tr:hover {
  background: var(--tint);
}

.color-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1px solid rgba(26, 35, 126, 0.15);
  box-shadow: 0 1px 3px rgba(26, 35, 126, 0.25);
}

.title-cell {
  font-weight: 700;
  white-space: nowrap;
}

.desc-cell {
  color: var(--muted);
  max-width: 420px;
  white-space: pre-wrap;
  cursor: pointer;
  transition: color 0.15s ease;
}

.desc-cell:hover {
  color: var(--accent);
}

.fullscreen-text-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 35, 126, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  cursor: pointer;
}

.fullscreen-text-content {
  background: #fff;
  color: var(--text);
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px 32px;
  border-radius: 18px;
  font-size: 1.15rem;
  line-height: 1.9;
  white-space: pre-wrap;
  box-shadow: 0 20px 50px rgba(21, 101, 192, 0.3);
}

.notes-table .delete-btn {
  position: static;
  font-size: 1rem;
}

.badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
}

.badge.normal { background: #0288D1; }
.badge.important { background: #FB8C00; }
.badge.urgent { background: var(--danger); }

.delete-btn {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  border: none;
  background: transparent;
  color: #EF5350;
  cursor: pointer;
  font-size: 1rem;
}

.secondary-btn {
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 12px 24px;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.2s ease;
}

.secondary-btn:hover {
  background: var(--bg);
}

.sidebar-block {
  margin-top: 18px;
}

.range-value {
  margin: 8px 0 0;
  color: var(--muted);
}

.usage-content {
  display: grid;
  gap: 16px;
  max-width: 820px;
}

.tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.tab-btn {
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.tab-btn:hover {
  background: var(--tint);
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.usage-card h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  font-weight: 800;
}

.usage-card ul {
  margin: 0;
  padding-inline-start: 20px;
  display: grid;
  gap: 8px;
  color: var(--text);
}

.feature-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: #FFF3E0;
  color: #E65100;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.empty-state {
  color: var(--muted);
  padding: 12px 0;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
  }

  .app-header {
    gap: 10px;
    margin-bottom: 14px;
  }

  .header-actions {
    margin-inline-start: auto;
  }

  .app-header h1 {
    font-size: 1.5rem;
  }

  .header-actions button:not(.icon-btn-round),
  .header-actions .link-button {
    padding: 10px 10px;
    font-size: 0.85rem;
  }

  .tabs-bar {
    flex-direction: column;
  }

  .tab-btn {
    width: 100%;
    text-align: center;
  }

  .calendar-card,
  .notes-card,
  .usage-card {
    padding: 14px;
    border-radius: 14px;
  }

  .section-title {
    flex-direction: column;
    align-items: flex-start;
  }

  .calendar-header {
    flex-wrap: nowrap;
    gap: 6px;
  }

  .calendar-header button {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }

  .calendar-header > div {
    flex: 1;
    min-width: 0;
    text-align: center;
  }

  #monthTitle {
    font-size: 1.05rem;
  }

  .hijri-month,
  #selectedDateLabel {
    font-size: 0.72rem;
  }

  .date-jump {
    margin-top: 10px;
  }

  .week-days,
  .calendar-grid {
    margin-top: 10px;
  }

  .calendar-day {
    min-height: 58px;
    padding: 5px;
  }

  .day-number {
    font-size: 0.8rem;
    min-width: 20px;
    height: 20px;
  }

  .hijri-day {
    font-size: 0.55rem;
    margin-top: 1px;
  }

  .note-count-badge {
    min-width: 18px;
    height: 18px;
    font-size: 0.62rem;
    top: 4px;
  }

  .week-days span {
    font-size: 0.66rem;
    padding: 6px 2px;
  }

  .split-row {
    grid-template-columns: 1fr;
  }

  .date-jump {
    gap: 6px;
  }

  .date-jump select {
    flex: 1;
    min-width: 0;
    padding: 9px 6px;
  }

  #jumpMonth,
  #fromMonth,
  #toMonth {
    width: auto;
  }

  .date-jump button {
    width: 100%;
  }

  .date-jump.date-jump-frame {
    margin-bottom: 14px;
  }

  .range-filter {
    padding-top: 12px;
    margin-top: 12px;
  }

  .range-label {
    width: 100%;
    margin-top: 4px;
  }

  .notes-table {
    min-width: 540px;
  }

  .notes-table th,
  .notes-table td {
    padding: 8px;
    font-size: 0.8rem;
  }

  .menu-dropdown {
    min-width: 180px;
  }
}
