.card,
.table-card,
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(18px);
}

.card {
    padding: 14px;
}

/* ── Labels ── */
label {
    display: block;
    margin-bottom: 6px;
    color: var(--grey-700);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ── Form inputs ── */
input[type="text"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 11px 14px;
    border: 1px solid rgba(16, 32, 56, 0.1);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.92);
    color: var(--grey-900);
    box-shadow: inset 0 1px 2px rgba(16, 32, 56, 0.05);
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        background-color var(--transition-fast);
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
input[type="datetime-local"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--border-strong);
    box-shadow:
        inset 0 1px 2px rgba(16, 32, 56, 0.05),
        var(--focus-ring);
    background: #fff;
}

input[type="radio"],
input[type="checkbox"] {
    width: auto;
}

textarea {
    min-height: 78px;
    resize: vertical;
}

input[type="date"],
input[type="time"],
input[type="datetime-local"] {
    color-scheme: light;
}

/* ── Buttons ── */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, #4f8cff 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(31, 111, 255, 0.16);
    transition:
        transform var(--transition-fast),
        box-shadow var(--transition-fast),
        filter var(--transition-fast);
}

button:hover,
.btn:hover {
    color: #fff;
    transform: translateY(-1px);
    filter: brightness(0.97);
    box-shadow: 0 14px 28px rgba(31, 111, 255, 0.2);
}

button:active,
.btn:active {
    transform: translateY(0);
}

button:focus-visible,
.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

button:disabled,
.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.96);
    color: var(--grey-900);
    border: 1px solid rgba(16, 32, 56, 0.12);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    color: var(--grey-900);
    background: var(--grey-100);
    border-color: var(--grey-500);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border-strong);
    box-shadow: none;
}

.btn-danger {
    background: linear-gradient(135deg, #eb5a68 0%, #d64352 100%);
    box-shadow: 0 12px 28px rgba(214, 67, 82, 0.2);
}

/* Reorder handles for repeatable form rows */
.row-reorder-table th.row-reorder-heading,
.row-reorder-table td.row-reorder-cell {
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px;
    padding-right: 6px !important;
    padding-left: 6px !important;
    text-align: center !important;
    vertical-align: middle !important;
}

.row-reorder-handle.row-reorder-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    width: 30px;
    min-width: 30px;
    height: 30px;
    min-height: 30px;
    padding: 0;
    border: 1px solid rgba(16, 32, 56, 0.14);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--grey-700);
    box-shadow: var(--shadow-sm);
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.row-reorder-handle.row-reorder-handle:hover {
    color: var(--primary);
    background: var(--grey-100);
    border-color: rgba(31, 111, 255, 0.28);
    filter: none;
}

.row-reorder-handle.row-reorder-handle:active,
.is-row-reorder-dragging .row-reorder-handle.row-reorder-handle {
    cursor: grabbing;
    transform: translateY(0);
}

.row-reorder-handle span {
    display: block;
    width: 13px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
}

.row-reorder-table tbody.is-row-reorder-active tr,
.row-reorder-card-stack.is-row-reorder-active .row-reorder-card {
    transition: background var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.row-reorder-table tbody tr.is-row-reorder-dragging td,
.row-reorder-card.is-row-reorder-dragging {
    background: rgba(31, 111, 255, 0.06);
    box-shadow: inset 3px 0 0 var(--primary);
    opacity: 0.72;
}

html[data-theme="dark"] .row-reorder-handle.row-reorder-handle {
    background: var(--surface-soft);
    border-color: var(--border);
    color: var(--grey-800);
    box-shadow: none;
}

html[data-theme="dark"] .row-reorder-handle.row-reorder-handle:hover {
    background: var(--dark-hover);
    border-color: var(--border-strong);
    color: var(--grey-900);
}

/* ── Accessibility ── */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Password field ── */
.password-field {
    position: relative;
}

.password-field .password-input {
    padding-right: 50px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border: 1px solid rgba(16, 32, 56, 0.08);
    border-radius: 10px;
    background: rgba(31, 111, 255, 0.08);
    color: var(--blue-800);
    box-shadow: none;
    line-height: 0;
}

.password-toggle:hover {
    color: var(--blue-800);
    background: rgba(31, 111, 255, 0.12);
    transform: translateY(-50%);
    filter: none;
    box-shadow: none;
}

.password-toggle:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.password-toggle-svg {
    display: block;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
}

.password-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    line-height: 0;
}

.password-toggle-icon--hide { display: none; }
.password-toggle.is-visible .password-toggle-icon--show { display: none; }
.password-toggle.is-visible .password-toggle-icon--hide { display: inline-flex; }

/* ── Alert / feedback banners ── */
.success-message,
.alert-success,
.error-message,
.alert-danger,
.info-message {
    padding: 10px 12px;
    border-radius: 10px;
    font-weight: 700;
    margin-bottom: 16px;
}

.success-message,
.alert-success {
    background: var(--success-bg);
    border: 1px solid rgba(17, 132, 91, 0.16);
    color: var(--success);
}

.error-message,
.alert-danger {
    background: var(--danger-bg);
    border: 1px solid rgba(214, 67, 82, 0.18);
    color: var(--danger);
}

.info-message {
    background: var(--blue-100);
    border: 1px solid rgba(31, 111, 255, 0.14);
    color: var(--blue-800);
}

/* ── Mode / radio pill block ── */
.mode-block {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    padding: 4px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.16);
}

.mode-block label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--grey-700);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.mode-block label:hover {
    background: rgba(31, 111, 255, 0.08);
    color: var(--ink-900);
}

.mode-block label input {
    margin: 0;
    accent-color: var(--primary);
}

.mode-block label:has(input:checked) {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(31, 111, 255, 0.2);
    color: var(--ink-900);
    box-shadow: var(--shadow-sm);
}

.mode-block label:has(input:focus-visible) {
    box-shadow: var(--focus-ring);
}

/* ── Generic branded data table ────────────────────────────────────────────
   Shared across form pages that embed tabular data-entry (e.g. vessel working
   hours). Header gradient matches the invoice line-items table for visual
   consistency across the app.                                                */
.app-data-table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border, rgba(16, 32, 56, 0.1));
}

.app-data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface, rgba(255, 255, 255, 0.96));
}

.app-data-table thead th {
    padding: 8px 10px;
    background: linear-gradient(90deg, #0f2b6d 0%, #1f6fff 100%);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.app-data-table td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--border, rgba(16, 32, 56, 0.08));
    vertical-align: top;
}

.app-data-table tbody tr:last-child td {
    border-bottom: 0;
}

html[data-theme="dark"] .app-data-table {
    background: #202226;
}

html[data-theme="dark"] .app-data-table td {
    border-color: rgba(255, 255, 255, 0.07);
}

/* ── Layout helpers ── */
.inline-row {
    display: grid;
    /* min-width:0 on the column prevents overflow when children have intrinsic width */
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 10px;
    align-items: start;
}

.form-block {
    margin-bottom: 10px;
}

.form-row-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

/* ── Horizontal customer form ── */
.customer-form.form-horizontal .form-block {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
}

.customer-form.form-horizontal .form-block label {
    margin-top: 8px;
    margin-bottom: 0;
}

/* ── Currency / total row ── */
.currency-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.total-container {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(31, 111, 255, 0.1), rgba(79, 195, 247, 0.14));
    border: 1px solid rgba(31, 111, 255, 0.14);
    font-size: 12px;
    font-weight: 800;
}

/* ── Table ── */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.table th {
    color: var(--grey-800);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.table tbody tr:hover td {
    background: rgba(31, 111, 255, 0.04);
}

/* ── Utility ── */
.small-note {
    color: var(--grey-800);
    font-size: 11px;
}

.empty-state {
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px dashed rgba(16, 32, 56, 0.24);
    background: rgba(255, 255, 255, 0.74);
    color: var(--grey-800);
    text-align: center;
}

.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mt-30 { margin-top: 30px; }
.mb-20 { margin-bottom: 20px; }
.w-50  { width: 50%; }
.w-100 { width: 100%; }
.text-right  { text-align: right; }
.text-center { text-align: center; }

/* ── Responsive ── */
@media (max-width: 860px) {
    .customer-form.form-horizontal .form-block {
        grid-template-columns: 1fr;
    }

    .customer-form.form-horizontal .form-block label {
        margin-top: 0;
    }
}

@media (max-width: 640px) {
    .currency-container,
    .form-row-2 {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    button[type="submit"],
    .btn {
        width: 100%;
    }
}
