:root {
    --bg: #0f1419;
    --bg-card: #1a2332;
    --bg-input: #242f3d;
    --border: #2d3a4d;
    --text: #e6edf3;
    --text-muted: #8b9eb3;
    --accent: #ffcc00;
    --accent-hover: #ffd633;
    --success: #3fb950;
    --error: #f85149;
    --radius: 10px;
    --font: 'Manrope', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.app {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(135deg, var(--accent), #ffaa00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0.5rem 0 0;
}

.main {
    flex: 1;
}

.section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 1rem;
    color: var(--text);
}

.hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: -0.5rem 0 1rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.toolbar-group {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--accent);
    color: #0f1419;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-danger {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
}

.btn-danger:hover {
    background: rgba(248, 81, 73, 0.15);
}

.file-label {
    cursor: pointer;
}

.file-label input {
    display: none;
}

.signatures-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.signature-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem;
}

.signature-card .info {
    flex: 1;
    min-width: 200px;
}

.signature-card .name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.signature-card .tin {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.signature-card .phones {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.phone-tag {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    background: var(--bg);
    border-radius: 4px;
    color: var(--text);
}

.signature-card .actions {
    display: flex;
    gap: 0.5rem;
}

.validation-box {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.validation-box textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    resize: vertical;
}

.validation-box textarea::placeholder {
    color: var(--text-muted);
}

.validation-results {
    margin-top: 1rem;
}

.validation-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.validation-item:last-child {
    border-bottom: none;
}

.validation-item.valid .status {
    color: var(--success);
}

.validation-item.invalid .status {
    color: var(--error);
}

.validation-item .original {
    color: var(--text-muted);
}

.validation-item .formatted {
    color: var(--success);
}

.validation-item .error {
    color: var(--error);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-family: var(--font);
    font-size: 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 440px;
    width: 100%;
}

.modal-content h3 {
    margin: 0 0 1.25rem;
    font-size: 1.1rem;
}

.import-result {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.import-result.success {
    background: rgba(63, 185, 80, 0.15);
    border: 1px solid var(--success);
}

.import-result.errors {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--error);
}

.import-result h4 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
}

.import-result ul {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer {
    margin-top: auto;
    padding-top: 2rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.footer a:hover {
    text-decoration: underline;
}

.help-section h2 {
    margin: 0;
}

.help-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}

.help-toggle:hover {
    color: var(--accent);
}

.help-toggle-icon {
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.help-toggle[aria-expanded="true"] .help-toggle-icon {
    transform: rotate(180deg);
}

.help-content {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.help-content h3 {
    font-size: 0.95rem;
    margin: 1rem 0 0.5rem;
    color: var(--text);
}

.help-content h3:first-child {
    margin-top: 0;
}

.help-content ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.help-content li {
    margin-bottom: 0.35rem;
}

.help-content code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-input);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.help-intro {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0 0 1rem;
}

.help-intro a {
    color: var(--accent);
}

.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.login-overlay.hidden {
    display: none !important;
}

.btn-block {
    width: 100%;
}

.login-overlay-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 360px;
    width: 90%;
}

.login-overlay-content h2 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
}

.login-overlay-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 1.5rem;
}

.login-overlay-error {
    color: var(--error);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    min-height: 1.2em;
}

.help-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.log-toolbar {
    margin-bottom: 0.75rem;
}

.access-log {
    max-height: 300px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.access-log table {
    width: 100%;
    border-collapse: collapse;
}

.access-log th,
.access-log td {
    padding: 0.4rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.access-log th {
    color: var(--text-muted);
    font-weight: 500;
    position: sticky;
    top: 0;
    background: var(--bg-input);
}

.access-log tr:hover td {
    background: var(--bg);
}

.access-log .log-empty {
    padding: 1.5rem;
    color: var(--text-muted);
    text-align: center;
}

@media (max-width: 640px) {
    .app {
        padding: 1rem;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar-group {
        margin-left: 0;
    }
}
