/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #4F46E5;
    --primary-dark: #3730A3;
    --primary-light: #EEF2FF;
    --danger: #EF4444;
    --danger-dark: #DC2626;
    --success: #10B981;
    --text: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --bg: #F9FAFB;
    --white: #FFFFFF;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --radius: 8px;
    --radius-sm: 4px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ===== Auth Pages ===== */
.auth-page { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }

.auth-container { width: 100%; max-width: 420px; padding: 1rem; }

.auth-box { background: var(--white); border-radius: 16px; padding: 2.5rem; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }

.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo h1 { font-size: 2rem; font-weight: 800; color: var(--primary); letter-spacing: 2px; }
.auth-logo p { color: var(--text-muted); margin-top: 0.25rem; }

.auth-footer { text-align: center; margin-top: 1.5rem; color: var(--text-muted); }
.auth-footer a { color: var(--primary); font-weight: 500; }
.auth-footer a:hover { text-decoration: underline; }

/* ===== Navbar ===== */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-brand a { font-size: 1.25rem; font-weight: 800; color: var(--primary); letter-spacing: 1px; }

.nav-menu { display: flex; align-items: center; gap: 1rem; }

.nav-link { color: var(--text-muted); font-weight: 500; padding: 0.25rem 0.5rem; border-radius: var(--radius-sm); transition: color 0.2s; }
.nav-link:hover { color: var(--primary); }

.nav-user { font-weight: 600; color: var(--text); padding: 0 0.5rem; }

/* ===== Container ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ===== Page Header ===== */
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.5rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }

/* ===== Form Elements ===== */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.4rem; color: var(--text); }

.form-control {
    width: 100%;
    padding: 0.6rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }

.textarea-lg { min-height: 280px; resize: vertical; }

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

.form-card { background: var(--white); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }

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

.field-error { color: var(--danger); font-size: 12px; margin-top: 0.3rem; }
.hint { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.required { color: var(--danger); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); }

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

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: var(--danger-dark); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 13px; }
.btn-full { width: 100%; }

/* ===== Alerts ===== */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 14px; font-weight: 500; }
.alert-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

/* ===== Badge ===== */
.badge { background: var(--primary); color: var(--white); font-size: 11px; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 999px; }

/* ===== Search ===== */
.search-form { margin-bottom: 1.5rem; }
.search-group { display: flex; gap: 0.5rem; }
.search-group .form-control { flex: 1; }

.search-result-info { margin-bottom: 1rem; color: var(--text-muted); font-size: 13px; }

/* ===== Memo Grid ===== */
.memo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }

.memo-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: box-shadow 0.2s, transform 0.2s;
}
.memo-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.memo-card-header { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.memo-date { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.memo-category {
    font-size: 11px;
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
}

.memo-title { font-size: 15px; font-weight: 700; }
.memo-title a:hover { color: var(--primary); }

.memo-preview { color: var(--text-muted); font-size: 13px; line-height: 1.5; flex: 1; white-space: pre-wrap; }

.memo-card-footer { display: flex; gap: 0.5rem; margin-top: auto; }

/* ===== Memo View ===== */
.memo-view-card { background: var(--white); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }

.memo-view-meta { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }

.memo-view-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }

.memo-view-content { color: var(--text); line-height: 1.8; white-space: pre-wrap; min-height: 200px; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state p { margin-bottom: 1rem; font-size: 15px; }

/* ===== Settings Layout ===== */
.settings-layout { display: grid; grid-template-columns: 350px 1fr; gap: 1.5rem; align-items: start; }

.settings-add-card, .settings-list-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.settings-add-card h3, .settings-list-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }

/* ===== Table ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 0.6rem 0.75rem; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.data-table td { padding: 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 200; }

.modal-content { background: var(--white); border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-close:hover { color: var(--text); }

/* ===== Dashboard ===== */
.dashboard-header { margin-bottom: 2rem; }
.dashboard-header h2 { font-size: 1.75rem; font-weight: 700; }
.text-muted { color: var(--text-muted); margin-top: 0.25rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-icon { font-size: 2rem; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 0.25rem; font-weight: 500; }

.dashboard-section { background: var(--white); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }
.section-header h3 { font-size: 1rem; font-weight: 700; }

.recent-memo-list { display: flex; flex-direction: column; gap: 0; }

.recent-memo-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.recent-memo-item:last-child { border-bottom: none; }

.recent-memo-meta { display: flex; align-items: center; gap: 0.5rem; }

.recent-memo-title { font-size: 15px; font-weight: 600; color: var(--text); }
.recent-memo-title:hover { color: var(--primary); }

.recent-memo-preview { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.dashboard-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }


/* ===== Hamburger ===== */
.nav-hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    color: var(--text);
    line-height: 1;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .navbar { padding: 0 1rem; position: relative; flex-wrap: wrap; height: auto; min-height: 60px; }
    .nav-hamburger { display: block; }
    .nav-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--white);
        padding: 0.5rem 1.25rem 1rem;
        border-bottom: 2px solid var(--border);
        box-shadow: 0 4px 12px rgba(0,0,0,0.12);
        z-index: 99;
        gap: 0;
    }
    .nav-menu.open { display: flex; }
    .nav-menu .nav-link { display: block; padding: 0.65rem 0; border-bottom: 1px solid var(--bg); width: 100%; }
    .nav-menu .nav-user { padding: 0.65rem 0; font-size: 13px; border-bottom: 1px solid var(--bg); }
    .nav-menu form { padding: 0.5rem 0 0; }
    .nav-menu .btn { width: fit-content; }

    .settings-layout { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .memo-grid { grid-template-columns: 1fr; }
    .container { padding: 1rem; }
    .stat-grid { grid-template-columns: 1fr 1fr; }

    .filter-form { flex-direction: column !important; align-items: stretch !important; gap: 0.5rem !important; }
    .filter-form select { width: 100% !important; }
    .filter-form input[type="date"] { width: 100% !important; }
    .filter-bar { flex-direction: column !important; align-items: stretch !important; gap: 0.5rem !important; }
    .filter-bar input[type="date"] { width: 100% !important; }

    .top-bar { flex-direction: column; }
    .top-bar > .btn,
    .top-bar > a.btn { width: 100%; justify-content: center; }
    .top-bar #collectMsg { text-align: center; }

    .stock-add-form { flex-direction: column !important; align-items: stretch !important; }
    .stock-add-form .form-group { flex: none !important; margin-bottom: 0 !important; }
    .stock-add-form input,
    .stock-add-form select { width: 100% !important; }
    .stock-add-form .btn { width: 100% !important; }

    .sig-stock-add-grid { grid-template-columns: 1fr !important; }
    .sig-account-grid { grid-template-columns: 1fr !important; }

    .rate-row { flex-wrap: wrap; gap: 0.5rem; }
    .rate-row label { min-width: 0 !important; width: 100%; }
    .rate-row .form-control { width: 100% !important; }

    .form-actions { flex-direction: column-reverse; gap: 0.5rem; }
    .form-actions .btn { width: 100%; }
    .dashboard-actions { flex-direction: column; }
    .dashboard-actions .btn { width: 100%; }

    .summary-row { gap: 0.5rem; }
    .summary-card { flex: 1 1 calc(50% - 0.25rem); min-width: 0; }

    .status-bar { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
    .status-bar .btn { margin-left: 0 !important; }

    .modal-content { margin: 1rem; width: calc(100% - 2rem); max-width: none; }

    .auth-box { padding: 1.5rem 1rem; }

    .order-card { padding: 1.25rem 1rem; }
}
