:root {
    --altus-navy: rgb(26, 46, 89);
    --altus-gold: rgb(199, 163, 76);
    --altus-red: rgb(178, 33, 33);
    --bg: #f5f5f7;
    --card-bg: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --success: #16a34a;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

.hidden { display: none !important; }

button {
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    background: transparent;
    color: var(--text-primary);
}

button.primary {
    background: var(--altus-navy);
    color: white;
}
button.primary:hover { background: rgb(20, 36, 70); }

button.secondary {
    background: white;
    border-color: var(--border);
}
button.secondary:hover { background: #f3f4f6; }

button.danger { color: var(--danger); }
button.danger:hover { background: rgba(220, 38, 38, 0.08); }

button.ghost-btn {
    background: transparent;
    color: var(--text-secondary);
    padding: 6px 10px;
}
button.ghost-btn:hover { background: rgba(0,0,0,0.04); color: var(--text-primary); }

input, textarea, select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    background: white;
    color: var(--text-primary);
    transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--altus-navy);
}

textarea { resize: vertical; font-family: -apple-system, monospace; }

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.error-text {
    color: var(--danger);
    font-size: 12px;
    margin-top: 8px;
    min-height: 16px;
}

/* ===== Login ===== */
.view { min-height: 100vh; }

#loginView {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--altus-navy) 0%, rgb(38, 60, 110) 100%);
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 14px;
    width: 360px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.brand {
    text-align: center;
    margin-bottom: 28px;
}

.brand-mark {
    font-weight: 800;
    letter-spacing: 8px;
    color: var(--altus-gold);
    font-size: 18px;
}

.brand-tagline {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 4px;
}

.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card form button { margin-top: 12px; padding: 10px; }
.login-card label { margin-top: 6px; }

/* ===== Main App ===== */
#appView {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--altus-navy);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
}
.sidebar .brand { text-align: left; margin-bottom: 32px; }
.sidebar .brand-mark { font-size: 14px; }
.sidebar .brand-tagline { color: rgba(255,255,255,0.5); }

.sidenav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.navitem {
    background: transparent;
    color: rgba(255,255,255,0.7);
    border: none;
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.navitem:hover { background: rgba(255,255,255,0.06); color: white; }
.navitem.active {
    background: rgba(255,255,255,0.12);
    color: white;
    font-weight: 600;
}

.navicon { font-size: 16px; }

.userbox {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 16px;
}
.user-email {
    color: rgba(255,255,255,0.6);
    font-size: 11px;
    margin-bottom: 8px;
    word-break: break-all;
}
.userbox .ghost-btn { color: rgba(255,255,255,0.7); }
.userbox .ghost-btn:hover { color: white; background: rgba(255,255,255,0.08); }

/* ===== Tabs / Main Content ===== */
.main {
    flex: 1;
    overflow-y: auto;
    padding: 28px 36px;
}

.tab { display: none; }
.tab.active { display: block; }

.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.tab-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.filters select { width: auto; min-width: 140px; }

/* ===== List Grid (Articles) ===== */
.list-grid {
    display: grid;
    gap: 12px;
}

.list-item {
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.15s;
}
.list-item:hover {
    border-color: var(--altus-navy);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.list-item-main { flex: 1; min-width: 0; }
.list-item-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.list-item-meta {
    color: var(--text-secondary);
    font-size: 12px;
    display: flex;
    gap: 12px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.badge.published { background: rgba(22, 163, 74, 0.1); color: var(--success); }
.badge.draft { background: rgba(107, 114, 128, 0.15); color: var(--text-secondary); }
.badge.archived { background: rgba(107, 114, 128, 0.1); color: var(--text-secondary); }
.badge.sold { background: rgba(178, 33, 33, 0.1); color: var(--altus-red); }
.badge.active { background: rgba(22, 163, 74, 0.1); color: var(--success); }
.badge.pro { background: rgba(199, 163, 76, 0.15); color: var(--altus-gold); }
.badge.module { background: rgba(26, 46, 89, 0.08); color: var(--altus-navy); }

/* ===== Artworks Grid ===== */
.artworks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.artwork-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
}
.artwork-card:hover {
    border-color: var(--altus-navy);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.artwork-image {
    width: 100%;
    height: 160px;
    background: #f3f4f6 center/cover no-repeat;
    position: relative;
}
.artwork-image.sold { filter: grayscale(1); opacity: 0.85; }
.artwork-image .sold-stamp {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-12deg);
    color: var(--altus-red);
    font-family: serif;
    font-weight: 900;
    font-size: 18px;
    letter-spacing: 2px;
    border: 2px solid var(--altus-red);
    padding: 4px 10px;
    background: rgba(255,255,255,0.05);
    opacity: 0.9;
}

.artwork-info {
    padding: 12px;
}
.artwork-info-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.artwork-info-period {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.artwork-info-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.artwork-info-price {
    color: var(--altus-gold);
    font-size: 12px;
    font-weight: 600;
}

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

.modal-content {
    background: white;
    border-radius: 14px;
    width: 560px;
    max-width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-content.wide { width: 880px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; font-weight: 700; }

.close-btn {
    background: transparent;
    border: none;
    font-size: 18px;
    color: var(--text-secondary);
    padding: 4px 10px;
}
.close-btn:hover { color: var(--text-primary); }

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: #fafafa;
}
.modal-footer .spacer { flex: 1; }

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

.checkbox-row { margin-bottom: 16px; }
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: none;
    font-weight: normal;
    font-size: 13px;
    color: var(--text-primary);
    letter-spacing: normal;
    cursor: pointer;
    margin-bottom: 0;
}
.checkbox-label input { width: auto; cursor: pointer; }

/* ===== Image Dropzone ===== */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s;
    overflow: hidden;
}
.dropzone:hover, .dropzone.dragging {
    border-color: var(--altus-navy);
    background: rgba(26, 46, 89, 0.02);
}

.image-preview {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa center/cover no-repeat;
}
.image-preview.empty {
    color: var(--text-secondary);
    font-size: 13px;
}

.dropzone-hint { color: var(--text-secondary); }

/* ===== Toast notifications ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--altus-navy);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    font-size: 13px;
    font-weight: 500;
    z-index: 200;
    transition: opacity 0.2s;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ===== Toast UI Editor overrides ===== */
.toastui-editor-defaultUI { border-radius: 8px; }
