:root {
    --ios-bg: #f2f2f7;
    --ios-card: #ffffff;
    --ios-blue: #007aff;
    --ios-text: #1c1c1e;
    --ios-gray: #8e8e93;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    background-color: #d1d1d6;
    color: var(--ios-text);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
}

.app-wrapper {
    width: 100%;
    max-width: 600px;
    min-height: 100vh;
    background-color: var(--ios-bg);
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.08);
    padding-bottom: 85px;
}

.hidden { display: none !important; }

h4 { font-weight: 700; font-size: 22px; margin-bottom: 5px; margin-top: 0; }

.login-box { max-width: 360px; margin: 80px auto 15px auto; }
.login-badge {
    width: 56px; height: 56px; border-radius: 16px;
    background: rgba(0, 122, 255, 0.12); color: var(--ios-blue);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; margin: 0 auto 15px auto;
}

.app-header {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(15px);
    padding: 18px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #e5e5ea;
}

.store-pill {
    display: inline-block;
    background: rgba(0, 122, 255, 0.12);
    color: var(--ios-blue);
    font-size: 11px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 8px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.header-metrics {
    font-size: 13px;
    color: var(--ios-gray);
    margin-top: 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ios-card {
    background: var(--ios-card);
    border-radius: 16px;
    padding: 20px;
    margin: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.section-divider {
    margin: 22px 0 14px 0;
    border-bottom: 1px solid #e5e5ea;
    padding-bottom: 6px;
}
.section-divider span {
    font-size: 11px;
    font-weight: 800;
    color: var(--ios-blue);
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.input-group { margin-bottom: 14px; width: 100%; box-sizing: border-box; }
.input-group label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ios-gray);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.ios-input {
    width: 100%;
    background: var(--ios-bg);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 15px;
    color: var(--ios-text);
    outline: none;
    transition: 0.25s;
    box-sizing: border-box;
}
.ios-input:focus { border-color: var(--ios-blue); background: #fff; }
.ios-input:read-only, .ios-input:disabled { opacity: 0.75; background: #e5e5ea; cursor: not-allowed; }

.flex-row { display: flex; flex-direction: row; gap: 12px; }
@media (max-width: 480px) { .flex-row { gap: 8px; } }

.chip-container { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.ios-chip {
    background: #e5e5ea;
    border: none;
    padding: 9px 15px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ios-text);
    cursor: pointer;
    transition: 0.2s;
}
.ios-chip.active { background: var(--ios-blue); color: white; transform: scale(1.03); }

.channel-block {
    background: #fafafa;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 14px;
    border-left: 4px solid var(--ios-blue);
    animation: fadeIn 0.25s ease-in-out;
    box-sizing: border-box;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.summary-preview-card {
    background: #f2f7ff;
    border: 1px solid #d0e3ff;
    border-radius: 14px;
    padding: 14px 16px;
    margin-top: 15px;
}
.sum-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--ios-blue);
    margin-bottom: 8px;
}
.sum-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    font-size: 13px;
}

.ios-btn {
    background: var(--ios-blue);
    color: white;
    border: none;
    width: 100%;
    padding: 14px 10px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    box-sizing: border-box;
    text-align: center;
}
.ios-btn:active { transform: scale(0.98); opacity: 0.9; }
.ios-btn-warning { background: #ff9500; }
.ios-btn-success { background: #34c759; }

.tab-bar {
    position: fixed;
    bottom: 0;
    width: 100%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-top: 1px solid #e5e5ea;
    display: flex;
    justify-content: space-around;
    padding: 10px 0 22px 0;
    z-index: 1000;
}
.tab-item {
    text-align: center;
    color: var(--ios-gray);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    width: 20%;
}
.tab-item i { font-size: 20px; display: block; margin-bottom: 3px; }
.tab-item.active { color: var(--ios-blue); }

.history-item {
    padding: 15px 18px;
    border-bottom: 1px solid #e5e5ea;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.history-item:last-child { border-bottom: none; }
.h-date { font-weight: 700; font-size: 15px; }
.h-sub { font-size: 12.5px; color: var(--ios-gray); margin-top: 3px; }

.info-detail { text-align: left; font-size: 13.5px; line-height: 1.6; color: #444; }
.info-detail b { color: #1c1c1e; }

.refresh-btn { background: none; border: none; cursor: pointer; padding: 4px; outline: none; }
.spin { animation: spinAnim 0.6s ease-in-out; }
@keyframes spinAnim { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.swal-custom-input {
    width: 100%;
    box-sizing: border-box;
    background: var(--ios-bg);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--ios-text);
    outline: none;
}
.swal-custom-input:focus { border-color: var(--ios-blue); background: #fff; }
.swal-label {
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--ios-gray);
    margin-bottom: 5px;
    display: block;
    text-transform: uppercase;
}

#sessionLoading { text-align: center; margin-top: 150px; }
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 40px; height: 40px; border-radius: 50%;
    border-left-color: var(--ios-blue);
    animation: spinAnim 1s linear infinite;
    margin: 0 auto 15px auto;
}

/* TABLET & DESKTOP FULL-SCREEN SIDEBAR */
@media (min-width: 768px) {
    body { align-items: flex-start; background-color: var(--ios-bg); }
    .app-wrapper { max-width: 100%; width: 100%; margin: 0; box-shadow: none; padding-bottom: 0; }
    #appSection {
        display: grid;
        grid-template-columns: 240px 1fr;
        grid-template-rows: auto 1fr auto;
        min-height: 100vh;
    }
    .app-header { grid-column: 2 / 3; grid-row: 1 / 2; padding: 22px 40px; }
    .tab-content { grid-column: 2 / 3; grid-row: 2 / 3; padding: 20px 40px; }
    #appSection > div:nth-last-child(2) { grid-column: 2 / 3; grid-row: 3 / 4; padding-bottom: 20px; }
    .tab-bar {
        position: fixed; top: 0; left: 0; width: 240px; height: 100vh;
        flex-direction: column; justify-content: flex-start;
        padding-top: 35px; background: #fff;
        border-top: none; border-right: 1px solid #e5e5ea;
        gap: 8px; max-width: none;
    }
    .tab-item {
        width: 88%; margin: 0 auto; border-radius: 12px;
        text-align: left; padding: 14px 18px; font-size: 14px;
        display: flex; align-items: center; gap: 14px; box-sizing: border-box;
    }
    .tab-item:hover { background: rgba(0, 122, 255, 0.08); }
    .tab-item.active { background: rgba(0, 122, 255, 0.12); color: var(--ios-blue); }
    .tab-item i { margin-bottom: 0; font-size: 20px; width: 24px; text-align: center; }
    .ios-card { padding: 28px; }
    .flex-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
    #multiChannelForms { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
    .channel-block { margin-bottom: 0; }
    .sum-grid { grid-template-columns: 1fr 1fr; }
}
