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

:root {
    --green: #1a7a4c;
    --green-light: #e8f5ef;
    --green-dark: #145f3b;
    --dark: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --gray-light: #f3f4f6;
    --white: #ffffff;
    --red: #dc2626;
    --red-light: #fef2f2;
    --orange: #f59e0b;
    --orange-light: #fef3c7;
    --radius: 12px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-secondary);
    background: var(--gray-light);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color-scheme: light;
}

h1, h2, h3, h4 {
    color: var(--dark);
    text-wrap: balance;
}

/* APP NAV */
.app-nav {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.app-nav .logo {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--green);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-nav .logo img,
.logo > img,
.upgrade-logo img {
    height: 32px;
    width: 32px;
    border-radius: 6px;
    vertical-align: middle;
}
.upgrade-logo { display: inline-flex; align-items: center; gap: 8px; }

.app-nav .logo span { color: var(--dark); }

.app-nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-nav-user {
    font-size: 14px;
    color: var(--text-secondary);
}

.app-nav-link {
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    letter-spacing: 0.01em;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.15s;
}

.app-nav-link:hover { background: var(--gray-light); }

.btn-logout {
    font-size: 13px;
    color: var(--text-tertiary);
    background: none;
    border: 1px solid #e5e7eb;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.btn-logout:hover { border-color: #d1d5db; color: var(--text-secondary); }

/* LAYOUT */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

/* CARDS */
.card {
    background: white;
    border-radius: var(--radius);
    border: 1px solid #e5e7eb;
    padding: 24px;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.015em;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--green);
    color: white;
}

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

.btn-secondary {
    background: var(--gray-light);
    color: var(--dark);
    border: 1px solid #e5e7eb;
}

.btn-secondary:hover { background: #e5e7eb; }

.btn-danger {
    background: var(--red-light);
    color: var(--red);
}

.btn-danger:hover { background: #fee2e2; }

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* FORMS */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    letter-spacing: 0.01em;
    outline: none;
    transition: border-color 0.15s;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--green);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-error {
    color: var(--red);
    font-size: 13px;
    margin-top: 4px;
}

/* ALERTS */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid #fecaca;
}

.alert-success {
    background: var(--green-light);
    color: var(--green-dark);
    border: 1px solid #a7f3d0;
}

/* STATUS BADGES */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.badge-pass { background: #dcfce7; color: #166534; }
.badge-fail { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-due { background: #eff6ff; color: #1d4ed8; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-late { background: #fee2e2; color: #991b1b; }

/* PROPERTY CARD */
.property-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    transition: box-shadow 0.15s;
}

.property-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.property-address {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--dark);
    margin-bottom: 12px;
}

.property-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.property-stat {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* EMPTY STATE */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-tertiary);
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 24px;
    margin-left: auto;
    margin-right: auto;
}

/* MODAL */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: white;
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

.modal h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* LOADING */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    color: var(--text-tertiary);
    font-size: 14px;
}

/* MOBILE */
@media (max-width: 640px) {
    .app-container { padding: 20px 16px; }
    .form-row { grid-template-columns: 1fr; }
    .property-stats { flex-direction: column; gap: 8px; }
    .modal { padding: 24px 20px; }
    .app-nav-user { display: none; }
}

/* =============================================
   SIDEBAR LAYOUT (Dashboard)
   ============================================= */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: white;
    border-right: 1px solid #e5e7eb;
    padding: 20px 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 50;
}

.sidebar-logo {
    padding: 0 20px 20px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #1a7a4c;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 12px;
    text-decoration: none;
    display: block;
}

.sidebar-logo span { color: #0f172a; }

.sidebar-nav { padding: 0 12px; }

.sidebar-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    padding: 20px 8px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 400;
    color: #475569;
    text-decoration: none;
    transition: all 0.1s;
    margin-bottom: 2px;
}

.sidebar-link:hover { background: #f3f4f6; color: #0f172a; }
.sidebar-link.active { background: #e8f5ef; color: #1a7a4c; font-weight: 500; }

.sidebar-trial {
    margin: 16px 12px;
    padding: 10px 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    font-size: 12px;
    color: #1d4ed8;
}

.sidebar-trial a {
    display: block;
    margin-top: 6px;
    font-weight: 500;
    color: #1a7a4c;
    text-decoration: none;
    font-size: 12px;
}

.app-main {
    margin-left: 240px;
    flex: 1;
    padding: 32px 40px;
    max-width: 1360px;
    background: #f9fafb;
    min-height: 100vh;
}

/* MOBILE SIDEBAR */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 60;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 40;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .sidebar-overlay.open { display: block; }
    .app-main { margin-left: 0; padding: 64px 16px 24px; }
}

/* =============================================
   PROPERTY LIST (Master-Detail)
   ============================================= */

.property-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
}

.property-row {
    background: white;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.1s;
}

.property-row:hover { background: #fafafa; }
.property-row.expanded { background: #fafafa; }

.property-row-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.property-row-icon {
    width: 36px;
    height: 36px;
    background: #e8f5ef;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.property-row-info { flex: 1; min-width: 0; }

.property-row-address {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.property-row-meta {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.property-row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* STATUS PILLS */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.pill-green { background: #dcfce7; color: #166534; }
.pill-orange { background: #fef3c7; color: #92400e; }
.pill-red { background: #fee2e2; color: #991b1b; }
.pill-blue { background: #eff6ff; color: #1d4ed8; }
.pill-gray { background: #f3f4f6; color: #6b7280; }

/* OVERFLOW MENU */
.overflow-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    position: relative;
}

.overflow-btn:hover { background: #f3f4f6; color: #475569; }

.overflow-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 4px;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 30;
}

.overflow-menu.open { display: block; }

.overflow-menu a,
.overflow-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 13px;
    color: #475569;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
}

.overflow-menu a:hover,
.overflow-menu button:hover { background: #f3f4f6; color: #0f172a; }

.overflow-menu .danger { color: #dc2626; }
.overflow-menu .danger:hover { background: #fef2f2; }

/* TABS */
.detail-panel {
    display: none;
    padding: 0 20px 20px;
    background: #fafafa;
}

.detail-panel.open { display: block; }

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #94a3b8;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.1s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.tab:hover { color: #475569; }
.tab.active { color: #1a7a4c; border-bottom-color: #1a7a4c; }

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* EMPTY STATE improved */
.empty-state-sm {
    text-align: center;
    padding: 32px 16px;
    color: #94a3b8;
    font-size: 13px;
}

.empty-state-sm .btn { margin-top: 12px; }

/* PAST DUE BANNER */
.past-due-banner {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* TENANT SCREENING CARDS in sidebar layout */
.screening-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.screening-card {
    text-decoration: none;
    transition: box-shadow 0.15s;
}

.screening-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* =============================================
   TOP NAV (replaces sidebar)
   ============================================= */
.top-nav {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.top-nav-logo {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #1a7a4c;
    text-decoration: none;
    margin-right: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.top-nav-logo span { color: #0f172a; }
.top-nav-logo img { height: 28px; width: 28px; border-radius: 5px; }
.top-nav-links {
    display: flex;
    gap: 4px;
    flex: 1;
}
.top-nav-link {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 400;
    color: #475569;
    text-decoration: none;
    transition: all 0.1s;
}
.top-nav-link:hover { background: #f3f4f6; color: #0f172a; }
.top-nav-link.active { background: #e8f5ef; color: #1a7a4c; font-weight: 500; }
.top-nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.top-nav-user {
    font-size: 13px;
    color: #94a3b8;
}
.top-nav-logout {
    font-size: 13px;
    color: #94a3b8;
    background: none;
    border: 1px solid #e5e7eb;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}
.top-nav-logout:hover { border-color: #d1d5db; color: #475569; }

.top-nav-trial {
    font-size: 12px;
    padding: 4px 10px;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 6px;
}
.top-nav-trial a {
    color: #1a7a4c;
    font-weight: 500;
    text-decoration: none;
    margin-left: 6px;
}

.app-content {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px;
    background: #f9fafb;
    min-height: calc(100vh - 56px);
}

/* PROPERTY DETAIL PAGE */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: #475569;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 6px 0;
    margin-bottom: 8px;
}
.back-btn:hover { color: #1a7a4c; }

.property-summary {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}
.property-summary-address {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #0f172a;
    margin-bottom: 8px;
}
.property-summary-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.property-summary-actions {
    display: flex;
    gap: 8px;
    position: relative;
}

.property-tabs-wrapper {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 20px 20px;
}

body { background: #f9fafb; }

@media (max-width: 640px) {
    .top-nav { padding: 0 12px; gap: 8px; }
    .top-nav-links { overflow-x: auto; }
    .top-nav-link { font-size: 13px; padding: 6px 10px; white-space: nowrap; }
    .top-nav-user, .top-nav-trial { display: none; }
    .app-content { padding: 16px 12px; }
    .property-summary { padding: 16px; }
    .property-summary-address { font-size: 18px; }
    .property-tabs-wrapper { padding: 12px 14px 16px; border-radius: 10px; }
}
