* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: #f0f2f5;
    color: #2d3436;
    min-height: 100vh;
    direction: rtl;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* Header */
.header {
    margin-bottom: 30px;
}

.header h1 {
    font-size: 1.8rem;
    color: #2d3436;
    border-bottom: 3px solid #e17055;
    padding-bottom: 10px;
    display: inline-block;
}

.back-link {
    display: inline-block;
    margin-bottom: 10px;
    color: #0984e3;
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: #074c8a;
}

/* Forms */
.add-form {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid #dfe6e9;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.inline-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.service-form .form-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.input-field {
    background: #f8f9fa;
    border: 1px solid #dfe6e9;
    color: #2d3436;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-field:focus {
    border-color: #0984e3;
    box-shadow: 0 0 0 3px rgba(9,132,227,0.1);
}

.input-field::placeholder {
    color: #b2bec3;
}

.inline-form .input-field {
    flex: 1;
}

.input-price {
    width: 120px;
}

.input-currency {
    width: 150px;
}

.parent-indicator {
    margin-top: 10px;
    padding: 8px 12px;
    background: #e17055;
    color: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.btn-add {
    background: #00b894;
    color: #fff;
}

.btn-add:hover {
    background: #00a381;
}

.btn-delete {
    background: #e17055;
    color: #fff;
    padding: 8px 12px;
    font-size: 1.1rem;
}

.btn-delete:hover {
    background: #c0392b;
}

.btn-delete-sm {
    background: transparent;
    color: #d63031;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1;
    padding: 3px 8px 5px;
    border-radius: 4px;
}

.btn-delete-sm:hover {
    background: #d6303120;
}

.btn-sub {
    background: transparent;
    color: #0984e3;
    border: 1px solid #0984e3;
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 4px;
}

.btn-sub:hover {
    background: #0984e310;
}

.btn-small {
    padding: 4px 10px;
    background: #fff;
    color: #e17055;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

/* Clients Grid */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.client-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #dfe6e9;
    overflow: hidden;
    transition: box-shadow 0.15s;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.client-card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.client-link {
    display: block;
    padding: 20px;
    text-decoration: none;
    color: inherit;
}

.client-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2d3436;
    margin-bottom: 10px;
}

.client-totals {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.total-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-sar {
    background: #00b89415;
    color: #00a381;
    border: 1px solid #00b89440;
}

.badge-usd {
    background: #6c5ce715;
    color: #6c5ce7;
    border: 1px solid #6c5ce740;
}

.no-services {
    color: #b2bec3;
    font-size: 0.85rem;
}

.delete-form {
    position: absolute;
    top: 10px;
    left: 10px;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #dfe6e9;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.services-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

.services-table thead {
    background: #dfe6e9;
}

.services-table th {
    padding: 14px 16px;
    text-align: right;
    font-weight: 600;
    color: #2d3436;
    font-size: 0.9rem;
    white-space: nowrap;
}

.services-table td {
    padding: 12px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid #f0f2f5;
    word-break: break-word;
    white-space: normal;
}

/* Row alternation */
.row-odd {
    background: #ffffff;
}

.services-table {
    table-layout: fixed;
    width: 100%;
}

.services-table th:first-child,
.services-table td:first-child {
    width: 35%;
}

.row-even {
    background: #f8f9fa;
}

.sub-row {
    background: #edf5ff;
}

.sub-name {
    padding-right: 30px !important;
    color: #636e72;
    font-size: 0.85rem;
}

.service-price {
    font-weight: 600;
    color: #e17055;
}

.service-currency {
    color: #636e72;
}

.service-row-total {
    font-weight: 700;
    color: #00b894;
}

.service-actions {
    display: flex;
    gap: 5px;
    align-items: center;
}

/* Editable cells */
.editable {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
    min-width: 60px;
    display: inline-block;
}

.editable:hover {
    background: #dfe6e9;
}

.editable-input {
    background: #fff;
    border: 2px solid #0984e3;
    color: #2d3436;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 100%;
    outline: none;
}

.editable-select {
    background: #fff;
    border: 2px solid #0984e3;
    color: #2d3436;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    outline: none;
}

/* Totals Section */
.totals-section {
    margin-top: 30px;
}

.totals-section h3 {
    color: #2d3436;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.totals-grid {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.total-card {
    padding: 20px 30px;
    border-radius: 12px;
    min-width: 200px;
    color: #fff;
}

.card-sar {
    background: linear-gradient(135deg, #00b894, #00a381);
}

.card-usd {
    background: linear-gradient(135deg, #6c5ce7, #5a4bd1);
}

.total-label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.total-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

/* Responsive */
@media (max-width: 600px) {
    .inline-form {
        flex-direction: column;
    }
    .service-form .form-row {
        flex-direction: column;
    }
    .input-price, .input-currency {
        width: 100%;
    }
    .clients-grid {
        grid-template-columns: 1fr;
    }
}
