:root {
  --ink: #132019;
  --muted: #627069;
  --paper: #f2f4ef;
  --surface: #fbfcf8;
  --line: #cbd2cc;
  --line-strong: #9aa69e;
  --green: #0a8f4d;
  --green-dark: #086b3c;
  --green-soft: #dcece3;
  --blue: #245f99;
  --blue-soft: #e2ebf4;
  --amber: #a35c00;
  --amber-soft: #f5e8cf;
  --red: #b4232c;
  --red-soft: #f4dfe0;
  --radius: 10px;
  font-family: "Arial Nova", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); }
body { min-width: 1180px; }
button, input, textarea, select { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(10, 143, 77, .28); outline-offset: 2px; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 1.4em; height: 1.4em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.screen { min-height: 100vh; padding: 20px 24px 24px; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 14px; }
.monitor-view { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 14px; }
.masthead { display: flex; align-items: center; justify-content: space-between; min-height: 70px; border-bottom: 2px solid var(--ink); padding-bottom: 14px; }
.brand-block { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 50px; height: 50px; background: var(--green); color: white; display: grid; place-items: center; border-radius: 8px; }
.brand-mark svg { width: 31px; height: 31px; stroke-width: 2.4; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(32px, 2.5vw, 48px); line-height: .95; letter-spacing: -.045em; font-weight: 800; }
.brand-block p { margin-top: 7px; color: var(--green-dark); font-size: 17px; font-weight: 700; }
.system-state { display: flex; border-left: 1px solid var(--line-strong); }
.management-open { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--ink); font-weight: 800; cursor: pointer; transition: background 160ms ease, color 160ms ease, border-color 160ms ease; }
.management-open:hover { border-color: var(--green); color: var(--green-dark); background: var(--green-soft); }
.management-open:active { background: #c9e1d3; }
.management-open svg { width: 20px; height: 20px; }
.state-item { min-width: 230px; display: flex; align-items: center; gap: 12px; padding: 7px 20px; border-right: 1px solid var(--line-strong); }
.state-item svg { color: var(--green); width: 30px; height: 30px; }
.state-item span { display: grid; gap: 3px; }
.state-item b { font-size: 17px; }
.state-item small { font-size: 13px; color: var(--muted); }
.state-item.error svg, .state-item.error small { color: var(--red); }
.state-item.waiting svg, .state-item.waiting small { color: var(--amber); }

.metrics { height: 100px; display: grid; grid-template-columns: repeat(4, 1fr) minmax(260px, .8fr); border: 1px solid var(--line-strong); background: var(--surface); }
.metrics article { padding: 15px 22px; display: flex; align-items: baseline; justify-content: space-between; border-right: 1px solid var(--line); }
.metrics article span { font-size: 16px; color: var(--muted); font-weight: 700; }
.metrics article strong { font-size: 54px; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.05em; }
.metrics article.danger strong { color: var(--red); }
.freshness { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 14px; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }

.workspace { min-height: 0; display: grid; grid-template-columns: minmax(330px, 29%) minmax(600px, 45%) minmax(320px, 26%); gap: 14px; }
.panel { min-height: 0; background: var(--surface); border: 1px solid var(--line-strong); display: grid; grid-template-rows: auto minmax(0, 1fr); }
.panel-head { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line-strong); }
.eyebrow { display: block; color: var(--green-dark); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 4px; }
.eyebrow.alert { color: var(--red); }
.panel h2 { font-size: 27px; line-height: 1; letter-spacing: -.025em; }
.panel-meta { color: var(--muted); font-size: 13px; font-weight: 700; }
.head-icon { color: var(--red); width: 34px; height: 34px; }

.task-list, .attention-list { min-height: 0; overflow: hidden; }
.task-row { position: relative; padding: 14px 16px 14px 23px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; }
.task-row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--blue); }
.task-row[data-tone="today"]::before { background: var(--amber); }
.task-row[data-tone="overdue"]::before { background: var(--red); }
.task-row[data-tone="done"]::before { background: var(--green); }
.task-row h3 { margin: 0; font-size: 19px; line-height: 1.14; letter-spacing: -.015em; }
.task-time { grid-row: 1 / span 2; grid-column: 2; text-align: right; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.task-time small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.task-meta { display: flex; min-width: 0; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.task-meta .owner { color: var(--ink); font-weight: 700; }
.task-meta .source { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); flex: none; }

.attention-card { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.attention-card:first-child { border-top: 5px solid var(--red); }
.attention-card h3 { font-size: 20px; line-height: 1.1; margin: 0 0 10px; }
.attention-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.attention-line span { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.attention-line svg { width: 17px; height: 17px; }
.due-tag { padding: 5px 7px; background: var(--red); color: white !important; font-weight: 800; font-variant-numeric: tabular-nums; border-radius: 4px; }
.due-tag.today { background: var(--amber); }

.calendar { min-height: 0; display: grid; grid-template-columns: 66px repeat(5, minmax(0, 1fr)); grid-template-rows: 60px repeat(6, minmax(72px, 1fr)); overflow: hidden; }
.cal-corner, .cal-day, .cal-time, .cal-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-day { display: grid; place-content: center; text-align: center; gap: 2px; background: #eef1ec; font-size: 15px; font-weight: 800; }
.cal-day b { font-size: 21px; }
.cal-day.today { color: white; background: var(--green-dark); }
.cal-time { display: flex; justify-content: center; padding-top: 13px; color: var(--muted); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-cell { position: relative; min-width: 0; min-height: 0; padding: 5px; overflow: hidden; }
.cal-event { padding: 7px 7px 7px 10px; background: var(--blue-soft); border-left: 4px solid var(--blue); font-size: 12px; line-height: 1.12; margin-bottom: 4px; overflow: hidden; }
.cal-event.today { background: var(--amber-soft); border-color: var(--amber); }
.cal-event.overdue { background: var(--red-soft); border-color: var(--red); }
.cal-event.done { background: var(--green-soft); border-color: var(--green); }
.cal-event b { display: block; font-size: 13px; margin-bottom: 4px; }
.cal-event span { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty { display: grid; place-items: center; min-height: 180px; padding: 28px; text-align: center; color: var(--muted); font-size: 15px; }
.hidden { display: none !important; }
.management-layer { position: fixed; inset: 0; z-index: 20; width: 100vw; height: 100dvh; padding: 24px; display: grid; place-items: center; background: rgba(19, 32, 25, .62); }
.management-dialog { width: min(1420px, 100%); height: min(920px, calc(100dvh - 48px)); min-height: 620px; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--paper); border: 1px solid var(--ink); box-shadow: 16px 16px 0 rgba(19, 32, 25, .2); overflow: hidden; }
.management-head { min-height: 88px; display: grid; grid-template-columns: minmax(280px, 1fr) auto auto; align-items: center; gap: 24px; padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--line-strong); }
.management-head h2 { margin: 0; font-size: 28px; letter-spacing: -.025em; }
.management-head p { max-width: 450px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.management-close { min-width: 96px; min-height: 46px; border: 1px solid var(--line-strong); border-radius: 7px; background: transparent; color: var(--ink); font-weight: 800; cursor: pointer; }
.management-close:hover { background: #e8ebe6; }
.management-shell { min-height: 0; display: grid; grid-template-columns: 370px minmax(0, 1fr); gap: 0; }
.management-list-panel { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--surface); border-right: 1px solid var(--line-strong); }
.search-field { min-height: 68px; margin: 0; padding: 11px 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.search-field svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search-field input { width: 100%; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 7px; background: white; color: var(--ink); font-size: 15px; }
.management-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.management-task { width: 100%; min-height: 92px; padding: 13px 14px 13px 17px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; text-align: left; border: 0; border-left: 5px solid transparent; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.management-task:hover { background: #f0f3ee; }
.management-task.selected { border-left-color: var(--green); background: var(--green-soft); }
.management-task-main { min-width: 0; display: grid; align-content: center; gap: 7px; }
.management-task-main b { font-size: 16px; line-height: 1.25; }
.management-task-main small { overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.management-task-side { display: grid; justify-items: end; align-content: space-between; gap: 8px; }
.management-task-side time { color: var(--muted); font-size: 12px; line-height: 1.35; text-align: right; font-variant-numeric: tabular-nums; }
.management-task-side em { padding: 4px 7px; border-radius: 4px; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-style: normal; font-weight: 800; }
.management-task-side em[data-status="done"] { color: var(--green-dark); background: var(--green-soft); }
.management-task-side em[data-status="cancelled"] { color: var(--muted); background: #e4e7e3; }
.management-task-side em[data-status="in_progress"] { color: var(--amber); background: var(--amber-soft); }
.management-empty { padding: 36px 20px; color: var(--muted); text-align: center; }
.editor-panel { min-width: 0; min-height: 0; overflow-y: auto; background: var(--paper); }
.editor-empty { min-height: 100%; padding: 40px; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); }
.editor-empty svg { width: 44px; height: 44px; margin-bottom: 14px; color: var(--green); }
.editor-empty h3 { margin: 0 0 8px; color: var(--ink); font-size: 24px; }
.editor-empty p { max-width: 420px; margin: 0; line-height: 1.5; }
.task-form { max-width: 980px; margin: 0 auto; padding: 24px 28px 40px; }
.editor-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line-strong); }
.editor-title-row h3 { margin: 0; font-size: 26px; line-height: 1.1; }
.source-badge { max-width: 320px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: var(--surface); font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { display: grid; align-content: start; gap: 7px; }
.field-wide { grid-column: 1 / -1; }
.field > span { font-size: 14px; font-weight: 800; }
.field input, .field textarea, .field select { width: 100%; min-height: 46px; border: 1px solid var(--line-strong); border-radius: 6px; background: white; color: var(--ink); padding: 10px 12px; font-size: 16px; }
.field textarea { min-height: 126px; resize: vertical; line-height: 1.5; }
.field small { min-height: 18px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.editor-error { margin: 12px 0 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.primary-button, .secondary-button { min-height: 48px; padding: 0 18px; border-radius: 6px; font-weight: 800; cursor: pointer; }
.primary-button { min-width: 150px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--green-dark); background: var(--green-dark); color: white; }
.primary-button:hover { background: var(--green); }
.primary-button:disabled { opacity: .48; cursor: wait; }
.primary-button svg { width: 19px; height: 19px; }
.secondary-button { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.secondary-button:hover { background: #e8ebe6; }
.history-panel { margin-top: 28px; padding-top: 22px; border-top: 2px solid var(--ink); }
.history-head { display: flex; align-items: center; justify-content: space-between; }
.history-head h4 { margin: 0; font-size: 19px; }
.history-head span { min-width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green-dark); font-size: 12px; font-weight: 800; }
.history-list { margin: 18px 0 0; padding: 0; list-style: none; }
.history-list li { position: relative; min-height: 52px; display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 12px; }
.history-list li > span { width: 10px; height: 10px; margin-top: 4px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.history-list li:not(:last-child)::before { content: ""; position: absolute; top: 16px; bottom: 1px; left: 4px; width: 1px; background: var(--line-strong); }
.history-list li div { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-bottom: 18px; }
.history-list li b { font-size: 14px; }
.history-list li time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.history-list .history-empty { display: block; color: var(--muted); }
.toast { position: fixed; z-index: 40; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 32px)); padding: 13px 16px; border-radius: 7px; background: var(--ink); color: white; font-weight: 700; opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.login-layer { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(19, 32, 25, .62); }
.login-card { width: min(420px, calc(100vw - 40px)); padding: 32px; background: var(--surface); border: 1px solid var(--ink); box-shadow: 12px 12px 0 rgba(19, 32, 25, .25); }
.login-card .brand-mark { margin-bottom: 24px; }
.login-card h2 { font-size: 34px; margin-bottom: 8px; }
.login-hint { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.login-card label { display: block; margin-bottom: 8px; font-weight: 700; }
.login-card input { width: 100%; height: 50px; border: 1px solid var(--line-strong); background: white; padding: 0 13px; font-size: 18px; }
.login-card input:focus { outline: 3px solid var(--green-soft); border-color: var(--green); }
.login-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; margin-top: 14px; }
.login-card button { min-height: 50px; border: 0; background: var(--green-dark); color: white; font-weight: 800; cursor: pointer; }
.login-card button:active { background: var(--ink); }
.login-card .login-cancel { border: 1px solid var(--line-strong); background: transparent; color: var(--ink); }
.login-card .login-cancel:hover { background: #e8ebe6; }
.form-error { min-height: 20px; margin-top: 10px; color: var(--red); font-size: 14px; }

@media (max-width: 1500px) {
  body { min-width: 1024px; }
  .screen { padding: 14px; gap: 10px; }
  .state-item { min-width: 190px; padding-inline: 14px; }
  .workspace { grid-template-columns: 28% 46% 26%; gap: 10px; }
  .panel-head { padding-inline: 14px; }
  .task-row { padding-top: 11px; padding-bottom: 11px; }
}

@media (max-width: 900px) {
  body.management-opened { min-width: 0; overflow: hidden; }
  .management-layer { padding: 0; }
  .management-dialog { width: 100vw; height: 100dvh; min-height: 0; border: 0; box-shadow: none; }
  .management-head { min-height: 74px; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 12px 16px; }
  .management-head h2 { font-size: 23px; }
  .management-head p { display: none; }
  .management-close { min-width: 86px; }
  .management-shell { display: block; overflow-y: auto; }
  .management-list-panel { max-height: 34dvh; border-right: 0; border-bottom: 1px solid var(--line-strong); }
  .management-list { max-height: calc(34dvh - 68px); }
  .editor-panel { overflow: visible; }
  .editor-empty { min-height: 45dvh; }
  .task-form { padding: 20px 16px calc(32px + env(safe-area-inset-bottom)); }
  .editor-title-row { display: grid; gap: 10px; }
  .source-badge { max-width: 100%; justify-self: start; }
  .form-grid { grid-template-columns: 1fr; gap: 16px; }
  .field-wide { grid-column: auto; }
  .form-actions { position: sticky; bottom: 0; z-index: 2; margin-inline: -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(242, 244, 239, .96); }
  .primary-button, .secondary-button { flex: 1; }
  .history-list li div { display: grid; gap: 4px; }
  .toast { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: breathe 2.4s ease-in-out infinite; }
  @keyframes breathe { 50% { box-shadow: 0 0 0 8px rgba(10, 143, 77, .08); } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
