:root {
    --primary: #111827;
    /* almost-black */
    --accent: #dacfbf;
    /* sand accent */
    --accent-soft: #f5efe7;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --border-subtle: #f3f4f6;
    --text-main: #111827;
    --text-muted: #6b7280;
    --danger: #b91c1c;

    --radius-card: 12px;
    --shadow-soft: 0 10px 25px rgba(15, 23, 42, 0.06);

    --font-heading: "Montserrat", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        sans-serif;
    --font-body: "Nunito Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-main);
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

/* Shared layout */

.shell {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.shell-inner {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 16px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

main {
    width: 100%;
    display: block;
}

/* Auth view */

#auth-view {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #e5e7eb, #f9fafb);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    padding: 32px 28px 26px;
}

.auth-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
    margin-bottom: 24px;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 200px;
    height: auto;
    flex-shrink: 0;
}

.auth-heading-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.auth-title {
    font-family: var(--font-heading);
    font-size: 22px;
    text-transform: uppercase;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

.auth-note {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 18px;
}

.auth-form-group {
    margin-bottom: 14px;
}

.auth-form-group label {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--text-main);
}

.auth-form-group input {
    width: 100%;
    padding: 9px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-family: var(--font-body);
    font-size: 14px;
}

.auth-form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-soft);
}

.auth-actions {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn {
    border-radius: 999px;
    border: none;
    font-family: var(--font-body);
    font-size: 14px;
    padding: 9px 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.06s ease;
}

.btn-primary {
    background: #000000;
    color: #ffffff;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.09);
}

.btn-primary:hover {
    background: #1C1C1C;
    color: #ffffff;
    box-shadow: 0 12px 25px rgba(15, 23, 42, 0.1);
    transform: translateY(-0.5px);
}

.btn-ghost {
    background: transparent;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 12px;
    padding: 6px 12px;
    color: var(--text-main);
}

.btn-ghost:hover {
    background: #ffffff;
    box-shadow: var(--shadow-soft);
}

.auth-error {
    min-height: 18px;
    font-size: 12px;
    color: var(--danger);
    margin-top: 2px;
}

.auth-footer {
    margin-top: 16px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    margin-top: 0.5rem;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
}

.forgot-password-panel {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #ccc;
}

.small-text {
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.small-btn {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    padding: 0.35rem 0.75rem;
}

.forgot-password {
    text-align: center;
}

.forgot-password-panel {
    text-align: center;
}

.forgot-password-panel .input {
    margin-top: 0.5rem;
    width: 80%;
}

.forgot-password-panel .btn-primary {
    margin-left: 0.5rem;
}

/* Ensures all text matches main card styling */
.forgot-password,
.forgot-password-panel,
.forgot-password-panel .small-text {
    font-family: inherit !important;
}

/* App view */

#app-view {
    display: none;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.brand-logo {
    width: 200px;
    height: auto;
}

.brand-text-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 20px;
}

.brand-title {
    font-family: var(--font-heading);
    font-size: 16px;
    text-transform: uppercase;
}

.brand-tagline {
    font-size: 13px;
    color: var(--text-muted);
}

.user-block {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-pill {
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #ffffff;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}

.user-pill strong {
    font-weight: 600;
    color: var(--text-main);
}

/* Tabs */

.tabs {
    display: flex;
    gap: 6px;
    margin-top: 16px;
    flex-wrap: wrap;
    width: 100%;
}

/* === Layout fixes for Documents tab === */

#tab-documents.tab-panel {
    width: 100%;
    padding: 0 24px;
}

#tab-documents .card {
    max-width: none;
    width: 100%;
    margin: 16px 0;
}

.tab-button {
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    padding: 6px 14px;
    font-family: var(--font-body);
    font-size: 14px;
    cursor: pointer;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease,
        border-color 0.15s ease, transform 0.06s ease;
}

.tab-button:hover {
    background: rgba(218, 207, 191, 0.2);
    transform: translateY(-0.5px);
}

.tab-button.active {
    background: #ffffff;
    border-color: var(--accent);
    color: var(--text-main);
    box-shadow: var(--shadow-soft);
}

.tab-panel {
    display: none;
    width: 100%;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 0 12px;
}

.tab-panel>.card {
    max-width: 760px;
    margin: 0 auto 16px;
}

.tab-panel.active {
    display: block;
}

/* Cards and sections */

.card {
    background: var(--card-bg);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
    padding: 18px 18px 16px;
    max-width: 760px;
    margin: 0 auto 16px;
}

.card-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
}

.card-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 18px;
}

.muted {
    color: var(--text-muted);
    font-size: 13px;
}

/* Dashboard */

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 8px;
}

.dash-grid .card {
    padding: 12px 14px;
    max-width: none;
    margin: 0;
}

.actions-grid {
    max-width: 480px;
    margin: 0 auto 4px;
}

.action-card {
    cursor: pointer;
    transition: transform 0.06s ease, box-shadow 0.12s ease;
}

.action-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.action-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.action-card-icon {
    font-size: 0;
    line-height: 1;
    margin-bottom: 2px;
}

.action-card-icon svg {
    width: 28px;
    height: 28px;
    display: block;
}

.action-card-text {
    text-align: center;
}

.action-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}

.action-card-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 180px;
    margin: 4px auto 10px;
}

.action-card .btn {
    width: 100%;
    max-width: 160px;
}

.stat-value {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

.welcome-text {
    margin-top: 10px;
    font-size: 14px;
    color: var(--text-muted);
}

/* Documents */

.upload-form {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.upload-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.file-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.file-row input[type="file"] {
    font-size: 13px;
}

#clientUploadStatus,
#adminUploadStatus {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

#doc-empty-msg {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

#doc-list {
    list-style: none;
    padding-left: 0;
    margin: 6px 0 0;
}

.doc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.doc-main {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
}

.doc-icon {
    font-size: 1.15rem;
    line-height: 1;
}

.doc-text {
    display: flex;
    flex-direction: column;
}

.doc-name {
    font-size: 0.95rem;
    margin-bottom: 2px;
    word-break: break-word;
}

.doc-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.doc-download-btn {
    border: none;
    background: transparent;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px 0;
    color: var(--text-main);
    white-space: nowrap;
}

.doc-download-btn:hover {
    text-decoration: none;
}

/* Admin upload mini-card */

.admin-upload-card {
    margin-top: 16px;
}

.admin-form-group {
    margin-bottom: 12px;
}

.admin-form-group label {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
}

.admin-form-group select,
.admin-form-group input[type="file"] {
    font-size: 13px;
}

/* Admin filter bar */

.admin-filter-bar {
    margin: 8px 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.admin-filter-bar input {
    flex: 1;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 13px;
}

.admin-filter-bar input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-soft);
}

/* Toast */

.toast {
    position: fixed;
    bottom: 16px;
    right: 16px;
    background: rgba(17, 24, 39, 0.9);
    color: #fff;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Inline link inside muted help text */
#documents-help a {
    font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    border-bottom: 1px dashed var(--text-muted);
    transition: color 0.15s ease, border-color 0.15s ease;
}

#documents-help a:hover {
    color: var(--text-main);
    border-bottom-color: var(--text-main);
}

/* Responsive */

@media (max-width: 640px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-block {
        align-self: stretch;
        justify-content: space-between;
    }
}