:root {
    --bg: #f3f1ea;
    --surface: #fffdf8;
    --surface-strong: #ffffff;
    --text: #2f2f2b;
    --muted: #6c6a63;
    --line: #ddd7c9;
    --line-strong: #c7c0ad;
    --accent: #1d6b5f;
    --accent-dark: #155247;
    --danger: #c95a38;
    --danger-dark: #a54427;
    --shadow: 0 14px 38px rgba(39, 36, 28, 0.08);
    --radius: 18px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(29, 107, 95, 0.08), transparent 22rem),
        linear-gradient(180deg, #f8f5ee 0%, var(--bg) 100%);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.45;
}

.page {
    max-width: 1480px;
    margin: 0 auto;
    padding: 36px 22px 56px;
}

.page-narrow {
    max-width: 980px;
}

.page-auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding-top: 24px;
    padding-bottom: 24px;
}

.page-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(2.3rem, 4vw, 3.6rem);
    line-height: 1;
    letter-spacing: -0.04em;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.main-nav {
    margin: 22px 0 24px;
}

.main-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
    padding: 12px;
    list-style: none;
    background: rgba(47, 47, 43, 0.94);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 18px;
    color: #fff;
    font-weight: 700;
    border-radius: 999px;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.main-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    text-decoration: none;
    transform: translateY(-1px);
}

.toolbar,
.table-card,
.form-card {
    background: rgba(255, 253, 248, 0.94);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.toolbar {
    display: grid;
    gap: 18px;
    padding: 22px;
}

.filters {
    display: grid;
    grid-template-columns: minmax(260px, 2fr) minmax(220px, 1fr) auto;
    gap: 16px;
    align-items: end;
    margin: 0;
}

.field-group {
    min-width: 0;
}

.field-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
}

input,
button,
select,
textarea {
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 12px 14px;
    font: inherit;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: var(--surface-strong);
    color: var(--text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

input::placeholder,
textarea::placeholder {
    color: #98948a;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(29, 107, 95, 0.6);
    box-shadow: 0 0 0 4px rgba(29, 107, 95, 0.12);
}

textarea {
    min-height: 132px;
    resize: vertical;
}

button {
    width: auto;
    min-width: 120px;
    border: 0;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    background: var(--accent-dark);
}

.secondary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: rgba(255, 255, 255, 0.7);
    font-weight: 600;
}

.secondary-link:hover {
    text-decoration: none;
    background: #fff;
}

.filter-actions,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 240px));
    gap: 12px;
}

.summary-card {
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(243, 241, 234, 0.88));
}

.summary-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.summary-card strong {
    font-size: 1.5rem;
    letter-spacing: -0.03em;
}

.table-card {
    margin-top: 24px;
    overflow: hidden;
}

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

table {
    width: 100%;
    min-width: 980px;
    border-collapse: separate;
    border-spacing: 0;
}

th,
td {
    padding: 16px 14px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f4f0e5;
    color: #403d36;
    font-size: 0.92rem;
    font-weight: 800;
    white-space: nowrap;
}

tbody tr:nth-child(even) td {
    background: rgba(252, 250, 245, 0.7);
}

tbody tr:hover td {
    background: rgba(29, 107, 95, 0.06);
}

.cell-name {
    font-weight: 700;
}

.cell-date,
.cell-price {
    white-space: nowrap;
}

.notes-cell {
    min-width: 220px;
    max-width: 320px;
    color: var(--muted);
    white-space: normal;
}

.empty-state {
    padding-top: 28px;
    padding-bottom: 28px;
    text-align: center;
    color: var(--muted);
}

tfoot td {
    background: #ece6d8;
    font-weight: 800;
    border-bottom: 0;
}

.action-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
}

.action-links a {
    display: inline-block;
    min-height: auto;
    padding: 0;
    color: var(--accent);
    font-size: 0.94rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border-radius: 0;
    box-shadow: none;
}

.action-links a:hover {
    text-decoration: underline;
    filter: none;
}

.action-links a[href*="edit_client.php"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 33px;
    padding: 0 15px;
    color: #fff;
    border-radius: 999px;
    text-decoration: none;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

.action-links a[href*="edit_client.php"] {
    background: linear-gradient(180deg, #255b51 0%, #184a40 100%);
}

.action-links a[href*="delete_client.php"] {
  color: #c43b2a;
  margin: 0 auto;
  font-weight: 400;
}

.action-links a[href*="edit_client.php"]:hover {
    filter: brightness(0.98);
}

.form-card {
    display: grid;
    gap: 18px;
    padding: 28px;
}

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

.field-full,
.form-actions {
    grid-column: 1 / -1;
}

.auth-card {
    width: min(100%, 420px);
}

.form-error {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid rgba(201, 90, 56, 0.24);
    border-radius: var(--radius-sm);
    background: rgba(201, 90, 56, 0.1);
    color: #7f301d;
}

@media (max-width: 980px) {
    .page {
        padding: 24px 14px 36px;
    }

    .filters,
    .summary,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        width: 100%;
    }

    .filter-actions button,
    .filter-actions .secondary-link,
    .form-actions button,
    .form-actions .secondary-link {
        width: 100%;
    }

    .summary-card strong {
        font-size: 1.3rem;
    }
}

@media (max-width: 640px) {
    h1 {
        font-size: 2.2rem;
    }

    .toolbar,
    .form-card {
        padding: 18px;
    }

    th,
    td {
        padding: 12px 10px;
    }
}
