﻿:root {
  color-scheme: light;
  --app-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  --app-bg: #f4f7f5;
  --app-surface: #ffffff;
  --app-surface-muted: #f9fafb;
  --app-ink: #14263d;
  --app-text-soft: #344452;
  --app-muted: #637487;
  --app-line: #dce4e1;
  --app-line-strong: #b8c5d0;
  --app-primary: #2f8f68;
  --app-primary-dark: #246f52;
  --app-primary-soft: #e8f5ef;
  --app-ai: #2478bd;
  --app-warning: #a76013;
  --app-warning-soft: #fff4df;
  --app-danger: #b33b3b;
  --app-radius: 12px;
  --app-radius-small: 8px;
  --app-shadow: 0 2px 12px rgb(25 51 76 / 7%);
  --app-page: 1440px;
}

/* Shared data-summary cards. */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.kpi {
  padding: 10px;
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius);
  background: var(--app-surface-muted);
}

.kpi .label {
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 800;
}

.kpi .value {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 900;
}

/* Shared edit dialog used by the mobile quick-entry flow. */
.edit-dialog {
  width: min(760px, calc(100vw - 32px));
  padding: 22px;
  border: 0;
  border-radius: var(--app-radius);
  box-shadow: 0 24px 70px rgb(20 35 50 / 30%);
}

.edit-dialog::backdrop {
  background: rgb(20 35 50 / 45%);
}

.edit-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.edit-dialog-head h2 {
  margin: 0;
}

.dialog-close {
  border: 0;
  background: transparent;
  color: var(--app-text-soft);
  cursor: pointer;
  font-size: 24px;
}

.edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.edit-grid label {
  display: grid;
  gap: 6px;
  color: var(--app-text-soft);
  font-weight: 700;
}

.edit-grid input,
.edit-grid select {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid var(--app-line-strong);
  border-radius: var(--app-radius-small);
  background: var(--app-surface);
  font: inherit;
}

.edit-description {
  grid-column: 1 / -1;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .edit-grid {
    grid-template-columns: 1fr;
  }

  .edit-description {
    grid-column: auto;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--app-bg);
  color: var(--app-ink);
  font-family: var(--app-font);
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea,
summary {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--app-primary);
  color: #fff;
}

.app-header__inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: var(--app-page);
  min-height: 64px;
  margin: 0 auto;
  padding: 8px 18px;
}

.app-brand {
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.app-primary-nav {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 4px;
}

.app-primary-nav a {
  position: relative;
  min-height: 44px;
  padding: 11px 14px;
  border-radius: 10px;
  color: #edf9f4;
  font-weight: 800;
  text-decoration: none;
}

.app-primary-nav a:hover,
.app-primary-nav a[aria-current="page"] {
  background: #fff;
  color: var(--app-ink);
}

.app-primary-nav b,
.app-mobile-nav > a > b {
  position: absolute;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 99px;
  background: #d34b4b;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.app-primary-nav b {
  top: 2px;
  right: 2px;
}

.app-user-menu {
  position: relative;
}

.app-user-menu summary {
  min-height: 44px;
  padding: 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  list-style: none;
}

.app-user-menu summary::-webkit-details-marker {
  display: none;
}

.app-user-menu[open] summary {
  background: rgb(255 255 255 / 18%);
}

.app-user-menu__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  gap: 6px;
  width: 170px;
  padding: 8px;
  border: 1px solid var(--app-line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--app-shadow);
}

.app-user-menu__panel > a,
.app-user-menu button {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.app-user-menu__panel > a {
  background: var(--app-primary-soft);
  color: var(--app-primary-dark);
}

.app-user-menu button {
  background: #fff0f0;
  color: var(--app-danger);
}

.app-user-menu form {
  margin: 0;
}

.app-mobile-header,
.app-mobile-nav {
  display: none;
}

.app-page {
  width: min(var(--app-page), calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 60px;
}

.app-page--medium {
  max-width: 960px;
}

.app-page--narrow {
  max-width: 680px;
}

.app-page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.app-page-header h1 {
  margin: 2px 0 0;
  font-size: clamp(24px, 3vw, 31px);
}

.app-page-header p {
  margin: 0;
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 700;
}

.app-count {
  flex: none;
  border-radius: 999px;
  background: var(--app-primary-soft);
  padding: 8px 12px;
  color: var(--app-primary-dark);
  font-size: 14px;
}

.app-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 15px;
  border: 1px solid var(--app-line);
  border-radius: 10px;
  background: #fff;
  color: var(--app-ink);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.app-button--primary {
  border-color: var(--app-primary);
  background: var(--app-primary);
  color: #fff;
}

.app-button--danger {
  border-color: #e0bcbc;
  color: var(--app-danger);
}

.app-button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.app-form-message {
  display: none;
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 800;
}

.app-form-message.is-ok,
.app-form-message.is-success {
  display: block;
  border: 1px solid #8bd3af;
  background: #eaf9f1;
  color: #11603d;
}

.app-form-message.is-error {
  display: block;
  border: 1px solid #f3aaa5;
  background: #fff1f0;
  color: #a52a24;
}

.app-submit {
  min-height: 48px;
  border: 0;
  border-radius: 11px;
  background: var(--app-primary);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 4px 10px rgb(47 143 104 / 20%);
  cursor: pointer;
}

.app-submit:disabled {
  cursor: not-allowed;
  opacity: .6;
}

.app-panel {
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius);
  background: var(--app-surface);
  box-shadow: var(--app-shadow);
}

.app-notice,
.app-task-link {
  border-radius: 10px;
  font-weight: 700;
}

.app-notice {
  margin: 0 0 14px;
  padding: 12px 14px;
}

.app-notice--success {
  background: #def5e9;
  color: #176a48;
}

.app-notice--error {
  background: #ffe5e5;
  color: #9f2e2e;
}

.app-task-list {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.app-task-list:empty {
  display: none;
}

.app-task-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 11px 13px;
  color: var(--app-ink);
  text-decoration: none;
}

.app-task-link--warning {
  border: 1px solid #eccb92;
  background: var(--app-warning-soft);
  color: #75430c;
}

.app-task-link strong {
  flex: none;
  white-space: nowrap;
}

.app-subnav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 14px;
  padding: 5px;
  border: 1px solid var(--app-line);
  border-radius: 11px;
  background: #edf2f1;
}

.app-subnav a {
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #455c6b;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

.app-subnav a[aria-current="page"] {
  background: #fff;
  color: var(--app-ink);
  box-shadow: 0 1px 6px rgb(20 38 61 / 8%);
}

@media (max-width: 760px) {
  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .app-header {
    display: none;
  }

  .app-mobile-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 7px 12px;
    background: var(--app-primary);
    color: #fff;
  }

  .app-mobile-header .app-brand {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 19px;
  }

  .app-mobile-header > strong {
    overflow: hidden;
    font-size: 14px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-user-chip {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    max-width: 76px;
    overflow: hidden;
    padding: 8px 5px;
    border-radius: 8px;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 120;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    min-height: 62px;
    padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--app-line);
    background: rgb(255 255 255 / 96%);
    box-shadow: 0 -4px 16px rgb(20 38 61 / 8%);
  }

  .app-mobile-nav > a {
    position: relative;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 1px;
    min-height: 50px;
    border-radius: 9px;
    color: #637487;
    font-size: 10px;
    font-weight: 800;
    text-decoration: none;
  }

  .app-mobile-nav svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentcolor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
  }

  .app-mobile-nav > a[aria-current="page"] {
    background: var(--app-primary-soft);
    color: var(--app-primary-dark);
  }

  .app-mobile-nav > a > b {
    top: 2px;
    right: calc(50% - 24px);
  }

  .app-page {
    width: calc(100% - 24px);
    padding: 16px 0 28px;
  }

  .app-page-header {
    align-items: center;
    margin-bottom: 12px;
  }

  .app-page-header p {
    display: none;
  }

  .app-page-header h1 {
    font-size: 23px;
  }

  .app-subnav a {
    min-height: 44px;
    padding: 11px 4px;
    font-size: 12px;
  }


}

