:root {
    font-family: Arial, Helvetica, sans-serif;
    color: #222;
    background: #f3f5f7;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: #f3f5f7;
}

.container {
    width: min(1200px, calc(100% - 32px));
    margin: 32px auto;
}

.card {
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

h1, h2 { margin-top: 0; }

.hint {
    color: #666;
    margin-top: -8px;
}

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

label {
    display: block;
    font-weight: 700;
    margin-bottom: 18px;
}

input, textarea, select {
    width: 100%;
    margin-top: 7px;
    padding: 11px 12px;
    border: 1px solid #b9c1c9;
    border-radius: 7px;
    font: inherit;
    background: #fff;
}

input:focus, textarea:focus, select:focus {
    outline: 2px solid #9cc3e6;
    border-color: #4b88b7;
}

textarea { resize: vertical; }

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 6px;
}

button, .button {
    display: inline-block;
    border: 0;
    border-radius: 7px;
    padding: 11px 16px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.primary {
    background: #175f92;
    color: #fff;
}

.primary:hover { background: #104b73; }

.secondary {
    background: #e8edf1;
    color: #222;
}

.secondary:hover { background: #dbe2e8; }

.notice {
    padding: 12px 14px;
    border-radius: 7px;
    margin-bottom: 18px;
}

.success {
    background: #e6f4ea;
    border: 1px solid #9fd0aa;
}

.error {
    background: #fdeaea;
    border: 1px solid #e0a7a7;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.table-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.table-controls .button { white-space: nowrap; }
.search-form { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; margin: 10px 0 18px; }
.search-form label { margin: 0; }
.search-form input { width: min(340px, 100%); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 18px; }
.delete-list { max-height: 350px; overflow: auto; margin-bottom: 15px; }
.delete-choice { display: flex; gap: 10px; align-items: flex-start; padding: 8px; margin: 0; border-bottom: 1px solid #e4e7ea; font-weight: normal; }
.delete-choice input { width: auto; margin: 3px 0 0; }
.existing-defect-toggle { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.existing-defect-toggle input { width: auto; margin: 0; }
#existingDefectPicker { margin-bottom: 18px; }
#existingDefectPicker label { margin-bottom: 4px; }
.field-info { display: block; color: #9b3030; font-size: .85em; font-weight: normal; margin-top: 4px; }
dialog { border: 1px solid #dfe3e8; border-radius: 12px; padding: 24px; width: min(400px, calc(100% - 32px)); box-shadow: 0 12px 40px #0003; }
dialog::backdrop { background: #0007; }

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

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

th, td {
    text-align: left;
    padding: 11px 10px;
    border-bottom: 1px solid #e4e7ea;
    vertical-align: top;
}

th {
    background: #f7f8f9;
    white-space: nowrap;
}

.sort-button {
    background: transparent;
    color: inherit;
    padding: 2px 16px 2px 0;
    position: relative;
}

.sort-button:hover { text-decoration: underline; }
.sort-button:focus-visible { outline: 2px solid #175f92; }
th[aria-sort="ascending"] .sort-button::after { content: '▲'; }
th[aria-sort="descending"] .sort-button::after { content: '▼'; }
th[aria-sort="ascending"] .sort-button::after,
th[aria-sort="descending"] .sort-button::after {
    position: absolute;
    right: 0;
    font-size: .65em;
}

.empty {
    text-align: center;
    color: #777;
    padding: 28px;
}

.defect-text { white-space: normal; min-width: 210px; }
.defect-status { margin: 8px 0; font-size: .9em; color: #555; }
.defect-note { margin: 8px 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.auth-trigger { margin-top: 8px; white-space: nowrap; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.editor-panel { margin-top: 20px; padding: 18px; background: #f7f8f9; border: 1px solid #dfe3e8; border-radius: 8px; }
.editor-panel h3 { margin-top: 0; }
.editor-panel label { margin-bottom: 12px; }

@media (max-width: 760px) {
    .container {
        width: min(100% - 20px, 1200px);
        margin: 16px auto;
    }

    .card { padding: 16px; }
    .grid { grid-template-columns: 1fr; gap: 0; }
}
