:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --background-color: #f8fafc;
    --card-background: #ffffff;
    --text-color: #1e293b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --font-family: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior-y: none;
}

.container {
    position: relative;
    width: 100%;
    max-width: 768px;
    /* Tablet width optimization */
    margin: 20px;
    background: var(--card-background);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
}

h1 {
    font-weight: 600;
    color: var(--primary-color);
}

/* Tabs */
.tabs-nav {
    display: flex;
    gap: 1rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: #666;
    font-weight: 600;
    font-size: 1rem;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

/* Settings Sections */
.settings-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.settings-section h2 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

/* Document Cards (Registration Form) */
.doc-card {
    background: white;
    border: 1.5px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.doc-card-header {
    background: linear-gradient(135deg, #1a73e8, #4285f4);
    color: white;
    padding: 0.8rem 1.2rem;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.doc-card-viewer {
    width: 100%;
    height: 55vh;
    min-height: 350px;
    border: none;
    display: block;
}

.doc-card-sign {
    padding: 1rem 1.2rem;
    background: #fafafa;
    border-top: 1px solid #eee;
}

.doc-card-sign label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.4rem;
    display: block;
}

.doc-card-sign .sig-canvas-wrap {
    border: 2px dashed #ccc;
    border-radius: 8px;
    background: white;
    height: 130px;
    position: relative;
    margin-bottom: 0.4rem;
}

.doc-card-sign canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

.doc-card-status {
    text-align: center;
    padding: 3rem;
    color: #999;
}

/* Column Order */
.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.8rem;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 0.4rem;
    background: #fafafa;
    font-size: 0.9rem;
}

.order-item span {
    font-weight: 500;
}

.order-btns {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}

.order-btns button.btn-icon-move {
    background: #e8eaf0 !important;
    border: none !important;
    border-radius: 6px !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px;
    font-size: 0.7rem !important;
    cursor: pointer;
    color: #555;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
}

.order-btns button.btn-icon-move:hover:not(:disabled) {
    background: #d0d4de !important;
}

.order-btns button.btn-icon-move:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 100;
    max-height: 280px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 0.7rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: #f0f4ff;
}

.autocomplete-item strong {
    color: #333;
}

.add-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.settings-list {
    list-style: none;
    padding: 0;
}

.settings-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.8rem;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
}

.settings-list li:last-child {
    border-bottom: none;
}

.tag-treatment {
    background: #e3f2fd;
    color: #1976d2;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.btn-delete-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: #ff5252;
}

.status-indicator {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 20px;
    background-color: var(--success-color);
    color: white;
}

.status-offline {
    background-color: var(--warning-color);
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px;
    /* Large touch target */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Signature Pad Styles */
.signature-section {
    margin-top: 30px;
    margin-bottom: 30px;
}

.signature-wrapper {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    height: 200px;
    background-color: #fafafa;
    position: relative;
    margin-bottom: 10px;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Buttons */
.actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

button {
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    padding: 14px 20px;
    font-size: 1rem;
    transition: background-color 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
    font-size: 0.9rem;
    padding: 8px 16px;
    width: auto;
    align-self: flex-start;
}

.btn-secondary:hover {
    background-color: #475569;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .container {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }
}

/* Hierarchical CRM Table */
.client-row {
    transition: background-color 0.2s;
    border-left: 4px solid transparent;
}

.client-row:hover {
    background-color: #f1f5ff !important;
}

.expand-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 20px;
    font-size: 0.7rem;
    color: var(--secondary-color);
    transition: transform 0.2s;
}

.sessions-row td {
    padding: 0 !important;
    border-bottom: 2px solid #eef2ff !important;
}

.sub-table {
    background: #fff;
    margin: 10px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.sub-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f1f5ff;
    padding: 10px 15px !important;
}

.sub-table tbody tr:hover {
    background: #f9faff;
}

.sub-table td {
    color: #444;
    padding: 10px 15px !important;
}

/* Category Toggle in Management Modal */
.category-select {
    outline: none;
    transition: border-color 0.2s;
}

.category-select:focus {
    border-color: var(--primary-color);
}