:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-border: #dde1e6;
  --color-text: #1f2933;
  --color-text-muted: #64748b;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;

  /* 会社ロゴから取った配色 */
  --brand-green: #7ab648;
  --brand-green-dark: #5c9436;
  --brand-orange: #f0891f;
  --brand-blue: #7cc6e8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

header.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 3px solid var(--brand-green);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo-img {
  height: 34px;
  width: auto;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--brand-green-dark);
  margin: 0;
}

.brand-tagline {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--brand-orange);
  text-transform: uppercase;
}

header.app-header a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 14px;
  margin-left: 16px;
}

header.app-header a:hover {
  color: var(--brand-green-dark);
}

main {
  max-width: 960px;
  margin: 24px auto;
  padding: 0 24px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 24px;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-title h2 {
  margin: 0;
  font-size: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
}

th {
  color: var(--color-text-muted);
  font-weight: 600;
}

.filter-row th {
  background: #f8fafc;
  padding: 6px 10px;
  border-bottom: 1px solid var(--color-border);
}

.filter-row select {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 12px;
  color: var(--color-text);
  font-weight: normal;
}

tbody tr:hover {
  background: #f8fafc;
  cursor: pointer;
}

.empty-state {
  color: var(--color-text-muted);
  padding: 32px 0;
  text-align: center;
}

.btn {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: #f1f5f9;
}

form .field {
  margin-bottom: 18px;
}

form label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

form input[type="text"],
form select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.detail-row {
  display: flex;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.detail-row dt {
  width: 160px;
  color: var(--color-text-muted);
  font-size: 14px;
}

.detail-row dd {
  margin: 0;
  font-size: 15px;
}

.case-number-badge {
  display: inline-block;
  font-family: "Consolas", monospace;
  background: #eef2ff;
  color: var(--color-primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
}

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-lead { background: #f1f5f9; color: #475569; }
.status-quoting { background: #fef3c7; color: #92400e; }
.status-submitted { background: #e0e7ff; color: #3730a3; }
.status-won { background: #dcfce7; color: #166534; }
.status-in-progress { background: #dbeafe; color: #1d4ed8; }
.status-done { background: #e5e7eb; color: #374151; }
.status-lost { background: #fee2e2; color: #991b1b; }

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.tabs button {
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tabs button.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.task-row.overdue td {
  color: #b91c1c;
}

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.inline-form .field {
  margin-bottom: 0;
}

.inline-form input[type="text"],
.inline-form input[type="date"],
.inline-form select {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
}

.note-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.note-item:last-child {
  border-bottom: none;
}

.note-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.note-body {
  white-space: pre-wrap;
  font-size: 14px;
}

.section-heading {
  font-size: 16px;
  margin: 32px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.section-heading:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.dropzone:hover {
  border-color: var(--color-primary);
}

.dropzone.dragover {
  border-color: var(--color-primary);
  background: #eef2ff;
  color: var(--color-primary);
}

.dropzone input[type="file"] {
  display: none;
}

.pending-file-list {
  margin-top: 12px;
}

.pending-file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--color-border);
}

.pending-file-item button {
  background: none;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 13px;
}

/* 状態変更（誤操作防止：選択しただけでは確定せず、「変更する」を押して初めて反映する） */
.status-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.status-edit-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-muted);
  font-size: 12px;
  padding: 2px 8px;
  cursor: pointer;
}

.status-edit-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.status-edit-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-edit-controls select {
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 13px;
}

.status-edit-controls button {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.status-edit-confirm {
  background: var(--color-primary);
  color: #fff;
  border: none;
}

.status-edit-cancel {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

/* 検索・絞り込み */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
}

.filter-bar select {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
}

/* 工事管理表: 同じ案件をまとめる行 */
.group-summary-row td {
  background: #f8fafc;
  cursor: pointer;
}

.group-summary-row:hover td {
  background: #eef2ff;
}

.group-toggle-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  width: 22px;
  height: 22px;
  line-height: 1;
  cursor: pointer;
  margin-right: 8px;
  font-size: 11px;
}

.group-meta {
  color: var(--color-text-muted);
  font-size: 13px;
  margin-left: 12px;
}

.group-detail-row td {
  background: #fbfbfd;
}

/* 工事管理表: 編集可能な表 */
#schedule-table input,
#schedule-table select,
#case-schedule-table input,
#case-schedule-table select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 13px;
  box-sizing: border-box;
}

/* 工事管理表: 表示切り替え（一覧／カレンダー／ガントチャート） */
.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.month-nav button {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 14px;
}

.month-nav button:hover {
  border-color: var(--color-primary);
}

.month-nav .month-label {
  font-weight: 600;
  font-size: 16px;
  min-width: 100px;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-dow {
  text-align: center;
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 600;
  padding: 4px 0;
}

.calendar-day {
  min-height: 90px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px;
  background: var(--color-surface);
}

.calendar-day.empty {
  background: transparent;
  border: none;
}

.calendar-day .day-num {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.calendar-day.is-today .day-num {
  color: var(--color-primary);
  font-weight: 700;
}

.calendar-chip {
  display: block;
  background: #eef2ff;
  color: var(--color-primary);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  cursor: pointer;
}

.calendar-chip:hover {
  background: #dbeafe;
}

.gantt-wrap {
  overflow-x: auto;
}

.gantt-grid {
  display: grid;
  align-items: center;
  min-width: 600px;
}

.gantt-label {
  padding: 6px 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--color-surface);
}

.gantt-header-cell {
  text-align: center;
  font-size: 11px;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  padding: 6px 0;
}

.gantt-header-cell.is-weekend {
  background: #f8fafc;
}

.gantt-track {
  position: relative;
  height: 100%;
  border-bottom: 1px solid var(--color-border);
  min-height: 32px;
}

.gantt-bar {
  position: absolute;
  top: 4px;
  bottom: 4px;
  background: var(--brand-green);
  border-radius: 4px;
  font-size: 11px;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
  cursor: pointer;
}

.gantt-bar:hover {
  filter: brightness(0.92);
}


/* ===== UI refresh: work-focused dashboard and calmer daily operation ===== */
:root {
  --color-bg: #f3f6f3;
  --color-border: #dce5dc;
  --color-text: #18231a;
  --color-text-muted: #66756a;
  --color-primary: #5c9436;
  --color-primary-hover: #4a7c2a;
  --surface-soft: #f7faf7;
  --shadow-soft: 0 8px 28px rgba(26, 63, 30, 0.08);
}

header.app-header {
  min-height: 66px;
  padding: 10px clamp(16px, 3vw, 32px);
  box-shadow: 0 2px 10px rgba(26, 63, 30, 0.05);
}

header.app-header nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px 4px;
}

header.app-header a {
  margin-left: 0;
  padding: 7px 9px;
  border-radius: 6px;
  white-space: nowrap;
}

header.app-header a:hover,
header.app-header a[aria-current="page"] {
  background: #edf6e8;
  color: var(--brand-green-dark);
  font-weight: 700;
}

main {
  max-width: 1240px;
  margin: 28px auto 48px;
  padding: 0 clamp(16px, 3vw, 32px);
}

.card {
  border: 1px solid rgba(92, 148, 54, 0.17);
  border-radius: 14px;
  padding: clamp(18px, 3vw, 28px);
  box-shadow: var(--shadow-soft);
}

.page-title h2 {
  font-size: 24px;
  letter-spacing: 0.02em;
}

.btn {
  background: var(--brand-green-dark);
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(51, 99, 28, 0.18);
  font-weight: 700;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

.btn:hover {
  background: #4a7c2a;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(51, 99, 28, 0.2);
}

.btn-secondary {
  box-shadow: none;
}

.btn-secondary:hover {
  background: #edf6e8;
  color: var(--brand-green-dark);
}

.dashboard-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: -2px 0 24px;
}

.dashboard-eyebrow {
  color: var(--brand-green-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  margin: 0 0 6px;
}

.dashboard-hero h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: .03em;
}

.dashboard-subtitle {
  margin: 7px 0 0;
  color: var(--color-text-muted);
  font-size: 14px;
}

.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 26px;
}

.summary-card {
  min-height: 106px;
  padding: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--color-text);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.summary-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-green);
  box-shadow: 0 6px 18px rgba(26, 63, 30, 0.10);
}

.summary-label {
  display: block;
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 700;
}

.summary-value {
  display: block;
  margin-top: 8px;
  color: var(--brand-green-dark);
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

.summary-note {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.summary-card.is-alert .summary-value { color: #c2410c; }
.summary-card.is-alert { background: #fffaf2; border-color: #fed7aa; }

.list-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}

.list-section-title h3 {
  margin: 0;
  font-size: 16px;
}

.list-section-title span {
  color: var(--color-text-muted);
  font-size: 13px;
}

.filter-bar {
  padding: 12px;
  margin-bottom: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

.filter-bar input[type="text"] {
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
}

thead th {
  background: #f5f8f4;
}

th, td {
  padding: 12px;
}

tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #f1f8ee; }

tfoot tr td { background: #edf6e8; }

.status-badge { padding: 4px 10px; }
.case-number-badge { padding: 4px 8px; background: #edf6e8; color: var(--brand-green-dark); }

@media (max-width: 900px) {
  header.app-header { align-items: flex-start; gap: 10px; flex-direction: column; }
  header.app-header nav { justify-content: flex-start; }
  .dashboard-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  main { margin-top: 16px; }
  header.app-header nav a { font-size: 12px; padding: 6px 7px; }
  #user-bar { display: none; }
  .dashboard-hero { align-items: stretch; flex-direction: column; }
  .dashboard-hero h2 { font-size: 24px; }
  .dashboard-summary { grid-template-columns: 1fr 1fr; gap: 8px; }
  .summary-card { min-height: 92px; padding: 13px; }
  .summary-value { font-size: 26px; }
  .page-title { align-items: flex-start; gap: 12px; flex-direction: column; }
  .toolbar { width: 100%; }
  .toolbar .btn { flex: 1; text-align: center; padding-left: 8px; padding-right: 8px; }
  .card { border-radius: 10px; }
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: #edf6e8;
  border: 1px solid var(--brand-green, #5c9436);
  border-radius: 8px;
  font-size: 13px;
  color: var(--brand-green-dark, #4a7c2a);
}

.filter-chip button {
  border: none;
  background: none;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.filter-chip button:hover {
  text-decoration: underline;
}
