:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-synthesis: none;
  background: #f4f5f2;
  color: #202b28;
  --ink: #202b28;
  --muted: #66736d;
  --line: #dce3dc;
  --surface: #fff;
  --green: #2a674d;
  --green-dark: #1d4d38;
  --shadow: 0 14px 40px rgba(31, 53, 40, 0.07);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px max(28px, calc((100vw - 1320px) / 2)); background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; }
.brand-icon { display: block; width: 36px; height: 36px; border-radius: 9px; }
.eyebrow { margin: 0 0 3px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: 0.13em; }
h1 { margin: 0; font-size: 19px; line-height: 1.2; letter-spacing: 0.03em; }
h2, h3, p { overflow-wrap: anywhere; }
.app-menu { position: relative; z-index: 10; }
.app-menu > summary { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--green-dark); font-size: 20px; cursor: pointer; list-style: none; }
.app-menu > summary::-webkit-details-marker, .card-expand::-webkit-details-marker { display: none; }
.app-menu > summary:hover, .app-menu[open] > summary { background: #eef5ed; }
.app-menu > summary:focus-visible, .card-expand:focus-visible { outline: 3px solid #a8d4af; outline-offset: 2px; }
.menu-items { position: absolute; top: calc(100% + 6px); right: 0; display: grid; width: 190px; padding: 5px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: 0 12px 35px rgba(31, 53, 40, 0.17); }
.menu-items button { width: 100%; min-height: 38px; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; font-size: 13px; }
.menu-items button:not(:disabled):hover { background: #eef5ed; }
.menu-items button:last-child { color: var(--green-dark); font-weight: 700; }
.button { min-height: 38px; padding: 8px 14px; border: 1px solid transparent; border-radius: 10px; font-size: 13px; font-weight: 700; white-space: nowrap; transition: background-color 0.15s, transform 0.15s; }
.button:not(:disabled):active { transform: translateY(1px); }
.button-subtle { color: var(--muted); background: transparent; }
.button-subtle:hover { background: #f1f4f0; }
.button-outline { color: var(--green-dark); background: #fff; border-color: #c8d8ca; }
.button-outline:hover { background: #eff6ef; }
.button-primary { color: #fff; background: var(--green); }
.button-primary:hover { background: var(--green-dark); }

.main-content { max-width: 1376px; margin: 0 auto; padding: 18px 28px 80px; }
.overview-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.summary, .sync-panel { min-width: 0; min-height: 62px; padding: 10px 13px; border: 1px solid #dce8dc; border-radius: 11px; background: #eef5ed; }
.summary { display: flex; align-items: center; justify-content: space-around; gap: 8px; }
.summary div { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.summary strong, .summary span, .sync-copy strong, .sync-copy span { font-size: 12px; line-height: 1.35; }
.summary strong { font-weight: 700; }
.summary span { color: var(--muted); }
.sync-panel { display: grid; grid-template-columns: 9px minmax(0, 1fr); align-content: center; align-items: center; gap: 2px 10px; }
.sync-indicator { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 100%; background: #b5bdb8; }
.sync-indicator.ok { background: #3b9a6b; box-shadow: 0 0 0 4px #d8ecde; }
.sync-indicator.busy { background: #d9a53b; box-shadow: 0 0 0 4px #f5ead1; animation: pulse 1.2s ease-in-out infinite; }
.sync-indicator.error { background: #ce685a; box-shadow: 0 0 0 4px #f5dfda; }
@keyframes pulse { 50% { opacity: 0.45; } }
.sync-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sync-copy span { color: var(--muted); }
.sync-error { grid-column: 1 / -1; margin: 4px 0 0; color: #a74339; font-size: 11px; }
.toolbar { display: flex; align-items: stretch; gap: 8px; margin-bottom: 10px; }
.search-field { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: #89948b; }
.search-field:focus-within, .select-field:focus-within { border-color: #6b9d7a; outline: 3px solid #dceee0; }
.search-field span:not(.sr-only) { font-size: 25px; line-height: 1; }
.search-field input { width: 100%; min-height: 36px; border: 0; outline: 0; background: transparent; font-size: 12px; }
.select-field { display: flex; align-items: center; gap: 10px; min-width: 150px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.select-field span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.select-field select { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }

.project-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 9px; }
.project-card { position: relative; min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-width: 0; padding-right: 34px; }
.priority { padding: 4px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.priority.high { color: #a43d30; background: #fbeae7; }
.priority.medium { color: #9b6e24; background: #f8f0db; }
.priority.low { color: #4b6c63; background: #e9f2ed; }
.priority.none { color: #78847e; background: #f0f2ef; }
.card-title { margin: 0; min-width: 0; font-size: 19px; line-height: 1.32; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.card-expand { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; color: var(--green-dark); background: #edf5ed; font-size: 23px; line-height: 1; cursor: pointer; list-style: none; }
.card-expand:hover, .card-details[open] .card-expand { background: #dceee0; }
.card-expand span { transform: translateY(-2px); transition: transform 0.15s; }
.card-details[open] .card-expand span { transform: translateY(-2px) rotate(180deg); }
.card-facts { display: grid; gap: 6px; margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.card-facts div { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.card-facts dt { flex: 0 0 68px; color: #829087; font-size: 11px; }
.card-facts dd { margin: 0; min-width: 0; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.status-pill { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 6px; font-size: 11px; }
.status-pill.active { color: #256444; background: #e9f4ea; }
.status-pill.waiting { color: #986922; background: #f7f0dd; }
.status-pill.paused { color: #697480; background: #eff2f4; }
.status-pill.none { color: #7c8981; background: #f2f3f1; }
.deadline-soon { color: #b45142; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; }
.note-preview { max-width: 70%; margin: 0; color: #7a867e; font-size: 11px; line-height: 1.45; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.edit-button { flex: 0 0 auto; border: 0; background: transparent; color: var(--green); font-size: 12px; font-weight: 800; }
.edit-button:hover { text-decoration: underline; }
.empty-state { margin-top: 14px; padding: 64px 20px; border: 1px dashed #cad8ca; border-radius: 15px; background: #fbfcfa; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 13px; background: #edf5ed; color: var(--green); font-size: 24px; }
.empty-state h3 { margin: 0 0 7px; font-size: 16px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 12px; }

.dialog { width: min(92vw, 560px); max-height: min(88vh, 850px); padding: 0; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 30px 90px rgba(24, 42, 30, 0.24); }
.dialog::backdrop { background: rgba(21, 34, 27, 0.4); }
.dialog form { padding: 25px; overflow-y: auto; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.dialog-heading h2 { margin: 2px 0 0; font-size: 22px; }
.icon-button { width: 31px; height: 31px; border: 0; border-radius: 8px; color: #6f7b73; background: #f2f4f1; font-size: 22px; line-height: 1; }
.dialog-help { margin: 15px 0 20px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.form-field { display: flex; flex-direction: column; gap: 7px; margin-top: 15px; color: #3c4b42; font-size: 12px; font-weight: 700; }
.form-field input, .form-field select, .form-field textarea { width: 100%; min-height: 42px; padding: 10px 11px; border: 1px solid #ced9cf; border-radius: 9px; outline: 0; background: #fff; color: var(--ink); font-size: 13px; font-weight: 400; }
.form-field textarea { min-height: 105px; resize: vertical; line-height: 1.6; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: #6b9d7a; box-shadow: 0 0 0 3px #dceee0; }
.form-field select:disabled { background: #f3f5f2; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.field-note { margin: 12px 0 0; color: #78857b; font-size: 11px; line-height: 1.65; }
.form-error { margin: 15px 0 0; color: #a74339; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 23px; }

@media (max-width: 680px) {
  .topbar { padding: 9px 12px; }
  .brand { gap: 3px; }
  .brand-icon { width: 31px; height: 31px; border-radius: 8px; }
  h1 { font-size: 17px; }
  .app-menu > summary { width: 34px; height: 34px; }
  .main-content { padding: 9px 9px 32px; }
  .overview-row { grid-template-columns: minmax(0, 43fr) minmax(0, 57fr); gap: 5px; margin-bottom: 7px; }
  .summary, .sync-panel { min-height: 58px; padding: 6px 8px; border-radius: 9px; }
  .summary { display: grid; align-content: center; justify-content: start; gap: 1px; }
  .summary div { gap: 4px; }
  .summary strong, .summary span, .sync-copy strong, .sync-copy span { font-size: 10px; }
  .sync-panel { column-gap: 7px; }
  .sync-error { font-size: 10px; }
  .toolbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 72px) minmax(0, 89px); gap: 5px; margin-bottom: 7px; }
  .search-field { min-width: 0; padding: 0 7px; }
  .search-field span:not(.sr-only) { display: none; }
  .search-field input { min-height: 32px; font-size: 11px; }
  .select-field { min-width: 0; padding: 0 4px; gap: 2px; }
  .select-field span { display: none; }
  .select-field select { min-width: 0; font-size: 10px; }
  .project-list { grid-template-columns: 1fr; gap: 5px; }
  .project-card { padding: 8px 10px; border-radius: 9px; box-shadow: none; }
  .card-title { font-size: 17px; line-height: 1.32; }
  .priority { flex: 0 0 auto; padding: 2px 5px; font-size: 9px; }
  .card-facts { margin-top: 9px; }
}

@media (max-width: 540px) {
  .form-grid { grid-template-columns: 1fr; }
  .dialog form { padding: 20px; }
}
