﻿:root {
      --header-height: 88px;
      --bg: #eef2f7;
      --card: #fff;
      --ink: #0f172a;
      --line: #cbd5e1;
      --dnk-blue: #2f7dff;
      --dnk-blue-hover: #256fe6;
      --dnk-green: #16a34a;
      --dnk-orange: #f59e0b;
      --dnk-red: #dc2626;
      --dnk-yellow: #fef3a6;
      --blue: var(--dnk-blue);
      --green: var(--dnk-green);
      --red: var(--dnk-red)
    }

    * {
      box-sizing: border-box
    }

    body {
      margin: 0;
      background: var(--bg);
      font-family: system-ui, "Segoe UI", Meiryo, sans-serif;
      color: var(--ink)
    }

    header {
      background: #0f172a;
      color: #fff;
      height: var(--header-height);
      padding: 16px 24px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      z-index: 3000;
      box-shadow: 0 2px 10px rgba(15, 23, 42, 0.16)
    }

    header h1 {
      margin: 0
    }

    .nav {
      display: flex;
      gap: 8px
    }

    .nav button {
      background: #fff;
      border: 0;
      border-radius: 10px;
      padding: 10px 14px;
      font-weight: 800;
      border: 1px solid transparent
    }

    .nav button.active,
    .nav button[aria-current="page"] {
      background: var(--blue);
      color: #fff;
      font-weight: 800;
      border-color: var(--blue)
    }

    main {
      max-width: 1100px;
      margin: auto;
      padding: calc(var(--header-height) + 24px) 18px 18px
    }

    @media(max-width:768px) {
      :root {
        --header-height: 160px
      }

      header {
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 10px
      }

      header h1 {
        font-size: 24px;
        line-height: 1.2
      }

      header>div:first-child>div {
        font-size: 12px;
        line-height: 1.3
      }

      .nav {
        width: 100%;
        justify-content: space-between;
        gap: 8px
      }

      .nav button {
        flex: 1;
        min-width: 0;
        padding: 9px 8px
      }
    }

    .hidden {
      display: none !important
    }

    .card {
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 16px;
      padding: 16px;
      margin-bottom: 16px
    }

    .grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px
    }

    .stats {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 12px
    }

    .stat b {
      font-size: 30px
    }

    .btn,
    button {
      border: 0;
      border-radius: 10px;
      padding: 10px 14px;
      font-weight: 800;
      cursor: pointer
    }

    .primary {
      background: var(--blue);
      color: #fff
    }

    .success {
      background: var(--green);
      color: #fff
    }

    .danger {
      background: var(--red);
      color: #fff
    }

    .ghost {
      background: #fff;
      border: 1px solid var(--line)
    }

    input,
    select {
      width: 100%;
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: 10px;
      font-size: 16px
    }

    label {
      font-weight: 800;
      display: block;
      margin: 8px 0 5px
    }

    .workers {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 12px
    }

    .worker {
      min-height: 70px;
      font-size: 20px;
      background: #fff;
      border: 1px solid var(--line)
    }

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

    th,
    td {
      padding: 10px;
      border-bottom: 1px solid #e2e8f0;
      text-align: left
    }

    .tabs {
      display: flex;
      gap: 8px;
      margin-bottom: 15px
    }

    .tab {
      background: #e5e7eb
    }

    .tab.active {
      background: var(--blue);
      color: #fff
    }

    .panel {
      display: none
    }

    .panel.active {
      display: block
    }

    .badge {
      padding: 5px 9px;
      border-radius: 999px;
      font-weight: 800
    }

    .green {
      background: #dcfce7;
      color: #166534
    }

    .yellow {
      background: var(--dnk-yellow);
      color: #6b5b00
    }

    .red {
      background: #fee2e2;
      color: #991b1b
    }

    .latest {
      background: #eff6ff;
      padding: 12px;
      border-radius: 12px;
      text-align: center
    }

    .latest b {
      font-size: 30px
    }

    .actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap
    }

    .modal {
      position: fixed;
      inset: 0;
      background: #0005;
      display: none;
      align-items: flex-end
    }

    .modal.show {
      display: flex
    }

    .sheet {
      background: #fff;
      width: 100%;
      max-width: 650px;
      margin: auto;
      padding: 18px;
      border-radius: 22px 22px 0 0
    }

    .keys {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px
    }

    .keys button {
      font-size: 24px;
      min-height: 55px
    }

    .quick {
      display: grid;
      grid-template-columns: repeat(6, 1fr);
      gap: 8px;
      margin-top: 8px
    }

    .display {
      font-size: 36px;
      font-weight: 900;
      border: 1px solid var(--line);
      padding: 10px;
      border-radius: 10px
    }

    @media(max-width:760px) {

      .grid,
      .stats,
      .workers {
        grid-template-columns: 1fr 1fr
      }

      .quick {
        grid-template-columns: repeat(3, 1fr)
      }
    }

    .flow-card-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 12px
    }

    .flow-card {
      border: 1px solid var(--line);
      border-radius: 14px;
      padding: 14px;
      background: #f8fafc
    }

    .flow-card h3 {
      margin: 0 0 8px
    }

    .progress {
      height: 14px;
      background: #e2e8f0;
      border-radius: 999px;
      overflow: hidden;
      margin: 8px 0
    }

    .progress-bar {
      height: 100%;
      background: var(--blue)
    }

    .idea-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 10px
    }

    .idea-grid div {
      padding: 12px;
      border: 1px solid #e2e8f0;
      border-radius: 12px;
      background: #f8fafc;
      font-weight: 700
    }

    .flow-section {
      margin-top: 16px;
      padding: 14px;
      border: 1px solid #e2e8f0;
      border-radius: 14px;
      background: #f8fafc
    }

    .flow-section h3 {
      margin-top: 0
    }

    .check-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px
    }

    .check-item {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 10px;
      background: #fff;
      border: 1px solid #e2e8f0;
      border-radius: 10px
    }

    .check-item input {
      width: auto;
      transform: scale(1.25)
    }

    .flow-warning {
      padding: 10px;
      border-radius: 10px;
      background: var(--dnk-yellow);
      color: #6b5b00;
      font-weight: 800;
      margin-top: 8px
    }

    @media(max-width:760px) {

      .flow-card-grid,
      .idea-grid,
      .check-grid {
        grid-template-columns: 1fr
      }
    }

    textarea {
      width: 100%;
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: 10px;
      font: inherit
    }

    .project-meta {
      font-size: 13px;
      color: #475569;
      line-height: 1.6;
      margin-top: 7px
    }

    .due-soon {
      background: #fee2e2;
      color: #991b1b;
      padding: 3px 7px;
      border-radius: 999px;
      font-weight: 800
    }

    .due-normal {
      background: #e0f2fe;
      color: #075985;
      padding: 3px 7px;
      border-radius: 999px;
      font-weight: 800
    }

    .master-detail {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      margin-top: 10px
    }

    .master-detail div {
      background: #fff;
      border: 1px solid #e2e8f0;
      border-radius: 9px;
      padding: 8px
    }

    @media(max-width:760px) {
      .master-detail {
        grid-template-columns: 1fr
      }
    }

    .row-actions {
      display: flex;
      gap: 6px;
      flex-wrap: wrap
    }

    .clone {
      background: #eef2ff;
      color: #3730a3
    }

    .stop {
      background: #fff7ed;
      color: #9a3412;
      border: 1px solid #fed7aa
    }

    .editing-banner {
      display: none;
      margin: 10px 0;
      padding: 10px 12px;
      border-radius: 10px;
      background: #dbeafe;
      color: #1d4ed8;
      font-weight: 800
    }

    .editing-banner.show {
      display: block
    }

    .build-info {
      text-align: center;
      color: #64748b;
      font-size: 12px;
      line-height: 1.7;
      margin: 20px 0 8px
    }

    .build-info h3 {
      margin: 0 0 8px;
      font-size: 13px;
      color: #475569
    }

    .toast-container {
      position: fixed;
      top: calc(var(--header-height, 88px) + 12px);
      left: 50%;
      transform: translateX(-50%);
      z-index: 5000;
      display: flex;
      flex-direction: column;
      gap: 8px;
      pointer-events: none;
      width: clamp(420px, 44vw, 520px);
      max-width: calc(100vw - 32px)
    }

    .toast-container.has-error {
      z-index: 7000
    }

    .toast {
      display: flex;
      align-items: center;
      gap: 8px;
      color: #fff;
      border-radius: 10px;
      padding: 11px 12px;
      font-weight: 700;
      box-shadow: 0 8px 20px rgba(15, 23, 42, 0.28);
      opacity: 0;
      transform: translateY(-12px);
      transition: opacity .26s ease, transform .26s ease;
      pointer-events: auto
    }

    .toast-error {
      align-items: flex-start
    }

    .toast.show {
      opacity: 1;
      transform: translateY(0)
    }

    .toast.hide {
      opacity: 0;
      transform: translateY(-12px)
    }

    .toast-icon {
      font-weight: 900;
      min-width: 1.2em;
      text-align: center
    }

    .toast-text {
      min-width: 0;
      flex: 1;
      line-height: 1.4;
      overflow-wrap: anywhere;
      word-break: break-word
    }

    .toast-code {
      position: absolute;
      right: 10px;
      bottom: 6px;
      font-size: 10px;
      line-height: 1;
      opacity: .7;
      letter-spacing: .04em;
      pointer-events: none
    }

    .toast-close {
      margin-left: auto;
      border: 0;
      background: transparent;
      color: #fff;
      font-size: 16px;
      font-weight: 900;
      line-height: 1;
      cursor: pointer;
      padding: 2px 6px;
      align-self: flex-start
    }

    .toast-success {
      background: var(--dnk-green)
    }

    .toast-warning {
      background: var(--dnk-orange)
    }

    .toast-error {
      background: var(--dnk-red)
    }

    .toast-info {
      background: var(--dnk-blue)
    }

    .error-modal-overlay {
      position: fixed;
      inset: 0;
      z-index: 9000;
      display: none;
      align-items: center;
      justify-content: center;
      background: rgba(15, 23, 42, .45);
      padding: 16px
    }

    .error-modal-overlay.show {
      display: flex
    }

    .error-modal {
      width: min(460px, calc(100vw - 32px));
      background: #fff;
      border-radius: 14px;
      border: 1px solid #fecaca;
      box-shadow: 0 24px 60px rgba(15, 23, 42, .4);
      padding: 18px 18px 14px
    }

    .error-modal-title {
      margin: 0 0 10px;
      color: #991b1b;
      font-size: 20px;
      line-height: 1.3
    }

    .error-modal-message {
      color: #1f2937;
      font-weight: 700;
      line-height: 1.6;
      white-space: pre-line;
      overflow-wrap: anywhere;
      margin-bottom: 8px
    }

    .error-modal-code {
      color: #6b7280;
      font-size: 11px;
      letter-spacing: .05em;
      margin-bottom: 14px
    }

    .error-modal-actions {
      display: flex;
      justify-content: center
    }

    .error-modal-actions .btn {
      min-width: 110px
    }

    @media(max-width:768px) {
      .toast-container {
        width: calc(100% - 32px);
        max-width: 420px
      }
    }

    @media(max-width:768px) {
      .admin-layout {
        grid-template-columns: 1fr;
        gap: 14px
      }

      .admin-table {
        border-collapse: separate;
        border-spacing: 0;
        table-layout: fixed
      }

      .admin-table thead {
        display: none
      }

      .admin-table,
      .admin-table tbody,
      .admin-table tr,
      .admin-table td {
        display: block;
        width: 100%
      }

      .admin-table tr {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 12px;
        margin-bottom: 10px;
        padding: 12px
      }

      .admin-table td {
        border: 0;
        padding: 4px 0;
        text-align: left
      }

      .admin-table td:before {
        display: block;
        margin-bottom: 2px;
        font-size: 12px;
        color: #475569;
        font-weight: 700
      }

      .worker-master-table td:nth-child(1):before {
        content: "社員番号"
      }

      .worker-master-table td:nth-child(2):before {
        content: "氏名"
      }

      .worker-master-table td:nth-child(3):before {
        content: "状態"
      }

      .worker-master-table td:nth-child(4):before {
        content: "操作"
      }

      .project-master-table td:nth-child(1):before {
        content: "番号"
      }

      .project-master-table td:nth-child(2):before {
        content: "工事名"
      }

      .project-master-table td:nth-child(3):before {
        content: "客先"
      }

      .project-master-table td:nth-child(4):before {
        content: "内面"
      }

      .project-master-table td:nth-child(5):before {
        content: "完成予定"
      }

      .project-master-table td:nth-child(6):before {
        content: "納期"
      }

      .project-master-table td:nth-child(7):before {
        content: "状態"
      }

      .project-master-table td:nth-child(8):before {
        content: "操作"
      }

      .admin-table .actions,
      .admin-table .row-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap
      }

      .admin-table button,
      .admin-table .actions button,
      .admin-table .row-actions button {
        min-height: 44px;
        padding: 10px 12px;
        white-space: nowrap;
        writing-mode: horizontal-tb;
        word-break: keep-all
      }

      #masterManagementPanel label,
      #p-projects label {
        writing-mode: horizontal-tb;
        white-space: nowrap;
        display: block
      }

      #masterManagementPanel input,
      #masterManagementPanel select,
      #p-projects input,
      #p-projects select,
      #p-projects textarea {
        width: 100%;
        min-height: 44px
      }
    }
