.button {
    display: inline-flex;
    min-height: var(--control-height);
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    padding: .625rem 1rem;
    border: .0625rem solid transparent;
    border-radius: var(--radius-small);
    color: #fff;
    background: #0f62fe;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.button:hover { background: #0353e9; text-decoration: none; }
.button:active { background: #002d9c; }
.button:disabled, .button[aria-disabled="true"] { color: #8d8d8d; background: #c6c6c6; cursor: not-allowed; }
.button--secondary { color: #fff; background: #393939; }
.button--secondary:hover { background: #4c4c4c; }
.button--ghost { color: var(--link); background: transparent; border-color: var(--link); }
.button--ghost:hover { color: #fff; background: var(--link); }
.button--danger { background: var(--signal-red-dark); }
.button--danger:hover { background: #750e13; }
.button--icon { width: var(--control-height); padding: 0; justify-content: center; }
.button-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

.field { display: grid; gap: var(--space-2); margin-bottom: var(--space-5); }
.field label, .field-label { font-size: .875rem; font-weight: 500; }
.field-help { margin: 0; color: var(--text-secondary); font-size: .8125rem; }
.field-error { margin: 0; color: var(--signal-red-dark); font-size: .8125rem; font-weight: 500; }
.required-mark { color: var(--signal-red-dark); }

.input, .select, .textarea {
    width: 100%;
    min-height: var(--control-height);
    padding: .625rem 1rem;
    border: 0;
    border-bottom: .0625rem solid var(--border-strong);
    border-radius: 0;
    color: var(--text-primary);
    background: var(--surface-secondary);
}

.textarea { min-height: 7.5rem; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { background: var(--surface-hover); }
.input:focus, .select:focus, .textarea:focus { outline: .125rem solid var(--focus); outline-offset: -.125rem; border-color: transparent; }
.input:disabled, .select:disabled, .textarea:disabled { color: var(--text-disabled); cursor: not-allowed; }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { outline: .125rem solid var(--signal-red-dark); outline-offset: -.125rem; }

.search-field { position: relative; }
.search-field .icon { position: absolute; top: .625rem; left: .75rem; pointer-events: none; }
.search-field .input { padding-left: 2.5rem; }

.choice { display: flex; gap: var(--space-3); align-items: flex-start; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-mark {
    display: grid;
    width: 1.125rem;
    height: 1.125rem;
    flex: 0 0 auto;
    place-items: center;
    margin-top: .1rem;
    border: .125rem solid var(--text-primary);
    background: transparent;
}
.choice--radio .choice-mark { border-radius: 50%; }
.choice input:focus-visible + .choice-mark { outline: .125rem solid var(--focus); outline-offset: .125rem; }
.choice input:checked + .choice-mark { border-color: var(--focus); background: var(--focus); box-shadow: inset 0 0 0 .1875rem var(--surface-primary); }
.choice--checkbox input:checked + .choice-mark { box-shadow: none; }
.choice--checkbox input:checked + .choice-mark::after { content: ""; width: .45rem; height: .25rem; border-left: .125rem solid #fff; border-bottom: .125rem solid #fff; transform: rotate(-45deg) translateY(-.05rem); }

.switch { display: inline-flex; gap: var(--space-3); align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch-track { position: relative; width: 3rem; height: 1.5rem; border-radius: 1rem; background: #8d8d8d; transition: background var(--transition-fast); }
.switch-track::after { content: ""; position: absolute; top: .25rem; left: .25rem; width: 1rem; height: 1rem; border-radius: 50%; background: #fff; transition: transform var(--transition-fast); }
.switch input:checked + .switch-track { background: var(--signal-green-dark); }
.switch input:checked + .switch-track::after { transform: translateX(1.5rem); }
.switch input:focus-visible + .switch-track { outline: .125rem solid var(--focus); outline-offset: .125rem; }

.notice { display: grid; grid-template-columns: auto 1fr; gap: var(--space-3); padding: var(--space-4); border-left: .25rem solid; background: var(--surface-primary); }
.notice strong { display: block; margin-bottom: var(--space-1); }
.notice p { margin: 0; color: var(--text-secondary); }
.notice--info { border-color: var(--signal-blue); background: #edf5ff; }
.notice--success { border-color: var(--signal-green); background: #defbe6; }
.notice--warning { border-color: var(--signal-yellow); background: #fcf4d6; }
.notice--danger { border-color: var(--signal-red); background: #fff1f1; }

.tag { display: inline-flex; min-height: 1.5rem; align-items: center; padding: .125rem .625rem; border-radius: 1rem; background: var(--surface-secondary); font-size: .75rem; font-weight: 500; }
.tag--success { color: #0e6027; background: #a7f0ba; }
.tag--warning { color: #684e00; background: #fddc69; }
.tag--danger { color: #750e13; background: #ffb3b8; }
.tag--info { color: #002d9c; background: #a6c8ff; }

.table-wrap { width: 100%; overflow-x: auto; border: .0625rem solid var(--border-subtle); }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface-primary); }
.data-table th { padding: .75rem 1rem; text-align: left; background: var(--surface-secondary); font-weight: 600; }
.data-table td { padding: .75rem 1rem; border-top: .0625rem solid var(--border-subtle); }
.data-table tbody tr:hover { background: #f8f8f8; }

.pagination { display: flex; gap: .0625rem; align-items: center; }
.pagination a, .pagination span { display: grid; min-width: 2.5rem; min-height: 2.5rem; place-items: center; color: var(--text-primary); background: var(--surface-secondary); text-decoration: none; }
.pagination a:hover { background: var(--surface-hover); }
.pagination [aria-current="page"] { color: #fff; background: var(--surface-inverse); }

.segmented { display: inline-flex; border: .0625rem solid var(--border-strong); }
.segmented button { min-height: 2.25rem; padding: .5rem .75rem; border: 0; border-right: .0625rem solid var(--border-strong); background: var(--surface-primary); cursor: pointer; }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { color: #fff; background: var(--surface-inverse); }

.tabs { display: flex; overflow-x: auto; border-bottom: .0625rem solid var(--border-subtle); }
.tab { min-height: 3rem; padding: .75rem 1rem; border: 0; border-bottom: .125rem solid transparent; background: transparent; cursor: pointer; }
.tab[aria-selected="true"] { border-color: var(--focus); font-weight: 500; }
.tab-panel { padding: var(--space-5) 0; }
.tab-panel[hidden] { display: none; }

.popover { position: relative; display: inline-block; }
.popover-panel { position: absolute; z-index: 20; top: calc(100% + .25rem); right: 0; width: min(20rem, 80vw); padding: var(--space-4); border: .0625rem solid var(--border-subtle); background: var(--surface-primary); box-shadow: var(--shadow-popover); }
.popover-panel[hidden] { display: none; }

.upload-box { padding: var(--space-6); border: .0625rem dashed var(--border-strong); background: var(--surface-primary); text-align: center; }
.progress { height: .5rem; overflow: hidden; background: var(--surface-secondary); }
.progress span { display: block; height: 100%; background: var(--focus); }
.progress--65 span { width: 65%; }
.progress--waiting span { width: 0; }
.color-input { min-height: 3rem; padding: .25rem; }
.range { width: 100%; accent-color: var(--focus); cursor: pointer; }

.empty-state { padding: var(--space-7); border: .0625rem dashed var(--border-subtle); background: var(--surface-primary); text-align: center; }
.empty-state .icon { width: 2rem; height: 2rem; margin: 0 auto var(--space-4); color: var(--text-secondary); }

@media (max-width: 42rem) {
    .button { width: 100%; }
    .button-row { align-items: stretch; }
}
