:root {
  --bg: #f6f6f8; --panel: #ffffff; --text: #1b1d22; --muted: #6b7080; --line: #e3e4e9;
  --accent: #4f6bed; --danger: #d64545;
  --create: #8b5cf6; --operate: #3b82f6; --maintain: #16a34a; --experience: #f97316;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111318; --panel: #1a1d24; --text: #e7e9ee; --muted: #9298a8; --line: #2b2f39; }
}
html[dir="rtl"] { font-family: Vazirmatn, system-ui, sans-serif; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; }
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 7px 12px; cursor: pointer;
}
button.ghost, .nav button, .seg button { background: transparent; color: var(--text); border: 1px solid var(--line); }
.seg button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
input, select { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
h2 { font-size: 17px; margin: 4px 0 10px; }
h3 { font-size: 14px; margin: 16px 0 6px; color: var(--muted); }
.spacer { flex: 1; }
.row { display: flex; gap: 6px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; align-items: center;
  padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.seg, .nav { display: flex; gap: 4px; }

.layout { display: grid; grid-template-columns: 1fr 340px; gap: 12px; padding: 12px; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.side { display: flex; flex-direction: column; gap: 12px; }
.theme { color: var(--muted); font-style: italic; margin: 0 0 8px; min-height: 1.2em; }
.tabbar { display: none; }

.capture { display: flex; gap: 6px; margin-bottom: 8px; }
.capture input { flex: 1; min-width: 0; }
.toast { background: var(--bg); border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; font-size: 13px; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.list li .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list li .x { background: none; color: var(--muted); padding: 2px 6px; }
.list li input[type=date] { padding: 2px 4px; font-size: 12px; width: 120px; }
.tag { font-size: 11px; border-radius: 6px; padding: 1px 6px; color: #fff; }
.tag.create { background: var(--create); } .tag.operate { background: var(--operate); }
.tag.maintain { background: var(--maintain); } .tag.experience { background: var(--experience); }
.tag.prio { background: var(--muted); }
.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

.score-item { margin: 10px 0; }
.score-item .lbl { display: flex; justify-content: space-between; font-size: 14px; }
.score-item .lbl span:last-child { direction: ltr; unicode-bidi: isolate; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.over > i { background: var(--danger); }

/* FullCalendar theming */
.fc { --fc-border-color: var(--line); --fc-page-bg-color: var(--panel); --fc-neutral-bg-color: var(--bg);
      --fc-today-bg-color: color-mix(in srgb, var(--accent) 8%, transparent); font-size: 13px; }
.fc .fc-timegrid-slot { height: 1.6em; }
.fc-event.mode-create { background: var(--create); border-color: var(--create); }
.fc-event.mode-operate { background: var(--operate); border-color: var(--operate); }
.fc-event.mode-maintain { background: var(--maintain); border-color: var(--maintain); }
.fc-event.mode-experience { background: var(--experience); border-color: var(--experience); }
.fc-event.is-task { background: var(--panel) !important; color: var(--text); border-style: dashed; border-width: 2px; }
.fc-event.is-task .fc-event-main { color: var(--text); }
.fc-event.is-done { opacity: .45; text-decoration: line-through; }
.fc .day-theme { display: block; font-size: 10px; font-weight: normal; color: var(--muted); white-space: normal; }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--panel); padding: 24px; border-radius: 14px; border: 1px solid var(--line); }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card label.check { flex-direction: row; align-items: center; gap: 8px; }
.err { color: var(--danger); margin: 0; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }

/* Mobile: one pane at a time + bottom tab bar */
@media (max-width: 800px) {
  .layout { display: block; padding: 8px 8px 70px; }
  .side { display: contents; }
  .pane { display: none; }
  .pane.active { display: block; }
  .brand { display: none; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; background: var(--panel);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar button { flex: 1; background: none; color: var(--muted); border-radius: 0; padding: 12px 4px; }
  .tabbar button.active { color: var(--accent); font-weight: 600; }
}

/* M2 additions */
.badge { font-size: 18px; }
.banner { background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 8px; padding: 8px 10px; margin: 0 0 8px; font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.theme-editor { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.field input, .field select { color: var(--text); font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
a.btn { display: inline-block; text-align: center; text-decoration: none; border-radius: 8px; padding: 7px 12px; border: 1px solid var(--line); color: var(--text); }
button.danger { background: var(--danger); }
.grip { cursor: grab; color: var(--muted); user-select: none; touch-action: none; }
li.draggable { cursor: grab; }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); width: min(420px, calc(100vw - 32px)); padding: 16px; }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h3 { margin: 0; color: var(--text); }
.trend table { width: 100%; border-collapse: collapse; font-size: 13px; }
.trend th, .trend td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: center; }
.trend th:first-child { text-align: start; font-weight: normal; color: var(--muted); }
.trend td.good { color: var(--maintain); font-weight: 600; }
.trend td.bad { color: var(--danger); font-weight: 600; }
.trend td { direction: ltr; unicode-bidi: isolate; }

/* event content: title first, time small; wraps on tall blocks, one line on short ones */
.fc .ev { display: flex; flex-wrap: wrap; column-gap: 6px; line-height: 1.2; overflow: hidden; height: 100%; padding: 1px 2px; }
.fc .ev-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.fc .ev-time { font-size: 10px; opacity: .85; white-space: nowrap; }
.fc .fc-timegrid-event-short .ev { flex-wrap: nowrap; }
.fc .fc-timegrid-event-short .ev-title { white-space: nowrap; }
.fc .fc-timegrid-event-short .ev-time { display: none; }
