* {
    box-sizing: border-box;
}
html {
    scrollbar-gutter: stable;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 100px 15px 40px;
}

.login-box {
    width: 100%;
    max-width: 420px;
    padding: 30px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
}

.login-box h1 {
    margin: 0 0 25px;
    text-align: center;
    font-size: 24px;
}

.login-box label {
    margin: 15px 0 5px;
}

.login-submit {
    width: 100%;
    min-height: 46px;
    margin-top: 25px;
    border-radius: 4px;
    font-size: 14px;
}

.login-box .gsi-material-button {
    width: 100%;
    max-width: none;
    height: 46px;
    background: #fff;
    border: 1px solid #747775;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
    color: #999;
    font-size: 15px;
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid #ddd;
}

.gsi-material-button {
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -webkit-appearance: none;
  background-color: #f2f2f2;
  background-image: none;
  border: none;
  -webkit-border-radius: 4px;
  border-radius: 4px;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  color: #1f1f1f;
  cursor: pointer;
  font-family: 'Roboto', arial, sans-serif;
  font-size: 14px;
  height: 40px;
  letter-spacing: 0.25px;
  outline: none;
  overflow: hidden;
  padding: 0 12px;
  position: relative;
  text-align: center;
  -webkit-transition: background-color .218s, border-color .218s, box-shadow .218s;
  transition: background-color .218s, border-color .218s, box-shadow .218s;
  vertical-align: middle;
  white-space: nowrap;
  width: auto;
  max-width: 400px;
  min-width: min-content;
}

.gsi-material-button .gsi-material-button-icon {
  height: 20px;
  margin-right: 10px;
  min-width: 20px;
  width: 20px;
}

.gsi-material-button .gsi-material-button-content-wrapper {
  -webkit-align-items: center;
  align-items: center;
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  -webkit-flex-wrap: nowrap;
  flex-wrap: nowrap;
  height: 100%;
  justify-content: space-between;
  position: relative;
  width: 100%;
}

.gsi-material-button .gsi-material-button-contents {
  -webkit-flex-grow: 1;
  flex-grow: 1;
  font-family: 'Roboto', arial, sans-serif;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

.gsi-material-button .gsi-material-button-state {
  -webkit-transition: opacity .218s;
  transition: opacity .218s;
  bottom: 0;
  left: 0;
  opacity: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.gsi-material-button:disabled {
  cursor: default;
  background-color: #ffffff61;
}

.gsi-material-button:disabled .gsi-material-button-state {
  background-color: #1f1f1f1f;
}

.gsi-material-button:disabled .gsi-material-button-contents {
  opacity: 38%;
}

.gsi-material-button:disabled .gsi-material-button-icon {
  opacity: 38%;
}

.gsi-material-button:not(:disabled):active .gsi-material-button-state, 
.gsi-material-button:not(:disabled):focus .gsi-material-button-state {
  background-color: #001d35;
  opacity: 12%;
}

.gsi-material-button:not(:disabled):hover {
  -webkit-box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15);
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15);
}

.gsi-material-button:not(:disabled):hover .gsi-material-button-state {
  background-color: #001d35;
  opacity: 8%;
}

.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

body {
    margin: 0;
    background: #f4f6f8;
    color: #222;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header {
    background: #fff;
    border-bottom: 1px solid #ddd;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.header-title {
    color: #222;
    font-size: 19px;
    font-weight: 700;
    text-decoration: none;
}

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

nav a,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 16px;
    border: 0;
    border-radius: 7px;
    background: #2367d1;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.2;
}

nav a.secondary,
.button.secondary {
    background: #666;
}

nav a.active {
    background: #174a9c;
    font-weight: 700;
}

.nav-logout-form {
    display: flex;
    margin: 0;
}

.button.danger {
    background: #c0392b;
}

.button.danger:hover {
    background: #a93226;
}

.delete-form {
    display: flex;
    margin: 0;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

.card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 18px;
}

h1 {
    margin: 0 0 20px;
    font-size: 24px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    padding: 10px;
    border: 1px solid #bbb;
    border-radius: 6px;
    background: #fff;
    font-size: 16px;
}

textarea {
    resize: vertical;
}

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

.error {
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 7px;
    background: #fee;
    color: #a00;
}


/* 一覧 */

.search-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 10px;
    align-items: end;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    white-space: nowrap;
}

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid #ddd;
    text-align: left;
    font-size: 14px;
}

th {
    background: #f4f6f8;
}

.amount {
    text-align: right;
}

.pagination {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}


/* 新規作成 */

.steps {
    display: flex;
    max-width: 500px;
    margin-bottom: 25px;
}

.step-label {
    flex: 1;
    padding: 10px;
    text-align: center;
    background: #ddd;
    font-weight: 600;
}

.step-label.active {
    background: #2367d1;
    color: #fff;
}

.step-label:first-child {
    border-radius: 7px 0 0 7px;
}

.step-label:last-child {
    border-radius: 0 7px 7px 0;
}

.step-page {
    display: none;
}

.step-page.active {
    display: block;
}

.issuer-box {
    min-height: 44px;
    padding: 11px;
    background: #f4f6f8;
    border-radius: 6px;
}

.line-card {
    position: relative;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 9px;
}

.line-title {
    margin-bottom: 14px;
    font-weight: 700;
}

.line-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.line-grid .wide {
    grid-column: span 2;
}

.remove-line {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 10px;
    border: 0;
    border-radius: 5px;
    background: #d9534f;
    color: #fff;
    cursor: pointer;
}

.actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
}

.summary {
    max-width: 420px;
    margin: 20px 0 0 auto;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid #ddd;
}

.summary-row.total {
    font-size: 20px;
    font-weight: 700;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.menu-card {
    display: flex;
    min-height: 130px;
    padding: 22px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fff;
    color: #222;
    text-decoration: none;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.menu-card:hover {
    border-color: #2367d1;
}

.menu-card strong {
    font-size: 19px;
}

.menu-card span {
    color: #666;
    font-size: 14px;
}

.admin-card {
    border-left: 4px solid #2367d1;
}

.disabled-card {
    background: #f5f5f5;
    color: #777;
}

.disabled-card:hover {
    border-color: #ddd;
}

.success {
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #b8dfc2;
    border-radius: 7px;
    background: #edf9f0;
}

/* 詳細 */

.detail-link,
.pdf-link {
    color: #2367d1;
    font-weight: 600;
    text-decoration: none;
}

.detail-link:hover,
.pdf-link:hover {
    text-decoration: underline;
}

.invoice-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 24px;
}

.invoice-detail-header h1 {
    margin: 4px 0 6px;
    font-size: 30px;
    line-height: 1.3;
}

.invoice-detail-date {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

.invoice-detail-label {
    color: #666;
    font-size: 13px;
    font-weight: 600;
}

.invoice-detail-date {
    color: #666;
    font-size: 14px;
}

.invoice-detail-card {
    padding: 26px;
}

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

.invoice-overview {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 40px;
    padding: 28px 30px;
    margin-bottom: 22px;
    border: 1px solid #d7dce2;
    border-radius: 10px;
    background: #fff;
}

.invoice-overview span {
    display: block;
    margin-bottom: 8px;
    color: #666;
    font-size: 13px;
}

.invoice-overview-client strong {
    font-size: 23px;
    line-height: 1.5;
}

.invoice-overview-total {
    min-width: 240px;
    text-align: right;
}

.invoice-overview-total strong {
    font-size: 28px;
    line-height: 1.4;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.section-header .section-title {
    margin: 0;
}

.section-title {
    margin: 0 0 18px;
    font-size: 18px;
}

.line-count {
    padding: 4px 9px;
    border-radius: 12px;
    background: #eef1f5;
    color: #555;
    font-size: 12px;
}

.invoice-info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 28px 36px;
    padding: 4px 2px;
}

.invoice-info-item {
    min-width: 0;
}

.invoice-info-item span {
    display: block;
    margin-bottom: 8px;
    color: #777;
    font-size: 12px;
}

.invoice-info-item strong {
    display: block;
    font-size: 15px;
    line-height: 1.6;
}

.invoice-lines-table {
    width: 100%;
    table-layout: fixed;
    white-space: normal;
}

.invoice-lines-table td {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.line-main,
.line-repair,
.line-sub,
.line-memo {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.line-main {
    font-weight: 600;
    line-height: 1.5;
}

.line-repair {
    margin-bottom: 5px;
    color: #555;
    font-size: 12px;
    font-weight: 600;
}

.line-sub {
    margin-top: 5px;
    color: #777;
    font-size: 12px;
    line-height: 1.5;
}

.line-memo {
    margin-top: 8px;
    padding: 7px 9px;
    border-radius: 5px;
    background: #f5f6f7;
    color: #555;
    font-size: 12px;
}

.line-amount {
    font-weight: 700;
    white-space: nowrap;
}

.invoice-bottom-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
}

.invoice-remarks-card,
.invoice-total-card {
    margin-bottom: 0;
}

.invoice-remarks {
    line-height: 1.7;
    /*white-space: pre-wrap;*/
    overflow-wrap: anywhere;
    word-break: break-word;
}

.empty-text {
    color: #999;
}

.invoice-total-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
}

.invoice-total-row.grand-total {
    padding-top: 14px;
    border-bottom: 0;
    font-size: 20px;
}

.invoice-total-row.grand-total strong {
    font-size: 24px;
}

.invoice-lines-mobile {
    display: none;
}

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

.page-title-row h1 {
    margin: 2px 0 0;
}

.page-category {
    color: #777;
    font-size: 13px;
    font-weight: 600;
}

.field-note {
    margin-top: 5px;
    color: #777;
    font-size: 12px;
}

.admin-table td {
    vertical-align: middle;
}

.role-badge,
.status-badge,
.current-user-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    white-space: nowrap;
}

.role-badge {
    background: #eef1f5;
    color: #555;
}

.role-badge.admin {
    background: #e8effc;
    color: #174a9c;
}

.status-badge.active {
    background: #e9f7ed;
    color: #28783d;
}

.status-badge.inactive {
    background: #f2f2f2;
    color: #888;
}

.current-user-badge {
    margin-left: 5px;
    background: #fff3cd;
    color: #795c00;
}

.grid .wide-field {
    grid-column: span 2;
}

.master-notice {
    padding: 12px 15px;
    margin-bottom: 18px;
    border: 1px solid #d8e3f5;
    border-radius: 7px;
    background: #f3f7fd;
    color: #425b7a;
    font-size: 13px;
    line-height: 1.6;
}

.admin-invoice-search {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
}

.admin-search-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}

.deleted-invoice-notice {
    padding: 15px 18px;
    margin-bottom: 18px;
    border: 1px solid #e0b4b4;
    border-radius: 8px;
    background: #fff3f3;
    color: #8d3333;
    line-height: 1.7;
}

.deleted-invoice-notice strong {
    display: block;
    margin-bottom: 5px;
}

.restore-form {
    display: flex;
    margin: 0;
}

.search-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 15px;
}

.line-add-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.bulk-pdf-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid #e1e4e8;
    border-radius: 7px;
    background: #f8f9fa;
}

.bulk-pdf-status {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #666;
    font-size: 13px;
}

.bulk-pdf-status strong {
    color: #222;
    font-size: 13px;
}

.bulk-pdf-actions form {
    margin: 0;
}

.bulk-pdf-actions .button {
    min-height: 36px;
    padding: 8px 14px;
}

.bulk-check-column {
    width: 42px;
    text-align: center;
}

.bulk-check-column input {
    width: 18px;
    height: 18px;
    min-height: 0;
    margin: 0;
    vertical-align: middle;
    cursor: pointer;
}

.button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.table-action {
    padding: 0;
    border: 0;
    background: none;
    color: #2367d1;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.table-action:hover {
    text-decoration: underline;
}

.table-action.danger {
    color: #c0392b;
}

.table-delete-form {
    display: inline-flex;
    margin: 0;
}

.master-code-picker {
    display: flex;
    align-items: center;
    gap: 6px;
}

.master-code-input {
    width: 56px;
    min-width: 56px;
    max-width: 56px;
    flex: 0 0 56px;
    padding-left: 6px;
    padding-right: 6px;
    text-align: center;
}

.master-code-picker select {
    flex: 1;
    min-width: 0;
}

.master-code-input::placeholder {
    font-size: 11px;
    opacity: 0.7;
}

@media (max-width: 700px) {

    .login-page {
        padding: 50px 15px 30px;
    }

    .login-box {
        padding: 24px 20px;
    }

    .header-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    main {
        padding: 16px 12px 50px;
    }

    .grid,
    .search-grid,
    .line-grid {
        grid-template-columns: 1fr;
    }

    .line-grid .wide {
        grid-column: auto;
    }

    .card {
        padding: 15px;
    }

    nav {
        display: flex;
        width: 100%;
        gap: 6px;
    }

    nav a,
    .nav-logout-form {
        flex: 1;
        min-width: 0;
    }

    nav a,
    .nav-logout-form .button {
        width: 100%;
        min-width: 0;
        min-height: 44px;
        padding: 10px 4px;
        justify-content: center;
        text-align: center;
        white-space: nowrap;
        font-size: 12px;
    }

    .nav-logout-form {
        display: flex;
        margin: 0;
    }

    .actions {
        flex-direction: column;
    }

    .actions .button {
        width: 100%;
        text-align: center;
    }

    .invoice-detail-header {
        align-items: stretch;
        flex-direction: column;
    }

    .invoice-detail-card {
        padding: 15px;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .button {
        flex: 1;
        padding-left: 8px;
        padding-right: 8px;
        text-align: center;
    }

    .page-actions .delete-form {
        display: flex;
        flex: 1;
    }

    .page-actions .delete-form .button {
        width: 100%;
    }

    .invoice-overview {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .invoice-overview-client strong {
        font-size: 20px;
    }

    .invoice-overview-total {
        min-width: 0;
        padding-top: 14px;
        border-top: 1px solid #ddd;
        text-align: left;
    }

    .invoice-overview-total strong {
        font-size: 24px;
    }

    .invoice-info-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .invoice-lines-desktop {
        display: none;
    }

    .invoice-lines-mobile {
        display: block;
    }

    .mobile-line-card {
        margin-bottom: 14px;
        border: 1px solid #d7dce2;
        border-radius: 8px;
        overflow: hidden;
    }

    .mobile-line-card:last-child {
        margin-bottom: 0;
    }

    .mobile-line-header {
        display: flex;
        justify-content: space-between;
        padding: 12px 14px;
        background: #f4f6f8;
    }

    .mobile-line-header span {
        font-weight: 700;
    }

    .mobile-line-section {
        padding: 12px 14px;
        border-top: 1px solid #eee;
        font-size: 14px;
    }

    .mobile-line-section > div {
        margin-top: 3px;
        color: #666;
        font-size: 12px;
    }

    .mobile-line-label {
        display: block;
        margin-bottom: 3px;
        color: #777;
        font-size: 11px;
    }

    .mobile-line-values {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        border-top: 1px solid #eee;
    }

    .mobile-line-values > div {
        padding: 10px;
        text-align: center;
    }

    .mobile-line-values span {
        display: block;
        margin-bottom: 3px;
        color: #777;
        font-size: 11px;
    }

    .mobile-line-values strong {
        font-size: 13px;
    }

    .mobile-line-memo {
        padding: 10px 14px;
        border-top: 1px solid #eee;
        background: #fafafa;
    }

    .mobile-line-memo span {
        color: #777;
        font-size: 11px;
    }

    .mobile-line-section,
    .mobile-line-section > div,
    .mobile-line-memo {
        min-width: 0;
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .invoice-bottom-grid {
        grid-template-columns: 1fr;
    }

    .page-title-row {
        align-items: stretch;
        flex-direction: column;
    }

    .page-title-row > .button {
        width: 100%;
        text-align: center;
    }

    .grid .wide-field {
        grid-column: auto;
    }

    .admin-invoice-search {
        grid-template-columns: 1fr;
    }

    .admin-search-actions {
        flex-direction: column-reverse;
    }

    .admin-search-actions .button {
        width: 100%;
        text-align: center;
    }

    .page-actions .restore-form {
        display: flex;
        flex: 1;
    }

    .page-actions .restore-form .button {
        width: 100%;
    }

    .search-actions .button {
        text-align: center;
    }

    .line-add-actions {
        flex-direction: column;
    }

    .line-add-actions .button {
        width: 100%;
    }

    .bulk-pdf-actions {
        gap: 10px;
        padding: 10px;
    }

    .bulk-pdf-status {
        flex: 1;
    }

    .bulk-pdf-actions .button {
        min-height: 40px;
        padding: 8px 12px;
        font-size: 12px;
    }

    .desktop-only {
        display: none !important;
    }

    .master-code-picker {
        display: block;
    }

}


/* 確認画面：全体を1枚の紙にする */
.invoice-sheet {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 24px;
}

/* 確認画面の中のカードだけ、枠を消して区切り線にする */
.invoice-sheet .card,
.invoice-sheet .invoice-overview {
    border: none;
    border-bottom: 1px solid #eee;
    border-radius: 0;
    margin-bottom: 0;
}


.invoice-sheet .invoice-info-grid {
    column-gap: 0;
    padding: 0;
}

.invoice-sheet .invoice-info-item span {
    background: #f4f6f8;
    padding: 11px 10px;
    margin-bottom: 0;
    border-bottom: 1px solid #ddd;
    color: #333;
    font-size: 14px;
    font-weight: bold;
}

.invoice-sheet .invoice-info-item strong {
    padding: 11px 10px;
}


@media (max-width: 700px) {

    .invoice-sheet {
        padding: 8px 4px;
    }

    .invoice-sheet .card,
    .invoice-sheet .invoice-overview {
        padding: 16px 12px;
    }


    .invoice-sheet .invoice-info-grid {
        grid-template-columns: 1fr;
        row-gap: 0;
    }

    .invoice-sheet .invoice-info-item {
        display: grid;
        grid-template-columns: 110px 1fr;
        border-bottom: 1px solid #ddd;
    }

    .invoice-sheet .invoice-info-item span {
        border-bottom: none;
    }

    .invoice-sheet .invoice-info-item strong {
        align-self: center;
    }

    .invoice-sheet .mobile-line-section {
        display: grid;
        grid-template-columns: 100px 1fr;
        column-gap: 8px;
        padding: 10px 12px;
    }

    .invoice-sheet .mobile-line-section > div {
        grid-column: 2;
    }

    .invoice-sheet .mobile-line-label {
        grid-row: span 3;
        margin-bottom: 0;
        font-size: 12px;
    }

    .invoice-sheet .mobile-line-values span {
        font-size: 12px;
    }
}